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
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?
Scott
Scott 2022-8-5
They were in the example code provided by the lecturer. If I delete them the error code changes to
Error using linprog
LINPROG requires the following inputs to be of data type double: 'beq'.
Error in ProfitMax (line 7)
linprog(f,A,ub,lb,options)

请先登录,再进行评论。

采纳的回答

Walter Roberson
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
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 CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by