CSC373 Week 6: Linear Programming
373F19 - Nisarg Shah & Karan Singh 1
Illustration Courtesy: Kevin Wayne & Denis Pankratov
Linear Programming Illustration Courtesy: Kevin Wayne & Denis - - PowerPoint PPT Presentation
CSC373 Week 6: Linear Programming Illustration Courtesy: Kevin Wayne & Denis Pankratov 373F19 - Nisarg Shah & Karan Singh 1 Recap Network flow Ford-Fulkerson algorithm Ways to make the running time polynomial
373F19 - Nisarg Shah & Karan Singh 1
Illustration Courtesy: Kevin Wayne & Denis Pankratov
373F19 - Nisarg Shah & Karan Singh 2
➢ Ford-Fulkerson algorithm ➢ Ways to make the running time polynomial ➢ Correctness using max-flow, min-cut ➢ Applications:
373F19 - Nisarg Shah & Karan Singh 3
➢ Per unit resource requirement and profit of the two items
are as given below
Example Courtesy: Kevin Wayne
373F19 - Nisarg Shah & Karan Singh 4
373F19 - Nisarg Shah & Karan Singh 5
➢ Example: 𝑔 𝑦1, 𝑦2 = 3𝑦1 − 5𝑦2 =
3 −5 𝑈 𝑦1 𝑦2
➢ For a linear function : ℝ𝑜 → ℝ and 𝑑 ∈ ℝ, 𝑦 = 𝑑 ➢ Line in the plane (or a hyperplane in ℝ𝑜) ➢ Example: 5𝑦1 + 7𝑦2 = 10
373F19 - Nisarg Shah & Karan Singh 6
373F19 - Nisarg Shah & Karan Singh 7
373F19 - Nisarg Shah & Karan Singh 8
373F19 - Nisarg Shah & Karan Singh 9
373F19 - Nisarg Shah & Karan Singh 10
373F19 - Nisarg Shah & Karan Singh 11
373F19 - Nisarg Shah & Karan Singh 12
373F19 - Nisarg Shah & Karan Singh 13
373F19 - Nisarg Shah & Karan Singh 14
➢ If 𝑦 is not a vertex, we can move towards the boundary in a direction
where the objective value does not decrease
and −𝑒 directions while remaining within the region
➢ Reach a point that is “tight” for at least one more constraint ➢ Repeat until we are at a vertex
373F19 - Nisarg Shah & Karan Singh 15
➢ There are 𝑜 variables and 𝑛 constraints
373F19 - Nisarg Shah & Karan Singh 16
➢ There are 𝑜 variables and 𝑛 constraints
373F19 - Nisarg Shah & Karan Singh 17
➢ Constraints that use ≥
➢ Constraints that use equality
➢ Objective function is a minimization
➢ Variable is unconstrained
replace every occurrence of 𝑦 with 𝑦′ − 𝑦′′, and add constraints 𝑦′ ≥ 0, 𝑦′′ ≥ 0
373F19 - Nisarg Shah & Karan Singh 18
373F19 - Nisarg Shah & Karan Singh 19
373F19 - Nisarg Shah & Karan Singh 20
373F19 - Nisarg Shah & Karan Singh 21
373F19 - Nisarg Shah & Karan Singh 22
Start at a vertex of feasible polytope Move to a neighbor vertex with better
Terminate, declare the current solution and value as optimal Is there a neighbor vertex with better
373F19 - Nisarg Shah & Karan Singh 23
➢ Convenient for implementing simplex operations ➢ We want to maximize 𝑨 in the slack form, but for now,
forget about the maximization objective
373F19 - Nisarg Shah & Karan Singh 24
373F19 - Nisarg Shah & Karan Singh 25
373F19 - Nisarg Shah & Karan Singh 26
➢ How do we find a feasible vertex? ➢ For now, assume 𝑐 ≥ 0 (each 𝑐𝑗 ≥ 0)
➢ We’ll later see what to do in the general case
373F19 - Nisarg Shah & Karan Singh 27
➢ Find a nonbasic variable with a positive coefficient
➢ See how much you can increase its value without
violating any constraints
373F19 - Nisarg Shah & Karan Singh 28
This is because the current values of 𝑦2 and 𝑦3 are 0, and we need 𝑦4, 𝑦5, 𝑦6 ≥ 0
373F19 - Nisarg Shah & Karan Singh 29
Tightest obstacle
➢ Solve the tightest obstacle for the nonbasic variable
𝑦1 = 9 − 𝑦2 4 − 𝑦3 2 − 𝑦6 4
373F19 - Nisarg Shah & Karan Singh 30
➢ The basic feasible solution (i.e. substituting 0 for all
nonbasic variables) improves from 𝑨 = 0 to 𝑨 = 27
373F19 - Nisarg Shah & Karan Singh 31
373F19 - Nisarg Shah & Karan Singh 32
373F19 - Nisarg Shah & Karan Singh 33
373F19 - Nisarg Shah & Karan Singh 34
Start at a vertex of feasible polytope Move to a neighbor vertex with better
Terminate, declare the current solution and value as optimal Is there a neighbor vertex with better
373F19 - Nisarg Shah & Karan Singh 35
Assuming 𝑐 ≥ 0, start with a basic feasible solution
Move to a neighbor vertex with better
Terminate, declare the current solution and value as optimal Is there a neighbor vertex with better
373F19 - Nisarg Shah & Karan Singh 36
Assuming 𝑐 ≥ 0, start with a basic feasible solution
Move to a neighbor vertex with better
Terminate, declare the current solution and value as optimal
Is there a leaving variable? (coefficient > 0 in 𝑨)
373F19 - Nisarg Shah & Karan Singh 37
Assuming 𝑐 ≥ 0, start with a basic feasible solution
Pivot on a leaving variable Terminate, declare the current solution and value as optimal
Is there a leaving variable? (coefficient > 0 in 𝑨)
373F19 - Nisarg Shah & Karan Singh 38
Assuming 𝑐 ≥ 0, start with a basic feasible solution
Pivot on a leaving variable Terminate, declare
Is there a leaving variable? (coefficient > 0 in 𝑨)
373F19 - Nisarg Shah & Karan Singh 39
➢ If it doesn’t appear in any constraints, or only appears in
constraints where it can go to ∞
➢ Then 𝑨 can also go to ∞, so declare that LP is unbounded
➢ Known as degeneracy, and can lead to infinite loops ➢ Can be prevented by “perturbing” 𝑐 by a small random
amount in each coordinate
➢ Or by carefully breaking ties among entering and leaving
variables, e.g., by smallest index (known as Bland’s rule)
373F19 - Nisarg Shah & Karan Singh 40
𝑀𝑄
1
Max 𝑑𝑈𝑦 s.t. 𝑏1
𝑈𝑦 ≤ 𝑐1
𝑏2
𝑈𝑦 ≤ 𝑐2
⋮ 𝑏𝑛
𝑈 𝑦 ≤ 𝑐𝑛
𝑦 ≥ 0 𝑀𝑄2 Max 𝑑𝑈𝑦 s.t. 𝑏1
𝑈𝑦 + 𝑡1 = 𝑐1
𝑏2
𝑈𝑦 + 𝑡2 = 𝑐2
⋮ 𝑏𝑛
𝑈 𝑦 + 𝑡𝑛 = 𝑐𝑛
𝑦, 𝑡 ≥ 0 𝑀𝑄3 Max 𝑑𝑈𝑦 s.t. 𝑏1
𝑈𝑦 + 𝑡1 = 𝑐1
−𝑏2
𝑈𝑦 − 𝑡2 = −𝑐2
⋮ −𝑏𝑛
𝑈 𝑦 − 𝑡𝑛 = −𝑐𝑛
𝑦, 𝑡 ≥ 0
Multiply every constraint with negative 𝑐𝑗 by − 1 so RHS is now positive
373F19 - Nisarg Shah & Karan Singh 41
𝑀𝑄3 Max 𝑑𝑈𝑦 s.t. 𝑏1
𝑈𝑦 + 𝑡1 = 𝑐1
−𝑏2
𝑈𝑦 − 𝑡2 = −𝑐2
⋮ −𝑏𝑛
𝑈 𝑦 − 𝑡𝑛 = −𝑐𝑛
𝑦, 𝑡 ≥ 0
Remember: the RHS is now positive
𝑀𝑄
4
Min σ𝑗 𝑨𝑗 s.t. 𝑏1
𝑈𝑦 + 𝑡1 + 𝑨1 = 𝑐1
−𝑏2
𝑈𝑦 − 𝑡2 + 𝑨2 = −𝑐2
⋮ −𝑏𝑛
𝑈 𝑦 − 𝑡𝑛 + 𝑨𝑛 = −𝑐𝑛
𝑦, 𝑡, 𝑨 ≥ 0
373F19 - Nisarg Shah & Karan Singh 42
Remember: the RHS is now positive
𝑀𝑄
4
Min σ𝑗 𝑨𝑗 s.t. 𝑏1
𝑈𝑦 + 𝑡1 + 𝑨1 = 𝑐1
−𝑏2
𝑈𝑦 − 𝑡2 + 𝑨2 = −𝑐2
⋮ −𝑏𝑛
𝑈 𝑦 − 𝑡𝑛 + 𝑨𝑛 = −𝑐𝑛
𝑦, 𝑡, 𝑨 ≥ 0
What now?
4 using simplex with
the initial basic solution being 𝑦 = 𝑡 = 0, 𝑨 = 𝑐
extract a basic feasible solution 𝑦∗ from it, use it to solve 𝑀𝑄
1 using simplex
4 is
greater than 0, then 𝑀𝑄
1 is
infeasible
373F19 - Nisarg Shah & Karan Singh 43
𝑀𝑄
1
Max 𝑑𝑈𝑦 s.t. 𝑏1
𝑈𝑦 ≤ 𝑐1
𝑏2
𝑈𝑦 ≤ 𝑐2
⋮ 𝑏𝑛
𝑈 𝑦 ≤ 𝑐𝑛
𝑦 ≥ 0 𝑀𝑄2 Min σ𝑗 𝑨𝑗 s.t. 𝑏1
𝑈𝑦 + 𝑡1 + 𝑨1 = 𝑐1
𝑏2
𝑈𝑦 + 𝑡2 + 𝑨2 = 𝑐2
⋮ 𝑏𝑛
𝑈 𝑦 + 𝑡𝑛 + 𝑨𝑛 = 𝑐𝑛
𝑦, 𝑡 ≥ 0
the initial basic feasible solution 𝑦 = 𝑡 = 0, 𝑨 = 𝑐
extract a basic feasible solution 𝑦∗ from it, use it to solve 𝑀𝑄
1 using simplex
greater than 0, then 𝑀𝑄
1 is
infeasible
373F19 - Nisarg Shah & Karan Singh 44
373F19 - Nisarg Shah & Karan Singh 45
➢ Number of vertices of a polytope can be exponential in
the number of constraints
choose your pivots arbitrarily
➢ There are other algorithms which run in polynomial time
input
373F19 - Nisarg Shah & Karan Singh 46
➢ Idea: They can give you very large LPs and you can quickly
return the optimal solutions
➢ Question: But how would they know that your solutions
373F19 - Nisarg Shah & Karan Singh 47
➢ Note: Can easily substitute (𝑦1, 𝑦2), and verify that it is
feasible, and its objective value is indeed 1900
373F19 - Nisarg Shah & Karan Singh 48
➢ E.g. 2*first_constraint + 5*second_constraint +
➢ Try to take combinations which give you 𝑦1 + 6𝑦2 on LHS
373F19 - Nisarg Shah & Karan Singh 49
➢ 𝑦1 + 6𝑦2 ≤ 200 + 6 ∗ 300 = 2000 ➢ This shows that no feasible solution can beat 2000
373F19 - Nisarg Shah & Karan Singh 50
➢ 5𝑦2 + 𝑦1 + 𝑦2 ≤ 5 ∗ 300 + 400 = 1900 ➢ This shows that no feasible solution can beat 1900
373F19 - Nisarg Shah & Karan Singh 51
➢ Note: These need not be integers. They can be reals.
𝑧1 + 𝑧3 𝑦1 + 𝑧2 + 𝑧3 𝑦2 ≤ 200𝑧1 + 300𝑧2 + 400𝑧3
373F19 - Nisarg Shah & Karan Singh 52
➢ We have:
𝑧1 + 𝑧3 𝑦1 + 𝑧2 + 𝑧3 𝑦2 ≤ 200𝑧1 + 300𝑧2 + 400𝑧3
➢ What do we want?
373F19 - Nisarg Shah & Karan Singh 53
➢ We have:
𝑧1 + 𝑧3 𝑦1 + 𝑧2 + 𝑧3 𝑦2 ≤ 200𝑧1 + 300𝑧2 + 400𝑧3
➢ What do we want?
300𝑧2 + 400𝑧3
373F19 - Nisarg Shah & Karan Singh 54
➢ We have:
𝑧1 + 𝑧3 𝑦1 + 𝑧2 + 𝑧3 𝑦2 ≤ 200𝑧1 + 300𝑧2 + 400𝑧3
➢ What do we want?
373F19 - Nisarg Shah & Karan Singh 55
➢ The problem of verifying optimality is another LP
dual is an upper bound on the objective value of the primal
becomes equal to the primal objective for the (𝑦1, 𝑦2) given to you, then you would know that the given 𝑦1, 𝑦2 is optimal for primal (and your (𝑧1, 𝑧2, 𝑧3) is optimal for dual)
373F19 - Nisarg Shah & Karan Singh 56
➢ The problem of verifying optimality is another LP
to verify if optimality of (𝑦1, 𝑦2) given to me?
corresponding 𝑧1, 𝑧2, 𝑧3 for proof of optimality
matches primal objective under optimal solution (𝑦1, 𝑦2)?
373F19 - Nisarg Shah & Karan Singh 57
➢ General version, in our standard form for LPs ➢ Recap:
primal feasible 𝑦 𝑑𝑈𝑦 ≤
min
dual feasible 𝑧 𝑧𝑈𝑐
373F19 - Nisarg Shah & Karan Singh 58
not unbounded
➢ For any primal feasible 𝑦 and dual feasible 𝑧, 𝑑𝑈𝑦 ≤ 𝑧𝑈𝑐
𝑑𝑈𝑦 ≤ 𝑧𝑈𝐵 𝑦 = 𝑧𝑈 𝐵𝑦 ≤ 𝑧𝑈𝑐 Primal LP Dual LP
373F19 - Nisarg Shah & Karan Singh 59
➢ For any primal optimal 𝑦∗ and dual optimal 𝑧∗, 𝑑𝑈𝑦∗ = 𝑧∗ 𝑈𝑐
373F19 - Nisarg Shah & Karan Singh 60
➢ Exactly one of the following holds:
1) There exists 𝑦 such that 𝐵𝑦 ≤ 𝑐 2) There exists 𝑧 such that 𝑧𝑈𝐵 = 0, 𝑧 ≥ 0, 𝑧𝑈𝑐 < 0
➢ Define image of 𝐵 = set of all possible values of 𝐵𝑦 ➢ It is known that this is a “linear subspace” (e.g. a line in a
plane, a line or plane in 3D, etc)
This slide is not in the scope of the course
373F19 - Nisarg Shah & Karan Singh 61
1) There exists 𝑦 such that 𝐵𝑦 ≤ 𝑐 2) There exists 𝑧 such that 𝑧𝑈𝐵 = 0, 𝑧 ≥ 0, 𝑧𝑈𝑐 < 0
1) Image of 𝐵 contains a point “below” 𝑐 2) The region “below” 𝑐 doesn’t intersect image of 𝐵 this is witnessed by normal vector to the image of 𝐵
This slide is not in the scope of the course
373F19 - Nisarg Shah & Karan Singh 62
➢ For any primal optimal 𝑦∗ and dual optimal 𝑧∗, 𝑑𝑈𝑦∗ = 𝑧∗ 𝑈𝑐 ➢ Proof (by contradiction):
such that 𝑧𝑈𝐵 ≥ 𝑑𝑈 and 𝑧𝑈𝑐 ≤ 𝑨∗, i.e., there is no 𝑧 such that
This slide is not in the scope of the course
373F19 - Nisarg Shah & Karan Singh 63
➢ There is no 𝑧 such that ➢ By Farkas’ lemma, there is 𝑦 and 𝜇 such that ➢ Case 1: 𝜇 > 0
𝑦 𝜇 = 𝑐 and 𝑑𝑈 𝑦 𝜇 > 𝑨∗
➢ Case 2: 𝜇 = 0
𝑨∗ ⇒ contradiction
This slide is not in the scope of the course
373F19 - Nisarg Shah & Karan Singh 64