Lecture 19 Linear Program
Recap Shortest path Minimum spanning tree Maximum matching Common: Optimizing some objective (length of paths, weight of the tree, number of matches) Very different techniques Hope: A common technique that can solve all problems
Linear Relationships Inequalities that are linear in all parameters. Example. If d[u] = shortest path distance from s to u, then for any edge (u,v) 𝑑 𝑣 ≤𝑑 𝑢 +𝑤(𝑢,𝑣)
Linear Relationships Example 2: Let xi,j = 1 if course i is matched to classroom j, and 0 otherwise. Each classroom is matched to at most one course. ∀𝑗 𝑖=1 𝑛 𝑥 𝑖,𝑗 ≤1
Linear Program Optimize a linear function (objective), under a set of linear inequality constraints. max 2𝑥+𝑦 𝑥≥0 𝑦≥0 𝑥+𝑦≤1
Geometric Interpretation Linear inequality Half planes x y x y x y 𝑥+𝑦≤1 𝑥≥0 𝑦≥0
Geometric Interpretation System of linear inequalities intersections Green: Feasible set. Point in Green: feasible solution. x y
Geometric Interpretation Objective function Direction of gravity x y x y max 2𝑥+𝑦
Geometric Interpretation Optimal Point Lowest point Optimal solution: (x, y) = (1, 0), value = 2. x y
Canonical Form min 𝑐,𝑥 𝐴𝑥≥𝑏 𝑥≥0 c x A x b ≥
Converting to Canonical Form Equality constraints (e.g. x+y = 3) Solution: Split into two constraints 𝑥+𝑦≥3 𝑥+𝑦≤3
Converting to Canonical Form Free variable: x may or may not be nonnegative. Solution: Split x into x1 and x2 𝑥= 𝑥 1 − 𝑥 2 𝑥 1 ≥0 𝑥 2 ≥0
Using LP to solve graph problems Edge (i, j): Course i can be scheduled into classroom j Courses Classrooms Solution: A set of edges that do not share any vertices. (a matching)
Using LP to solve graph problems 1 2 1 2 3 3 1 2 4 5 6 4 1 1 3 2 7 8 9 1 1