The Generations option in Stopping criteria determines the maximum number of generations the genetic algorithm runs for—see Stopping Conditions for the Algorithm. Increasing the Generations option often improves the final result.
As an example, change the settings in the Optimization app as follows:
Set Fitness function to
Set Number of variables to
Select Best fitness in the Plot functions pane.
Set Generations to
Set Stall generations to
Set Stall time limit to
Run the genetic algorithm for approximately 300 generations and click Stop. The following figure shows the resulting best fitness plot after 300 generations.
Note that the algorithm stalls at approximately
generation number 170—that is, there is no immediate improvement
in the fitness function after generation 170. If you restore Stall
generations to its default value of
the algorithm could terminate at approximately generation number 220.
If the genetic algorithm stalls repeatedly with the current setting
for Generations, you can try increasing both
the Generations and Stall generations options
to improve your results. However, changing other options might be
When Mutation function is set to