How can I terminate the ga (genetic aclgorithm) optimizer based on elapsed cpu time?

1 view (last 30 days)
The ga optimizer (genetic algorithm) can be given various stopping criteria: number of (stalled) iterations, wall clock (stalled) time. However, on a computer where other processes are also taking cpu time, the wall clock is not a dependable measure of elapsed computation time. This makes some computations hard to reproduce. I would assume that it in principle the cpu time of the Matlab process is a better measure in that case.
So, Is it possible to use elapsed cpu time as a stopping criterion for the ga optimizer? I assumed that one would be able to define one's own stopping criteria, but from the documentation it is not clear to me which option I should use, or whether my assumption is correct.

Accepted Answer

Alan Weiss
Alan Weiss on 4 Dec 2017
Edited: Alan Weiss on 4 Dec 2017
You can define you own stopping criteria by using an output function. Be careful, using cputime can give you strange results when computing in parallel. You will see in that linked discussion that ga used to use cputime for monitoring the time spent in an optimization, but this was changed in R2015b to use tic/toc because of the oddities when computing in parallel.
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!