simple linear programming problem

조회 수: 3 (최근 30일)
Ricardo Machado
Ricardo Machado 2019년 9월 20일
댓글: Steven Lord 2019년 9월 20일
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?

채택된 답변

Fabio Freschi
Fabio Freschi 2019년 9월 20일
% 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
Steven Lord
Steven Lord 2019년 9월 20일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Linear Programming and Mixed-Integer Linear Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by