フィルターのクリア

Using linprog but it's only returning 'Optimal solution found' with no feasible solution?

5 ビュー (過去 30 日間)
Gurneet Kaur
Gurneet Kaur 2022 年 9 月 5 日
編集済み: Matt J 2022 年 9 月 5 日
This is my first time using MATLAB and I'm so confused. This is my input:
f = [-4000 -5000];
A = [6 5;
4 6;
-6 -5;
-9 -5;
-1 0;
0 -1];
b = [500 400 -300 -200 0 0];
Aeq = [];
beq = [];
X = linprog(f,A,b,Aeq,beq)
Optimal solution found.
X = 2×1
62.5000 25.0000
As you can see, all I get in return is "Optimal solution found." Is there something I'm missing possibly? I feel like it should be easy, but like I said I've never used MATLAB.
  1 件のコメント
Bruno Luong
Bruno Luong 2022 年 9 月 5 日
You should explain why/what the result surprise you, don't let us guess.

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

回答 (1 件)

Bruno Luong
Bruno Luong 2022 年 9 月 5 日
編集済み: Bruno Luong 2022 年 9 月 5 日
It looks solution is correct to me.
Note that the Aeq = [] meaning you don"t supply equality constraint, so I need to check for inquelity constraints of the solution and the constraints are satisfied as showed here:
f = [-4000 -5000];
A = [6 5;
4 6;
-6 -5;
-9 -5;
-1 0;
0 -1];
b = [500 400 -300 -200 0 0];
Aeq = [];
beq = [];
X = linprog(f,A,b,Aeq,beq)
Optimal solution found.
X = 2×1
62.5000 25.0000
A*X-b(:)
ans = 6×1
0 0 -200.0000 -487.5000 -62.5000 -25.0000
all(A*X<=b(:))
ans = logical
1

カテゴリ

Help Center および File ExchangeGet Started with Optimization Toolbox についてさらに検索

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by