How to ignore constraint that cannot be satisfied with fmincon?
5 views (last 30 days)
Show older comments
Hi All,
I am running an iteration in which I minimize a function with fmincon. In some cases the function cannot be minimzed because the nonlinear constraint can never be satisfied.
This is fine for my problem, but Matlab obviously doesn't know and, when the constraint is not satisfied at the initial guess, I get this error: (at least that's the reason why I think this happens, I am not 100% sure, help is welcome)
??? Error using ==> svd
Input to SVD must not contain NaN or Inf.
Error in ==> pinv at 29
[U,S,V] = svd(A,0);
Error in ==> qpsub at 461
projSD = pinv(projH)*(-Zgf);
Error in ==> nlconst at 695
[SD,lambda,exitflagqp,outputqp,howqp,ACTIND] ...
Error in ==> fmincon at 774
[X,FVAL,LAMBDA,EXITFLAG,OUTPUT,GRAD,HESSIAN]=...
My question is: Is there anyway to tell Matlab that's fine, assign some values to some variable to keep note of what's happened and go on with the iteration?
I hope I was clear, tell me if not, and thanks a lot to all in advance,
Sergio
1 Comment
Answers (2)
Sean de Wolski
on 8 Nov 2012
You could always put a try/catch around it but I would recommend spending a little time trying to figure out what is causing it.
0 Comments
Sergio
on 9 Nov 2012
2 Comments
Lauren Cook
on 15 Nov 2018
Edited: Lauren Cook
on 15 Nov 2018
Thanks for your answer. I think this is happening in my case as well. How did you constrain fmincon to avoid this?
Thanks for your help. In case it is helpful, my code is below.
paramEsts = [0.2520,0.0860,0.2576]
opts = optimset('Algorithm','active-set', 'Display','notify', 'MaxFunEvals',1000, ... %options
'RelLineSrchBnd',.1, 'RelLineSrchBndDuration',Inf);
CIobjfun = @(params) gevinv(1-1./n,params(1),params(2),params(3)); %CI objective funtion
CIconfun = @(params) deal(gevlike(params,y) - nllCritVal, []); %CI constraint function
[params,RnLower,flag,output] = ...
fmincon(CIobjfun,paramEsts,[],[],[],[],[],[],CIconfun,opts); %Perform constrained optimization
See Also
Categories
Find more on Surrogate Optimization in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!