Why my 20 variables nonlinear constraint Genetic Algorithm runs for only 5~6 generations?

I want to optimize the one siderostat array, according to the Cornwell's fitness function. This is the background of my program.
There are 20 variables in my GA, and nonlinear constraint. It is supposed that the algorithm may run for hundreds of generations. But it runs for only 5~6 generations.
Is there any wrong in my code?
clear
clc
global d_aperture; d_aperture = 0.1;
global d_max; d_max = 10;
global N; N = 10;
object_function = @cornwell;
nvars = 2 * N;
LB = ones(1, nvars).* d_max / 2 * -1;
UB = ones(1, nvars).* d_max / 2;
constraint_function = @d_constraint;
options = gaoptimset(@ga);
options = gaoptimset(options, ...
'PlotFcn', {@gaplotbestf, @gaplotstopping}, ...
'Display', 'iter', ...
'MutationFcn', @mutationadaptfeasible, ...
'Tolcon', 1e-8);
[x,val] = ga(object_function, nvars, [], [], [], [], ...
LB, UB, ...
constraint_function, ...
options);
here is what printed in the command line window:
Best max Stall
Generation f-count f(x) constraint Generations
1 10600 -17688.4 0 0
2 21000 -17722.4 0 0
3 31400 -17724.8 0 0
4 41800 -17725 0 0
5 52200 -17725 0 0
Optimization terminated: average change in the fitness value less than options.TolFun
and constraint violation is less than options.TolCon.
can anyone explain it?

1 Comment

sir do you have any experience of applying genetic algorithm for cell formation? its a cellular manufacturing technique. I want some guide to implement genetic algorithm for this. thanks if you can help out some way.

Sign in to comment.

 Accepted Answer

The reason you get so few "iterations" and so many function evaluations is that you have nonlinear constraints. See the description of nonlinear constraint solver algorithms. For an example, see constrained minimization using ga.
Alan Weiss
MATLAB mathematical toolbox documentation

1 Comment

Alan, thanks for your answering.
I have read the description and example you offered in your answer and noticed that the GA program in the example runs for only five generations.
The final fitness value of my GA program is -952.**, smaller than -953.**, which is offered by a famous paper in my field. Even though the two values are quite close to each other. The array configuration is different apparently. I do not know what is wrong. so I thought the GA may be stuck in the local minimum. Could you please give me a hint?
I do not familiar with the details of how subproblems are computed in nonlinear constraint problems. However, in each generation, the fitness function must have been computed for many times, because f-count is much larger PopulationSize.

Sign in to comment.

More Answers (1)

Just like it says:
Optimization terminated: average change in the fitness value less than options.TolFun
and constraint violation is less than options.TolCon.
Over the last 11000 or so function calls, the fitness has barely improved - it changed less than 0.05 . And the change over more than 21000 function calls was at most 0.2. You got stuck in a minima, and ga detected that and gave up.
You can increase the stall options, but you would likely not accomplish anything by doing so unless you increased it enough to reach a migration. You would probably do better to change the mutation function to gaussian with a higher Scale to increase the randomness.
Or... you could just run ga multiple times, with different initial populations (even if random ones) and take the best result.

3 Comments

Thanks for your answer, Walter.
It seems that the gaussian mutation function is not applicable to a nonlinear constraint.
I do not understand "the last 11000 or so function calls". which function does the GA calls?
ga() calls the objective function many times during each generation. Each generation does (at least) one calculation for each member of the population. Populations are mutated between generations, but then any given population may be allowed to run for a number of iterations.
In your table,
Generation f-count f(x) constraint Generations
1 10600 -17688.4 0 0
2 21000 -17722.4 0 0
the "f-count" is the count of the number of times the objective function has been called (cumulative), and f(x) is the best objective function value out of the entire population. You can see from the table that the first generation called the objective function 10600 times, and that by the end of the second generation, the objective function had been called 21000 times. My guess is that your population size is about 10000.
Thanks for your explanations, Walter.
I am trying to increase the mutation probability. Hoping this can make the algorithm don't get stuck in the local minimum.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!