Document

Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
0 2 4 6
x
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
x + y ≤ 4
0 2 4 6
x
From now on, we restrict x,y ≥ 0
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
x + y ≤ 4
2x + y ≤ 5 0 2 4 6
Any x,y point in this area is
a solution to
above inequalities
x
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
x + y ≤ 4
2x + y ≤ 5
Maximize:
3x + 4y 0 2 4 6
x
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
1 1  x ≤ 4
2 1 y 5
Objective function:
3x + 4y
0 2 4 6
x
3 4 
y
x Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
1 1  x ≤ 4
2 1 y 5
Objective function:
3x + 4y
0 2 4 6
x
3 4 
y
x What does it mean to maximize the objective function?
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
1 1  x ≤ 4
2 1 y 5
Objective function:
3x + 4y = 8
0 2 4 6
x
3 4 
y
x What does it mean to maximize the objective function?
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
1 1  x ≤ 4
2 1 y 5
Objective function:
3x + 4y = 12
0 2 4 6
x
3 4 
y
x What does it mean to maximize the objective function?
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
1 1  x ≤ 4
2 1 y 5
Objective function:
3x + 4y = 15
0 2 4 6
x
3 4 
y
x What does it mean to maximize the objective function?
Simplex Algorithm
Linear Programming example in 2 dimensions:
0 2 4 y
1 1  x ≤ 4
2 1 y 5
Objective function:
3x + 4y = 16
0 2 4 6
x
3 4 
y
x What does it mean to maximize the objective function?
Simplex Algorithm
Step 1: Transform the instance to standard form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
Add non­negative slack variables:
x + y + s1 = 4 2x + y + s2 = 5 s1 ≥ 0; s2 ≥ 0;
Simplex Algorithm
Step 1: Transform the instance to standard form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
What do the slack variables and the = do?
x + y + s1 = 4 2x + y + s2 = 5 For any x,y s.t. x+y≤ 4, say, just add some value to
s1 and the first constraint can be satisfied. Simplex Algorithm
Step 1: Transform the instance to standard form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
Add non­negative slack variables:
x + y + s1 = 4 Rewrite the objective function:
2x + y + s2 = 5 ­3x ­4y + P = 0
s1 ≥ 0; s2 ≥ 0;
Simplex Algorithm
Step 2: Put into matrix form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
Simplex Algorithm
Step 2: Put into matrix form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
We must have an identity matrix – the “basic” feasible solution
Simplex Algorithm
Step 2: Put into matrix form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
The matrix must be “priced­out”
Simplex Algorithm
Step 2: Put into matrix form:
Ax = b, x ≥ 0 (x is a vector of variables)
Example:
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
The initial feasible solution: x, y = 0
Simplex Algorithm
0 2 4 y
This is where the initial feasible solution puts us
0 2 4 6
x
Simplex Algorithm
Step 3: Run Simplex:
Identify pivot column – most negative number
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
Simplex Algorithm
Step 3: Run Simplex:
Identify pivot row – lowest value/column ratio
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
Simplex Algorithm
Step 3: Run Simplex:
Zero the column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 0 ­1 1 0 1
1 0 4 0 1 16
Simplex Algorithm
Step 3: Run Simplex:
Zero the column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 0 ­1 1 0 1
1 0 4 0 1 16
The next feasible solution: x = 0, y = 4
Simplex Algorithm
0 2 4 y
This is where the current feasible solution puts us
0 2 4 6
x
Simplex Algorithm
Step 3: Run Simplex:
Check for most negative entry in bottom row
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 0 ­1 1 0 1
1 0 4 0 1 16
There is no negative entry – max at: 3x + 4y ­ 16 = 0
Simplex Algorithm
Tryit: What would happen if we choose another col?
Choose column with ­3 at bottom
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
Simplex Algorithm
Tryit: What would happen if we choose another col?
nd
Now the 2 row is the pivot row
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
Simplex Algorithm
Tryit: What would happen if we choose another col?
Pivot becomes 1
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 1/2 0 1/2 0 5/2
­3 ­4 0 0 1 0
Simplex Algorithm
Tryit: What would happen if we choose another col?
Zero out the column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1/2 1 ­1/2 0 3/2
1 1/2 0 1/2 0 5/2
0 ­5/2 0 3/2 1 15/2
Simplex Algorithm
Tryit: What would happen if we choose another col?
Zero out the column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1/2 1 ­1/2 0 3/2
1 1/2 0 1/2 0 5/2
0 ­5/2 0 3/2 1 15/2
The next feasible solution: x = 5/2, y = 0
Simplex Algorithm
0 2 4 y
This is where the current feasible solution puts us
0 2 4 6
x
The next feasible solution: x = 0, y = 4
Simplex Algorithm
Tryit: Now let’s continue as before
Choose pivot column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1/2 1 ­1/2 0 3/2
1 1/2 0 1/2 0 5/2
0 ­5/2 0 3/2 1 15/2
Simplex Algorithm
Tryit: Now let’s continue as before
Choose pivot row
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1/2 1 ­1/2 0 3/2
1 1/2 0 1/2 0 5/2
0 ­5/2 0 3/2 1 15/2
Simplex Algorithm
Tryit: Now let’s continue as before
Pivot becomes 1
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1 2 ­1 0 3
1 1/2 0 1/2 0 5/2
0 ­5/2 0 3/2 1 15/2
Simplex Algorithm
Tryit: Now let’s continue as before
Zero the column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1 2 ­1 0 3
1 0 ­1 1 0 1
0 0 5 ­1 1 15
Simplex Algorithm
Tryit: Now let’s continue as before
Zero the column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1 2 ­1 0 3
1 0 ­1 1 0 1
0 0 5 ­1 1 15
The next feasible solution: x = 1, y = 3
Simplex Algorithm
0 2 4 y
This is where the current feasible solution puts us
0 2 4 6
x
The next feasible solution: x = 1, y = 3
Simplex Algorithm
Tryit: Now let’s continue as before
Choose the pivot column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1 2 ­1 0 3
1 0 ­1 1 0 1
0 0 5 ­1 1 15
Simplex Algorithm
Tryit: Now let’s continue as before
Choose the pivot row
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 0 1 2 ­1 0 3
1 0 ­1 1 0 1
0 0 5 ­1 1 15
Simplex Algorithm
Tryit: Now let’s continue as before
Zero the pivot column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 0 ­1 1 0 1
1 0 4 0 1 16
Simplex Algorithm
Tryit: Now let’s continue as before
Zero the pivot column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 0 ­1 1 0 1
1 0 4 0 1 16
The next feasible solution: x = 0, y = 4
Simplex Algorithm
0 2 4 y
This is where the current feasible solution puts us
0 2 4 6
x
Simplex Algorithm
Tryit: Now let’s continue as before
Zero the pivot column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
1 0 ­1 1 0 1
1 0 4 0 1 16
Stop at this point – all bottom row entries are non­negative
Simplex Algorithm
Step 3: Run Simplex: return to the past
What happens if we choose another pivot row?
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P 1 1 1 0 0 4
2 1 0 1 0 5
­3 ­4 0 0 1 0
Simplex Algorithm
Tryit: Run Simplex: non­optimal pivot row choice
zero the pivot column
x + y ≤ 4 Obj: 3x + 4y
2x + y ≤ 5 x, y ≥ 0
x y s1 s2 P ­1 0 1 0 0 ­1
2 1 0 1 0 5
5 0 0 4 1 20
Uh oh ­ s1 is negative, hence this cannot be a feasible solution
Simplex Algorithm
This is where the assignment puts us
0 2 4 y
0 2 4 6
x