fmincon output is converging to infeasible point

1 visualización (últimos 30 días)
Harshvardhan Tandon
Harshvardhan Tandon el 29 de Jul. de 2020
Comentada: Alan Weiss el 4 de Ag. de 2020
I am getting an output that is correctly following lower bound and upper bound but is not satisfying the non-linear constraint. Those values are not useful for me at all. Do let me know if you require the entire code.
m = 20
lb = zeros(m,2);
ub = ones(m,2);
Y = 0.5.*ub;
[xopt,fval] = fmincon(@getCost,Y,[],[],[],[],lb,ub,@nlcon)
function [x,n,N,S] = getCost(Y)
..............
.........
end
%Constraint function
function [c, ceq] = nlcon(Y)
[~,~,c,~] = getCost(Y);
[~,~,~,ceq] = getCost(Y);
c = ceq;
end

Respuestas (1)

Alan Weiss
Alan Weiss el 29 de Jul. de 2020
While I don't understand your listed code at all, perhaps you will be able to solve your problem using some ideas from the documentaton on what to do when the solver converges to an infeasible point.
Alan Weiss
MATLAB mathematical toolbox documentation
  2 comentarios
Harshvardhan Tandon
Harshvardhan Tandon el 4 de Ag. de 2020
I did try what you recommended but fmincon was still converging to an infeasible point. My program is quite complex to be solved easily. I am trying to use different/ or modify the non-linear constraints and get convergence to a feasible point.
%Constraint function
function [c, ceq] = nlcon(Y)
[~,~,c,~] = getCost(Y);
[~,~,~,ceq] = getCost(Y);
c = ceq;
end
%%%I made it to this%%%
%Constraint function
function [c, ceq] = nlcon(Y)
[~,~,c,~] = getCost(Y);
[~,~,~,ceq] = getCost(Y);
c == ceq;
end
If you could give an idea of how fmincon reaches its value or how it reacts to when i put a '==' operator. That would be helpful.
Alan Weiss
Alan Weiss el 4 de Ag. de 2020
As I said, I don't understand your code at all, so I don't know what you are trying to do or how to advise you. In particular, I don't know what you are attempting to do with the 'c = ceq' or 'c == ceq' calls. To me, they are equally nonsensical, but I'm sure that you have a reason for including them. I would have simply given
function [c, ceq] = nlcon(Y)
[~,~,c,ceq] = getCost(Y);
end
but I don't know what any of these lines of code mean.
I suggest that you try using the debugger to see what MATLAB is doing.
Alan Weiss
MATLAB mathematical toolbox documentation

Iniciar sesión para comentar.

Categorías

Más información sobre Solver Outputs and Iterative Display en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by