Solving a linear programming problem uising linprog
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Sergio
am 23 Mai 2024
Kommentiert: Rena Berman
am 10 Jul. 2024
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)
.
LINPROG requires the following inputs to be of data type double: 'LB'"
How do I prepare the linear inequalities correctly?
With Thanks
4 Kommentare
Akzeptierte Antwort
Torsten
am 23 Mai 2024
Bearbeitet: Torsten
am 23 Mai 2024
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)
Weitere Antworten (1)
Ayush Modi
am 23 Mai 2024
Bearbeitet: Ayush Modi
am 23 Mai 2024
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:
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!