No feasible solution in optimisation in linprog

1 回表示 (過去 30 日間)
Jackie
Jackie 2023 年 2 月 11 日
コメント済み: Jackie 2023 年 2 月 11 日
My code:
f= [89;82;82;29;76];
A1= [0 0 2 1 0
2 11 0 0 1
60 60 0 0 8
2 2 0 0 50
15 9 0 0 8
0 0 20 14 9
4 0 60 14 0];
A= [A1;-A1];
AEQ= [1 1 1 1 1];
b= [100;140;120;130;140;150;60; -10; -100;-12;-13;-80;-13;-45];
alpha = 19:0.1:22;
advertisement=zeros(length(alpha),1);
obj_values = [];
x_values = [];
for i = 1:length(alpha)
current_limit = alpha(i);
[x, obj, exitflag, output] = linprog(f, A, b, AEQ, current_limit, [],[]);
advertisement(i) = current_limit;
x_values = [x_values,x];
if exitflag == 1
obj_values = vertcat(obj_values, obj);
else
obj_values = vertcat(obj_values, NaN);
end
end
Hello, I'm not too sure where went wrong but it does not seems to produce any feasible solutions with regards to the problem that I have coded and there are no errors with the code. Would love if anyone could provide any advices.

採用された回答

Matt J
Matt J 2023 年 2 月 11 日
編集済み: Matt J 2023 年 2 月 11 日
Your problem is infeasible because of the input problem data you provided, not because of coding errors. In particular, in Market Group 3, it is clear that you must allocate less than 3 to TVL and TVP in order to stay below the Saturation Level of 120. However, if TVP abd TVL are <3, there is no way for Market Group 2 to reach its Minimum Exposures of 100.
  2 件のコメント
Matt J
Matt J 2023 年 2 月 11 日
If the optimization variables x(i) represent monetary expenditures, I'm assuming there should be non-negativity bounds on them as well, unless there are somehow ways to make negative expenditures in this scenario,
[x, obj, exitflag, output] = linprog(f, A, b, AEQ, current_limit, zeros(size(f)),[]);
Jackie
Jackie 2023 年 2 月 11 日
Thank you for the clarification! I'll check back with my tutor to see how it goes with regards to your comment!

サインインしてコメントする。

その他の回答 (2 件)

Alan Stevens
Alan Stevens 2023 年 2 月 11 日
I don't know if this will fix your problem, but I think the first number in the second row of A1 should be 8 not 2.
  1 件のコメント
Jackie
Jackie 2023 年 2 月 11 日
Hello, thank you for spotting my mistake! Unfortunately, there's still no feasible solutions.

サインインしてコメントする。


John D'Errico
John D'Errico 2023 年 2 月 11 日
編集済み: John D'Errico 2023 年 2 月 11 日
I posted a question recently to help explain some of the reasons when linprog fails. You should read my first answer, as it discusses infeasibility by linprog.
  1 件のコメント
Jackie
Jackie 2023 年 2 月 11 日
Thank you for this information!

サインインしてコメントする。

コミュニティ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by