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

ga.tolerance #10

Open
MarrowSix opened this issue May 30, 2019 · 0 comments
Open

ga.tolerance #10

MarrowSix opened this issue May 30, 2019 · 0 comments

Comments

@MarrowSix
Copy link

In the function ga.run(), the 'bestResult' and 'prevBestResult' was equal before iterations.

T bestResult = pop(0)->getTotal();
T prevBestResult = bestResult;

So, if i set ga.tolerance to a user-define value, the program will exit with the code below, because the reason i noted:

// checking convergence
if (tolerance != 0.0) {
    if (fabs(bestResult - prevBestResult) < fabs(tolerance)) {
       break;
    }
    prevBestResult = bestResult;
 }

May be you can add nogen > 1 to fix this problem:

// checking convergence
if (tolerance != 0.0 && nogen > 1) {
    if (fabs(bestResult - prevBestResult) < fabs(tolerance)) {
       break;
    }
    prevBestResult = bestResult;
 }
@thewoz thewoz mentioned this issue Nov 5, 2019
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

No branches or pull requests

1 participant