Why my 20 variables nonlinear constraint Genetic Algorithm runs for only 5~6 generations?
Show older comments
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
summyia qamar
on 7 Jan 2017
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.
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Mar 2016
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
The Pirate
on 30 Mar 2016
Walter Roberson
on 30 Mar 2016
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.
The Pirate
on 30 Mar 2016
Categories
Find more on Choose a Solver in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!