フィルターのクリア

fmincon output is converging to infeasible point

2 ビュー (過去 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 Center および File ExchangeSolver 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