Trouble with my homework - Getting an error in my linear programming code requiring a double.
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Scott
il 5 Ago 2022
Commentato: Walter Roberson
il 5 Ago 2022
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 Commenti
Image Analyst
il 5 Ago 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?
Risposta accettata
Walter Roberson
il 5 Ago 2022
linprog((f,A,ub,[],[],lb,options)
You missed passing ub in. Your options are in the ub slot.
1 Commento
Walter Roberson
il 5 Ago 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
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!