simple linear programming problem
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ricardo Machado
el 20 de Sept. de 2019
Comentada: Steven Lord
el 20 de Sept. de 2019
This is an example from my textbook
Minimize 5x-7y-4z+6t
Subject to 2x+6y+z-t <= 5
5x+3y-6z-2t <= 7
-x-3y+6z+2t <= 6
x,y,z,t > = 0
So this is my code
f = [5 -7 -4 6]
A = [2 6 1 -1
5 3 -6 -2
-1 -3 6 2]
B = [5 7 6]
x = linprog(f,A,B)
So do i have to list the linear equality constraint if all variables are greater than zero or is there something wrong with the code?
0 comentarios
Respuesta aceptada
Fabio Freschi
el 20 de Sept. de 2019
% your code
f = [5 -7 -4 6]
A = [2 6 1 -1
5 3 -6 -2
-1 -3 6 2]
B = [5 7 6]
% add lowerbound (0) and upper bound (Inf)
lb = [0 0 0 0]
ub = [Inf Inf Inf Inf]
% solve (Aeq = []; beq = [];)
x = linprog(f,A,B,[],[],lb,ub)
1 comentario
Steven Lord
el 20 de Sept. de 2019
Fabio Freschi is correct. If you look at the description of the lb and ub input arguments on the linprog documentation page you'll see it says "Set Aeq = [] and beq = [] if no equalities exist."
The "Obtain Solution and Lagrange Multipliers" example on that page demonstrates this, solving a problem with bounds (actually, just lower bounds but no upper bounds) but no equality constraints.
Más respuestas (0)
Ver también
Categorías
Más información sobre Linear Programming and Mixed-Integer Linear Programming en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!