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 个评论
Matt J
Matt J 2012-11-8
编辑:Matt J 2012-11-8
No, that doesn't explain the error you're seeing. Even if a constraint can never be satisfied, fmincon should still run until it decides that a solution can't be found, and then terminate gracefully. You should probably show more of your code.

请先登录,再进行评论。

回答(2 个)

Sean de Wolski
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.

Sergio
Sergio 2012-11-9
Thank you all for the help.
For future reference, maybe this is helpful: the problem was due to the fact that the constraint function could grow without bounds, so matlab was having to deal with Inf's. I imposed some bounds to fmincon and that seems to have solved it.
Thank you all again!
  2 个评论
Lauren Cook
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
Sergio
Sergio 2018-11-21
Hi,
A long time has passed now, but I think what I did was setting bounds in fmincon, i.e.:
X = fmincon(FUN,X0,A,B,Aeq,Beq,LB,UB)
and assign some values to LB and UB.
Good luck.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Surrogate Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by