Stop fmincon and continue routine.

10 views (last 30 days)
Carlos
Carlos on 10 Jul 2014
Edited: Matt J on 10 Jul 2014
Hello. Thanks in advance for your help.
I am solving certain problem by using a genetic algorithm, after 'x' iterations i try to improve some chromosomes by calling a fmincon function, using a SQP solver. The problem is that sometimes the SQP gets stuck and i do not know the reason (i am guessing that it can be a problem while computing the hessian or something like that, when i press ctrl -c matlab always says that the operation has been terminated In fmincon (line 910) [X,FVAL,EXITFLAG,OUTPUT,LAMBDA,GRAD,HESSIAN] = sqpLineSearch(funfcn,X,full(A),full(B),full(Aeq),full(Beq), ...).
Ok, what i want to di is to stop the search after some time; but i do want the algorithm to continue with the next chromosome (something like break in a for loop or a return in a 'while'), i.e, i do not want to stop and lose the results of the whole simulations (Genetic Algorithm and some SQP's).
I tried 'return' and it still gets stuck, 'break' is not possible outside a for, when i use a timer and put an error message, the simulation stops and i lose the simulations results.
Any help will be appreciated. Thanks.

Answers (1)

Matt J
Matt J on 10 Jul 2014
Edited: Matt J on 10 Jul 2014
FMINCON has an optimoption called 'OutputFcn', which lets you terminate the optimization according to your own criteria.

Products

Community Treasure Hunt

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

Start Hunting!