Parallel GA is Ignoring Time Limit?

4 views (last 30 days)
When running a vectorized GA
options = gaoptimset('Vectorized', 'off', 'UseParallel', 'Always', 'TimeLimit', 300);
it will run indefinitely (left it running for more than two hours, and it still hadn't stopped or found an optimal solution.
But when I change it to
options = gaoptimset('Vectorized', 'on', 'TimeLimit', 300);
It runs just fine and stops after 5 minutes. Before running the parallel version, I run 'matlabpool 4'. Does the parallelization usually negate the time limit, or does someone have any clue why it would do so?

Accepted Answer

Alan Weiss
Alan Weiss on 22 Mar 2013
Thanks for reporting this behavior. I believe I understand what is happening, and will consider either making a change in the documentation or in the GA parallel behavior.
As documented, GA uses cputime to measure time for the purpose of stopping. When you run in parallel, the host CPU sends jobs to the workers, and spends essentially no CPU time while it waits for the results. When the results come back, it speedily computes a new population, then sends the jobs out to the workers again. So cputime does not advance much at all in each iteration, but wall clock time does.
So the parallel behavior of the TimeLimit option with GA is currently pretty useless.
If you have a lot of gumption, you can try editing the private GA isItTimeToStop function to use tic/toc instead of cputime. Or you can use an output function that stops GA after a period of time; this is probably much simpler and less error-prone.
You can also estimate how long each iteration takes, and set an iteration limit instead of a time limit.
Sorry about this behavior. We are working on either changing it, or documenting it so it won't surprise people.
Alan Weiss
MATLAB mathematical toolbox documentation

More Answers (0)

Categories

Find more on Performance and Memory 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!