How to ignore constraint that cannot be satisfied with fmincon?
5 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(2 个)
Sean de Wolski
2012-11-8
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 个评论
Sergio
2012-11-9
2 个评论
Lauren Cook
2018-11-15
编辑:Lauren Cook
2018-11-15
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
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surrogate Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!