Open tarcisiofischer opened 2 years ago
Indeed it's a bug. I just noted the equivalence is not tested for pso. Have a look to the test for cmaes here:
https://github.com/esa/pagmo2/blob/16fced244537f6ba1a5dc8872e410e333688834f/tests/cmaes.cpp#L266
A similar test should be added also for pso, and it should pass.
Anything that needs to be remembered from previous generations should Indeed be in the algo memory. When memory=true it should be remembered.
A PR would indeed be appreciated ...
In case you do open a PR, could you also make the symmetric modifications to pso_gen?
@darioizzo I didn't make the pso_gen
modifications yet because I wanted to show the pso
version first, so you can validate if everything is as expected in terms of project patterns, and also your expectation around this. Feel free to ask for modifications.
Also note that I had to make further modifications in order to make all variations of pso
to work in the test case. Perhaps you find it to be a little overengineered... Feel free to suggest modifications around the implementation. I tried to make it as explicit as I could to avoid confusion for future readers from the code.
I'm planning on making similar changes (and adding similar test) to pso_gen
after you take a look at the PR :)
Thanks in advance!
According to this discussion, all algorithms should behave the same with
gen=N
vsN
calls withgen=1
(Did I understand correcly?).I tried with PSO in pygmo, and couldn't make it work (Will explain better after showing the code):
Results:
pso_run_a: 35.042803177459504
pso_run_b: 14.44962519803876
It seems to be a bug related to the way the population evolves. AFAIU, when returning from the algorithm, PSO will return the best fit ( important code here ), and then, in the next run,
X
will be in relation tolbX
. While when running the code iteratively with multiple generations (and assuming that one generation didn't perform better than the previous, thenX
andlbX
will be different ( important code here )There are several ways of solving this. The simplier, I believe, is to update keep an internal
m_X
in thePSO
algorithm class. What are your thoughts around this? Are you interest in a specific fix just to the PSO algorithm (I can open a PR)?Thanks in advance!