Revised Simplex Method Solution
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello,
I'm trying to run a quick solver to find a solution to the following problem:
Maximise: z = 7x1 + 2x2 + 3x3 + x4 + x5 + x6
Subject to constraints: 2x1 + 7x2 + x3 + x6 = 30
5x1 + 8x2 + 2x4 <=20
x1 + x2 + x6 =>12
x1 + x3 + x5 + x6 <= 41
I currently have:
A = [2 7 1 0 0 1,
5 8 0 2 0 0,
1 1 0 0 0 1,
1 1 0 0 0 1]
b = [30 20 12 41]
f = [7 2 3 1 1 1]
I've been trying to use the function
linprog(f,A,b,.....
But am struggling to work out how to input the inequalities into the linprog.
Any advice?
Thanks!
댓글 수: 0
답변 (1개)
John D'Errico
2018년 12월 3일
편집: John D'Errico
2018년 12월 3일
I would say to read the docs for linprog, where this will have been explained in some depth. But perhaps it may be confusing still.
From the help for linprog, we see:
X = linprog(f,A,b) attempts to solve the linear programming problem:
min f'*x subject to: A*x <= b
x
X = linprog(f,A,b,Aeq,beq) solves the problem above while additionally
satisfying the equality constraints Aeq*x = beq. (Set A=[] and B=[] if
no inequalities exist.)
You wrote A and b as:
A = [2 7 1 0 0 1,
5 8 0 2 0 0,
1 1 0 0 0 1,
1 1 0 0 0 1]
b = [30 20 12 41]
So you made a good start. (The only reason I am answering your question.)
You actually have both EQUALITY and INEQUALITY constraints to supply here. And worse? They varied the direction of the inequalities. How nasty of them.
So, you have ONE equality constraint. Therefore Aeq and beq will have ONE row. Create those matrices separately.
As far as the inequalities go, you were given:
5x1 + 8x2 + 2x4 <=20
x1 + x2 + x6 =>12
x1 + x3 + x5 + x6 <= 41
But is that what you want? Or, do you need to have all the inequalities as <= inequalities? So multiply by -1 for the middle one. What does that do?
5x1 + 8x2 + 2x4 <= 20
-x1 + -x2 + -x6 <= -12
x1 + x3 + x5 + x6 <= 41
That second inequality will now have -1s in there.
I have confidence you can do the rest now.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File 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!