simple linear programming problem

3 visualizaciones (últimos 30 días)
Ricardo Machado
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?

Respuesta aceptada

Fabio Freschi
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
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Programming and Mixed-Integer Linear Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by