Trouble with my homework - Getting an error in my linear programming code requiring a double.
2 ビュー (過去 30 日間)
古いコメントを表示
options=optimoptions(@linprog,'Algorithm','dual-simplex');
f=[110;220;250;140];
A=[2/3,1,5/8,5/6;0,1,6/5,3/4;0,1,1/2,0;0,0,0,1];
ub=[10000;150000;8000;7000];
lb=zeros(4,1);
[x,fval,exitflag,output,lambda] = ...
linprog((f,A,ub,[],[],lb,options)
Error using linprog
LINPROG requires the following inputs to be of data type double: 'UB'.
Error in ProfitMax (line 7)
linprog(f,A,ub,[],[],lb,options)
running the following to maximise profits
110x1 + 220x2 + 250x3 +140x4
on the following
2/3x1 + 1x2 + 5/8x3 + 5/6x4 <= 10000
0x1 + 1x2 + 6/5x3 + 3/4x4 <= 15000
0x1 + 1x2 + 1/2x3 + 0x4 <= 8000
0x1 + 0x2 + 0x3 + 1x4 <= 7000
And should I be using dual simplex or interior point - why does this matter?
2 件のコメント
Image Analyst
2022 年 8 月 5 日
It looks like everything is a double except for the nulls. What are those supposed to be? Is it okay if they're null?
採用された回答
Walter Roberson
2022 年 8 月 5 日
linprog((f,A,ub,[],[],lb,options)
You missed passing ub in. Your options are in the ub slot.
1 件のコメント
Walter Roberson
2022 年 8 月 5 日
Note that you cannot pass values in any order you like. MATLAB does not look at the names of the variables you pass in to decide what function the parameter should have: MATLAB requires a very specific order:
f_Matrix, Linear_Inequality_A, Linear_Inequality_b, Linear_Equality_A, Linear_Equality_b, Lower_Bound, UpperBound, Initial_Guess, Options
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Discrete Math についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!