Stop fmincon and continue routine.

21 次查看(过去 30 天)
Carlos
Carlos 2014-7-10
编辑: Matt J 2014-7-10
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.

回答(1 个)

Matt J
Matt J 2014-7-10
编辑:Matt J 2014-7-10
FMINCON has an optimoption called 'OutputFcn', which lets you terminate the optimization according to your own criteria.

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by