fmincon output is converging to infeasible point

조회 수: 1 (최근 30일)
Harshvardhan Tandon
Harshvardhan Tandon 2020년 7월 29일
댓글: Alan Weiss 2020년 8월 4일
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

답변 (1개)

Alan Weiss
Alan Weiss 2020년 7월 29일
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
Harshvardhan Tandon
Harshvardhan Tandon 2020년 8월 4일
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 2020년 8월 4일
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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Solver Outputs and Iterative Display에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by