Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix for PSO GEN #349

Merged
merged 2 commits into from
Sep 29, 2019
Merged

bug fix for PSO GEN #349

merged 2 commits into from
Sep 29, 2019

Conversation

Sceki
Copy link
Member

@Sceki Sceki commented Sep 28, 2019

This PR aims to fix a bug in the pso_gen algorithm.
Instead of

                        for (decltype(x1.size()) k = 0u; k < x1.size(); ++k) {
                            if (ub[j] > lb[j]) {
                                acc += (x1[k] - x2[k]) * (x1[k] - x2[k]) / (ub[k] - lb[k]) / (ub[k] - lb[k]);
                            } // else 0
                        }

it should be :

                        for (decltype(x1.size()) k = 0u; k < x1.size(); ++k) {
                            if (ub[k] > lb[k]) {
                                acc += (x1[k] - x2[k]) * (x1[k] - x2[k]) / (ub[k] - lb[k]) / (ub[k] - lb[k]);
                            } // else 0
                        }

As j spans through the pop_size, whereas k spans through the dvs size (which is the length of ub, lb).. This error was not spotted in the current tests because the pop_size were always chosen to be smaller than the dvs size.. thus shadowing the error.

@Sceki Sceki changed the title bug fix for pso_gen bug fix for PSO GEN Sep 28, 2019
@darioizzo
Copy link
Member

A bug indeed. Nice catch. We tried with @bluescarni to understand when and how it was introduced, its likely it was me that when coding pso_gen decided to check the bounds in a separate for loop and mistyped the indexes. The issue was not caught as pso_gen has been rarely used since without bfe pso is almost always a better option. The reason pso_gen was coded at all in pagmo2 is to allow neuroevolution, since we used this algorithm during the ACT-MIT SPHERES experiments.

Its a definite merge for me.

@darioizzo darioizzo merged commit 448d92a into esa:master Sep 29, 2019
@Sceki Sceki deleted the pso_gen_bug branch September 29, 2019 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants