Linear Programming (LP) and the Simplex Method

Linear Programming
min cT x
min cT x
x
x
Linear Programming (LP)
and the Simplex Method
s.t. Ax = b
x
0
s.t. Ax  b
max cT x
x
s.t. Ax  b
Examples:
- diet problem
- allocation problem
Michal Kvasnica
- separation & classification
- distribution problem
- …
LP: Graphical Interpretation
max 4x1 + 6x2
s.t.
x1 + x2  11
x1 + x2  27
2x2 + 5x2  90
x 1 , x2
0
George B. Dantzig
(1914 - 2005)
max cT x
x
s.t. Ax = b
x
0
Linear Programming
Conversion between Standard Forms
max c̃T z
min cT x
z
x
s.t. Ãz = b̃
z 0
s.t. Ax  b
1
Convert inequalities to equalities:
Ax  b
2
Ax + Is = b, s
x
) A(x+
min cT x
x
s.t. Ax  b
max
x+ ,x ,s
⇥
⇥
s.t. A
x
+
cT
0, x+
x ) + Is = b, s
x ) ) max
cT (x+
Conversion to the Standard Form
cT
A
0, x
2 +3
⇤ x
0 4x 5
s
2 +3
⇤ x
I 4x 5 = b
s
0, s
0, x
Convert minimization to maximization
min cT x ) min cT (x+
Conversion between Standard Forms
0
Convert positive/negative values:
x = x+
2
)
max 4x1 + 6x2
s.t.
x1 + x2  11
x1 + x2  27
2x2 + 5x2  90
x 1 , x2
0
0
Eliminate inequalities by introducing slack variables:
max 4x1 + 6x2
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
0
x )
0
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
1
1
0
1
0
27
1
1
0
1
0
27
2
5
0
0
1
90
2
5
0
0
1
90
-4
-6
0
0
0
0
-4
-6
0
0
0
0
Classification of variables:
Feasible solution
- basic variables (only one “1” entry in each column, x3, x4, x5)
- free variables = 0 (x1=0, x2=0)
- nonbasic (free) variables (x1, x2)
- basic variables = RHS of constraints (x3=11, x4=27, x5=90)
- objective function: 0
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
1
1
0
1
0
27
1
1
0
1
0
27
2
5
0
0
1
90
2
5
0
0
1
90
-4
-6
0
0
0
0
-4
-6
0
0
0
0
Change of which variable influences the objective function the most?
Which constraint will be violated first by increasing x2?
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
1
1
0
1
0
27
1
1
0
1
0
27
2
5
0
0
1
90
2
5
0
0
1
90
-4
-6
0
0
0
0
-4
-6
0
0
0
0
Pivoting = elementary row operations until:
-first row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x2
- we reach a “one” coefficient by x2
- remaining rows in the x2 column are zeros
- remaining rows in the x2 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
2
0
-1
1
0
16
2
0
-1
1
0
16
2
5
0
0
1
90
2
5
0
0
1
90
-4
-6
0
0
0
0
-4
-6
0
0
0
0
Pivoting = elementary row operations until:
-first row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x2
- we reach a “one” coefficient by x2
- remaining rows in the x2 column are zeros
- remaining rows in the x2 column are zeros
-5x first row
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
2
0
-1
1
0
16
2
0
-1
1
0
16
7
0
-5
0
1
35
7
0
-5
0
1
35
-4
-6
0
0
0
0
-4
-6
0
0
0
0
-5x first row
Pivoting = elementary row operations until:
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x2
- we reach a “one” coefficient by x2
- remaining rows in the x2 column are zeros
- remaining rows in the x2 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
2
0
-1
1
0
16
2
0
-1
1
0
16
7
0
-5
0
1
35
7
0
-5
0
1
35
-10
0
6
0
0
66
-10
0
6
0
0
66
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x2
- remaining rows in the x2 column are zeros
+6x first row
Classification of variables:
- basic variables (only one “1” entry in each column, x2, x4, x5)
- nonbasic (free) variables (x1, x3)
+6x first row
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
2
0
-1
1
0
16
2
0
-1
1
0
16
7
0
-5
0
1
35
7
0
-5
0
1
35
-10
0
6
0
0
66
-10
0
6
0
0
66
Feasible solution:
Keep pivoting if the last row contains negative values
- free variables = 0 (x1=0, x3=0)
- basic variables = RHS of constraints (x2=11, x4=16, x5=35)
- objective function: 66
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
2
0
-1
1
0
16
2
0
-1
1
0
16
7
0
-5
0
1
35
7
0
-5
0
1
35
-10
0
6
0
0
66
-10
0
6
0
0
66
Change of which variable influences the objective function the most?
Which constraint will be violated first by increasing x1?
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
-1
1
1
0
0
11
-1
1
1
0
0
11
2
0
-1
1
0
16
2
0
-1
1
0
16
7
0
-5
0
1
35
7
0
-5
0
1
35
-10
0
6
0
0
66
-10
0
6
0
0
66
Pivoting = elementary row operations until:
+1/7x third row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x1
- we reach a “one” coefficient by x1
- remaining rows in the x1 column are zeros
- remaining rows in the x1 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
x
x
x
x
x
b
0
1
2/7
0
1/7
16
2
0
-1
1
0
7
0
-5
0
-10
0
6
0
Pivoting = elementary row operations until:
0
x
x
x
x
x
b
0
1
2/7
0
1/7
16
16
2
0
-1
1
0
16
1
35
7
0
-5
0
1
35
0
66
-10
0
6
0
0
66
+1/7x third row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x1
- we reach a “one” coefficient by x1
- remaining rows in the x1 column are zeros
- remaining rows in the x1 column are zeros
-2/7x third row
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
2/7
0
1/7
16
0
1
2/7
0
1/7
16
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
7
0
-5
0
1
35
7
0
-5
0
1
35
-10
0
6
0
0
66
-10
0
6
0
0
66
-2/7x third row
Pivoting = elementary row operations until:
+10/7x third row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x1
- we reach a “one” coefficient by x1
- remaining rows in the x1 column are zeros
- remaining rows in the x1 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
2/7
0
1/7
16
0
1
2/7
0
1/7
16
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
7
0
-5
0
1
35
7
0
-5
0
1
35
0
0
-8/7
0
10/7
116
0
0
-8/7
0
10/7
116
Pivoting = elementary row operations until:
+10/7x third row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x1
- we reach a “one” coefficient by x1
- remaining rows in the x1 column are zeros
- remaining rows in the x1 column are zeros
/7
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
2/7
0
1/7
16
0
1
2/7
0
1/7
16
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
1
0
-5/7
0
1/7
5
1
0
-5/7
0
1/7
5
0
0
-8/7
0
10/7
116
0
0
-8/7
0
10/7
116
/7
Classification of variables:
Pivoting = elementary row operations until:
- basic variables (x1, x2, x4)
- we reach a “one” coefficient by x1
- free variables (x3, x5)
- remaining rows in the x1 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
2/7
0
1/7
16
0
1
2/7
0
1/7
16
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
1
0
-5/7
0
1/7
5
1
0
-5/7
0
1/7
5
0
0
-8/7
0
10/7
116
0
0
-8/7
0
10/7
116
Feasible solution:
- free variables = 0 (x3=0, x5=0)
- basic variables = RHS of constraints (x1=5, x2=16, x4=6)
- objective function: 116
Keep pivoting if the last row contains negative values
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
2/7
0
1/7
16
0
1
2/7
0
1/7
16
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
1
0
-5/7
0
1/7
5
1
0
-5/7
0
1/7
5
0
0
-8/7
0
10/7
116
0
0
-8/7
0
10/7
116
Change of which variable influences the objective function the most?
Simplex Tableau
Which constraint will be violated first by increasing x3?
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
2/7
0
1/7
16
0
1
2/7
0
1/7
16
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
1
0
-5/7
0
1/7
5
1
0
-5/7
0
1/7
5
0
0
-8/7
0
10/7
116
0
0
-8/7
0
10/7
116
Pivoting = elementary row operations until:
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x3
- we reach a “one” coefficient by x3
- remaining rows in the x3 column are zeros
- remaining rows in the x3 column are zeros
- 2/3 second row
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
x
x
x
x
x
b
0
1
0
-2/3
1/3
12
0
0
3/7
1
-2/7
1
0
-5/7
0
0
0
-8/7
0
0
x
x
x
x
x
b
0
1
0
-2/3
1/3
12
6
0
0
3/7
1
-2/7
6
1/7
5
1
0
-5/7
0
1/7
5
10/7
116
0
0
-8/7
0
10/7
116
- 2/3 second row
Pivoting = elementary row operations until:
+ 5/3 second row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x3
- we reach a “one” coefficient by x3
- remaining rows in the x3 column are zeros
- remaining rows in the x3 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
0
-2/3
1/3
12
0
1
0
-2/3
1/3
12
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
1
0
0
5/3
-1/3
15
1
0
0
5/3
-1/3
15
0
0
-8/7
0
10/7
116
0
0
-8/7
0
10/7
116
Pivoting = elementary row operations until:
+ 5/3 second row
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x3
- we reach a “one” coefficient by x3
- remaining rows in the x3 column are zeros
- remaining rows in the x3 column are zeros
+ 8/3 second row
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
0
-2/3
1/3
12
0
1
0
-2/3
1/3
12
0
0
3/7
1
-2/7
6
0
0
3/7
1
-2/7
6
1
0
0
5/3
-1/3
15
1
0
0
5/3
-1/3
15
0
0
0
8/3
2/3
132
0
0
0
8/3
2/3
132
+ 8/3 second row
Pivoting = elementary row operations until:
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x3
- we reach a “one” coefficient by x3
- remaining rows in the x3 column are zeros
- remaining rows in the x3 column are zeros
Simplex Tableau
Simplex Tableau
max 4x1 + 6x2
s.t.
max 4x1 + 6x2
x1 + x2 + x3 = 11
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
x 1 , x2 , x3 , x4 , x5
0
0
x
x
x
x
x
b
x
x
x
x
x
b
0
1
0
-2/3
1/3
12
0
1
0
-2/3
1/3
12
0
0
1
7/3
-2/3
14
0
0
1
7/3
-2/3
14
1
0
0
5/3
-1/3
15
1
0
0
5/3
-1/3
15
0
0
0
8/3
2/3
132
0
0
0
8/3
2/3
132
Pivoting = elementary row operations until:
- we reach a “one” coefficient by x3
- remaining rows in the x3 column are zeros
x 7/3
Feasible solution:
- free variables = 0 (x4=0, x5=0)
- basic variables = RHS of constraints (x1=15, x2=12, x3=14)
- objective function: 132
x 7/3
Simplex Tableau
Graphical Interpretation
max 4x1 + 6x2
s.t.
x1 + x2 + x3 = 11
x1 + x2 + x4 = 27
2x1 + 5x2 + x5 = 90
x 1 , x2 , x3 , x4 , x5
0
x
x
x
x
x
b
0
1
0
-2/3
1/3
12
0
0
1
7/3
-2/3
14
1
0
0
5/3
-1/3
15
0
0
0
8/3
2/3
132
Keep pivoting if the last row contains negative values.
If the last row contains only positive values, we have found the
optimum!
Simplex Method
linprog
max c1 x1 + c2 x2 + · · · + cn xn
s.t. a11 x1 + a12 x2 + · · · + a1n xn = b1
a21 x1 + a22 x2 + · · · + a2n xn = b2
..
.
am1 x1 + am2 x2 + · · · + amn xn = b2
x 1 , x2 , . . . , x n
0
linprog is a solver for linear programming
- included in the Optimization Toolboxu
- implements 3 methods (one of them is the simplex method)
- input format:
min cT x
x
Algorithm:
1. create the simplex tableau
2. optimal solution?(if the last row has all entries positive)
3. select the pivoting variable
- column with the smallest nagative value in the last row
- row with the smallest non-negative ratio bi/aij
4. pivoting using elementary row operations
5. repeat from step 2
s.t. Ax  b
minimization of a linear objective function
inequality constraints
Aeq x = beq
equality constraints
xlb  x  xub
lower/upper bounds on optimization variables
linprog
Tvar LP
min cT x
s.t. Ax  b
linprog
Syntax
xopt=linprog(c, A, b)
Tvar LP
min cT x
s.t. Ax  b
max cT x
s.t. Ax  b
linprog
Tvar LP
min cT x
s.t. Ax  b
max cT x
s.t. Ax  b
Aeq x = beq
xopt=linprog(c, A, b)
xopt=linprog(-c, A, b)
linprog
Syntax
xopt=linprog(c, A, b)
xopt=linprog(-c, A, b)
min cT x
s.t. Ax  b
Syntax
Tvar LP
min cT x
s.t. Ax  b
max cT x
s.t. Ax  b
Syntax
xopt=linprog(c, A, b)
xopt=linprog(-c, A, b)
min cT x
xopt=linprog(c, A, b, Aeq, beq)
s.t. Ax  b
xopt=linprog(c, A, b, Aeq, beq)
Aeq x = beq
min cT x
s.t. Ax  b
Aeq x = beq
xlb  x  xub
xopt=linprog(c, A, b, Aeq, beq, lb, ub)
Infeasible LP
linprog
[xopt, Jopt, status] = linprog(c, A, b, Ae, be, lb, ub)
max x1 + x2
s.t.
0.5x2 
0.5x1
x1 + x2  1
Outputs:
x 1 , x2
- xopt: vector of optimal decision variables
- Jopt: value of the objective function at the optimum (scalar)
- status: status of the solution (scalar)
Status
Meaning
1
optimal solution found
0
maximal # of iterations reached
-2
problem is infeasible
-3
problem is unbounded
Unbounded LP
max 2x1 + x2
s.t.
x1
x1 + x1  1
2x2  2
x 1 , x2
0
0
1