How to ignore constraint that cannot be satisfied with fmincon?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
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.
Respuestas (2)
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.
0 comentarios
Sergio
el 9 de Nov. de 2012
2 comentarios
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
Ver también
Categorías
Más información sobre Surrogate Optimization en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!