Genetic Algorithm never runs past 15 iterations
이전 댓글 표시
I am trying to minimize a function with non-linear constraint. Search space is complicating and large so I would expect search to take some time, but no matter what settings/options I use my search always terminates under 15 iterations. Most of the time GA comes back with an answer but it's always subpar. How can I make it search longer?
Here is example of one of my calls...
[x,fval] = ga(@demo_power_mod,4,[],[],[],[],LB,UB,@demo_constraint_mod,gaoptimset('PopulationSize',100,'Display','iter')
Here is an output...
Best max Stall
Generation f-count f(x) constraint Generations
1 5300 0.000452147 0.007359 0
2 10500 0.000480009 0.007328 0
3 15700 0.000514905 0.007293 0
4 20900 0.000565675 0.007245 0
5 26100 0.000636612 0.007183 0
6 31300 0.000758782 0.007083 0
7 36610 0.0115404 2.151e-007 0
8 41810 0.0112147 0.0001978 0
9 47010 0.0114633 2.46e-005 0
10 52210 0.0114687 1.95e-005 0
11 62310 0.0114617 2.078e-005 0
12 72410 0.0114657 1.49e-005 0
13 77610 0.0114722 1.366e-005 0
14 87710 0.0126579 0 0
15 92910 0.0115109 0 0
Optimization terminated: average change in the fitness value less than options.TolFun
and constraint violation is less than options.TolCon.
댓글 수: 1
Star Strider
2012년 9월 20일
I suggest adding to your gaoptimset call:
..., 'TolFun',1E-8, 'TolCon',1E-8)
or less to see if that improves your results. According to the gaoptimset documentation, the default for these options is 1E-6.
답변 (2개)
Sean de Wolski
2012년 9월 20일
[x,fval,exitflag] = ga(fitnessfcn,nvars,...)
What's the exitflag?
doc ga
to have exitflag explained.
댓글 수: 3
Vlad
2012년 9월 20일
Sean de Wolski
2012년 9월 20일
1 Without nonlinear constraints — Average cumulative change in value of the fitness function over StallGenLimit generations is less than TolFun, and the constraint violation is less than TolCon.
With nonlinear constraints — Magnitude of the complementarity measure (see Definitions) is less than sqrt(TolCon), the subproblem is solved using a tolerance less than TolFun, and the constraint violation is less than TolCon.
Vlad
2012년 9월 20일
Alan Weiss
2012년 9월 20일
The nonlinear constraints cause the algorithm to behave differently than you might expect. You see how high the F-counts are. There is a lot of computation happening at each iteration, and with nonlinear constraints, the stopping condition is not "weighted average change in fitness function over 50 iterations." See the nonlinear algorithm description.
And let me make my usual plea that you try using patternsearch instead of ga. You will probably find patternsearch to be faster, more reliable, and easier to tune. The only potential problem with patternsearch is that you need to give starting points. Since you have lower and upper bounds (and I assume that they are finite), you can try the following random start point:
x0 = LB + rand(size(LB)).*(UB - LB);
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!