Project-Platypus / Platypus

A Free and Open Source Python Library for Multiobjective Optimization
GNU General Public License v3.0
565 stars 153 forks source link

Inconsistent Results from NSGA-II #118

Closed khoopes closed 1 year ago

khoopes commented 4 years ago

Excuse my inexperience with things like this. I am working on a project where I am doing a single objective optimization of 7 variables with 4 constraints. Right now I am using NSGA-II. I use a population size of 480 and run for 500 generations.

My issue is that if I run this case multiple times I get different optimums which are different enough to have me worried that I have not found the global optimum. Is this just a sign that my population size isn't large enough and/or my number of generations isn't large enough?

In previous implementations of NSGA-II I have seen options for mutation scale, standard deviation of the random numbers generated, and shrink where the code will decrease the mutation range as the optimization progresses. Are there options like this in platypus? Or am I missing something similar?

Thanks,

hh-wu commented 4 years ago

I think you can use binary encoding instead of real encoding.

khoopes commented 4 years ago

I am not quite sure I know what you mean by that, can you elaborate?

Thanks,

dhadka commented 4 years ago

Hi @khoopes, there is no built-in mechanism to adjust the mutation range dynamically. however it should be possible with a little extra work. For the default operators SBX and PM, you can narrow the variability in generated offspring by increasing the distribution_index. Here's an example (please note that I have not tested this code, so you may need to tweak it to get it to work):

sbx = SBX()
pm = PM()
algorithm = NSGAII(problem, variator = GAOperator(sbx, pm))

for i in range(10):
    algorithm.run(1000)
    sbx.distribution_index *= 1.1
    pm.distribution_index *= 1.1

I would also suggest trying with a smaller population size and more generations. Generally speaking, a larger population slows convergence because there is more genetic diversity, which requires more generations to converge.

github-actions[bot] commented 1 year ago

This issue is stale and will be closed soon. If you feel this issue is still relevant, please comment to keep it active. Please also consider working on a fix and submitting a PR.