Call GA in a loop to customize stop criteria
Show older comments
Hi:
I'm trying to run a GA optimization and I want to stop the GA when a mean fitness for the last population is met.
I don't see how to use such a custom stop criteria, so I'm thinking I could do this:
1. Generate a first random population
while stopFuncCriteria is FALSE 2. Call GA for just 1 generation using the previous population as a start point 3. Evaluate stopFuncCriteria
end
Is this possible? Will it work the way I want?
Thank you.
Answers (1)
Alan Weiss
on 28 Nov 2012
If you want to create your own stopping criterion, I suggest you disable the existing criteria and insert your own via an output function.
opts = gaoptimset('Generations',Inf,'StallGenLimit',Inf,'TolFun',0); % disable
opts = gaoptimset(opts,'OutputFcns',@yourOutputFcnNameHere);
You have to write yourOutputFcnNameHere.m first, of course. You might want to set the Generations limit lower while you are testing your output function, and you might want to enable iterative display or a plot function so you can keep track of progress.
Note that the way to stop an optimization in the output function is to set state.StopFlag to a nonempty string.
Alan Weiss
MATLAB mathematical toolbox documentation
Categories
Find more on Problem-Based Optimization Setup in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!