Trouble with my homework - Getting an error in my linear programming code requiring a double.

2 vues (au cours des 30 derniers jours)
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 commentaires
Image Analyst
Image Analyst le 5 Août 2022
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 le 5 Août 2022
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)

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 5 Août 2022
linprog((f,A,ub,[],[],lb,options)
You missed passing ub in. Your options are in the ub slot.
  1 commentaire
Walter Roberson
Walter Roberson le 5 Août 2022
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

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by