Filter löschen
Filter löschen

fmincon output is converging to infeasible point

2 Ansichten (letzte 30 Tage)
Harshvardhan Tandon
Harshvardhan Tandon am 29 Jul. 2020
Kommentiert: Alan Weiss am 4 Aug. 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

Antworten (1)

Alan Weiss
Alan Weiss am 29 Jul. 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 Kommentare
Harshvardhan Tandon
Harshvardhan Tandon am 4 Aug. 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 am 4 Aug. 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

Melden Sie sich an, um zu kommentieren.

Produkte


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by