Solving a linear programming problem uising linprog

I have the given linear program to solve.
To solve this I prepare the following for the constraints on each of the six variables:
A = [110 205 160 160 420 260;
4 32 13 8 4 14;
2 12 54 285 22 80];
b = [2000 55 800];
where the function to be minimized with constraints:
f = [3 24 13 9 20 19];
lb = [0,0,0,0,0,0];
ub = [4,3,2,8,2,2];
Is solved by:
options = optimoptions('linprog','Algorithm','dual-simplex');
[x,fval,exitflag,output] = linprog(f,A,b,lb,ub,options)
.
I get "Error using linprog (line 182)
LINPROG requires the following inputs to be of data type double: 'LB'"
How do I prepare the linear inequalities correctly?
With Thanks

4 件のコメント

Ayush Modi
Ayush Modi 2024 年 5 月 23 日
Try this ->
beq = [2000;55;800];
Sergio
Sergio 2024 年 5 月 23 日
@Ayush Modi I found that out, it was wrong to have beq in the code. I removed it, now it should be right, but the error is completely different now..
Sergio
Sergio 2024 年 7 月 7 日
@Torsten I acidentally edited an old question with a new question, I tried to delete it , but that didn't work!
Rena Berman
Rena Berman 2024 年 7 月 10 日

(Answers Dev) Restored edit

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

 採用された回答

Torsten
Torsten 2024 年 5 月 23 日
編集済み: Torsten 2024 年 5 月 23 日

1 投票

A = -[110 205 160 160 420 260;...
4 32 13 8 4 14;...
2 12 54 285 22 80];
b = -[2000; 55; 800];
Aeq = [];
beq = [];
where the function to be minimized with constraints:
f = [3 24 13 9 20 19];
lb = [0,0,0,0,0,0];
ub = [4,3,2,8,2,2];
Is solved by:
options = optimoptions('linprog','Algorithm','dual-simplex');
[x,fval,exitflag,output] = linprog(f,A,b,Aeq,beq,lb,ub,options)
Optimal solution found.
x = 6x1
4.0000 0 0 4.5000 2.0000 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
fval = 92.5000
exitflag = 1
output = struct with fields:
iterations: 3 algorithm: 'dual-simplex-highs' constrviolation: 0 message: 'Optimal solution found.' firstorderopt: 1.7764e-15

1 件のコメント

Sergio
Sergio 2024 年 5 月 23 日
Formidable. Thanks Torsten!

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

その他の回答 (1 件)

Ayush Modi
Ayush Modi 2024 年 5 月 23 日
編集済み: Ayush Modi 2024 年 5 月 23 日

0 投票

Hi Sergio,
The error you are getting is because of extra parameters in the function call. Here is how you can make the call to the "linprog" function with lower and upper bounds:
x = linprog(f,A,b,Aeq,beq,lb,ub,options) % Maximum 8 parameters
Refer to the following MathWorks documentation for more information on syntax of "linprog" function:

カテゴリ

製品

リリース

R2024a

タグ

質問済み:

2024 年 5 月 23 日

コメント済み:

2024 年 7 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by