Why is the relative change higher than my "FunctionTolerance" when I use ga?

3 visualizaciones (últimos 30 días)
I want to use Genetic Algorithm and Particle Swarm Optimization to minimize an objective function without non-linear constraint. I want the algorithm to stop when the relative change of the best fitness value over the last 200 generations is less than 0.01%. For ga, I set the parameter of “FunctionTolerance” to be 0.0001, “MaxStallGenerations” to be 200, and “Generations” to be “inf”. For particleswarm, I set the parameter of “FunctionTolerance” to be 0.0001, “MaxStallIterations” to be 200, and “MaxIterations” to be 200000000 (large enough). “pso” performs well, but “ga” does not perform as expected.
I ran the program for several times and they have the same problem. “ga” stopped with an exitflag = 1. But the relative change of best fitness is much higher than 0.0001. In my program, “ga” stopped at the 510th generation with an approximate fitness value of 32740000, while the 310th generation has a fitness value of approximate 33390000. The relative change is (33390000-32740000)/32740000 = 0.02077, which is much higher than 0.0001. I have no idea what’s the problem here. The “pso” algorithm performs well under the same parameter values.
Why does this happen?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 20 de Jul. de 2020
The stopping condition from the ga code is measured by funChange:
funChange = abs(Bestfvals(1) - Bestfvals(end))/ (Window*max(1,abs(Bestfvals(end))));
Here, Bestfvals is a vector whose length is the length of Window, meaning the stall generation limit.
ga stops when funChange is smaller than the function tolerance.
My interpretation of your test is that the AVERAGE RELATIVE change over the window has to be smaller than the function tolerance, not that the TOTAL RELATIVE change is less than the function tolerance. The difference is the factor Window in the denominator. This is measuring a rate of change over the window.
If you want the TOTAL RELATIVE change to be the criterion, then you should divide the desired function tolerance by the window size.
There is a discrepancy between the stopping condition for particleswarm and ga. The corresponding line of code in particleswarm is:
funChange = abs(maxBestFvalsWindow-bestFval)/max(1,abs(bestFval));
The window does not appear in the denominator here.

Más respuestas (0)

Categorías

Más información sobre Particle Swarm en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by