Options for Genetic Algorithm don't work

Hello. I need to set limited computation time for my GA optimization. I used both gaoptimset and optimset, but they don't work. It's not terminated when time is up. Also tried optimoptions, but got an error:
Invalid solver specified. Provide a solver name or handle (such as 'fmincon' or @fminunc). Type DOC OPTIMOPTIONS for a list of solvers.
My code:
options = gaoptimset('TimeLimit',30);
%options = optimset('MaxTime',30);
%options = optimoptions('MaxTime',30);
[x,fval] = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,options)
What's wrong? (MATLAB R2014b)

2 commentaires

jianli chen
jianli chen le 25 Fév 2019
Hi Vladimir,I encounter the same problem when using GA optimization in Matlab. Has you solved this problem? Thanks for your help.
Walter Roberson
Walter Roberson le 25 Fév 2019
jianli chen: which MATLAB release are you using, and how do you create the options?

Connectez-vous pour commenter.

Réponses (1)

Alan Weiss
Alan Weiss le 14 Avr 2017

1 vote

For R2014b use gaoptimset. For R2014b, use the correct option names, as many option names changed in R2016a. In particular, for R2014b, the maximum time is specified by the MaxTime option, not the TimeLimit option.
Alan Weiss
MATLAB mathematical toolbox documentation

4 commentaires

Vladimir Berezkin
Vladimir Berezkin le 14 Avr 2017
MaxTime option doesn't work for gaoptimset, it returns en error: Unrecognized parameter name 'MaxTime'. With TimeLimit it's no error, but the program is not terminated.
Alan Weiss
Alan Weiss le 19 Avr 2017
Sorry, I got it exactly backwards. TimeLimit is indeed the legacy name, the appropriate one for you to use.
You do not show that you are using parallel computing in your options. There was a bug that caused TimeLimit not to be honored in parallel in the way that you would expect. This was fixed in R2015b. So, if you are using parallel computing, then adjust your call as suggested in one of the links.
Alan Weiss
MATLAB mathematical toolbox documentation
Vladimir Berezkin
Vladimir Berezkin le 21 Avr 2017
Modifié(e) : Vladimir Berezkin le 22 Avr 2017
Thank you for your reply. I installed R2016b, but it still doesn't work. Actually, I tried another termination criteria such as maximum number of generations, and it also doesn't help. A feature of my code is that I use external simulation program connected to MATLAB via COM interface. So, my fitness function just receives a set of input variables, sends it to the simulation program and gets the result. All calculations are carried out in the external software, not in MATLAB. I suppose this is the reason of my problem. But is it possible to do smth about that?
Alan Weiss
Alan Weiss le 24 Avr 2017
Sorry, I have never heard of this problem before. Perhaps you should contact technical support.
Alan Weiss
MATLAB mathematical toolbox documentation

Connectez-vous pour commenter.

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by