How to ignore constraint that cannot be satisfied with fmincon?

5 visualizaciones (últimos 30 días)
Sergio
Sergio el 8 de Nov. de 2012
Comentada: Sergio el 21 de Nov. de 2018
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 comentario
Matt J
Matt J el 8 de Nov. de 2012
Editada: Matt J el 8 de Nov. de 2012
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.

Iniciar sesión para comentar.

Respuestas (2)

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

Sergio
Sergio el 9 de Nov. de 2012
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 comentarios
Lauren Cook
Lauren Cook el 15 de Nov. de 2018
Editada: Lauren Cook el 15 de Nov. de 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
Sergio
Sergio el 21 de Nov. de 2018
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.

Iniciar sesión para comentar.

Categorías

Más información sobre Surrogate Optimization en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by