Linear Programming DPV Chapter 7, Part 2 Jim Royer Part 2 March 25, 2019 Uncredited diagrams are from DPV or homemade. DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 1 / 18
Bipartite matching, 1 Definition A graph G = ( V , E ) is bipartite when V can (a) Carol cake be partitioned into two nonempty sets L and R and each edge in E has one endpoint Alice pie in L and the other in R . Given a bipartite graph G , a bipartite (b) Bob tart matching is a set of edges which give an 1-1 Dan cookie correspondence between L and R . (E.g., { (Alice,pie), (Bob,tart), (Carol,cake), (Dan,cookie) } ) DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 2 / 18
Bipartite matching, 1 Definition A graph G = ( V , E ) is bipartite when V can (a) Carol cake be partitioned into two nonempty sets L and R and each edge in E has one endpoint Alice pie in L and the other in R . Given a bipartite graph G , a bipartite (b) Bob tart matching is a set of edges which give an 1-1 Dan cookie correspondence between L and R . (E.g., { (Alice,pie), (Bob,tart), (Carol,cake), (Dan,cookie) } ) We can turn the problem of finding a bipartite matching into a network flow problem by: Carol cake Adding a source and target verts s and t . Alice pie Adding edges from s to each u ∈ L . s t Adding edges from each v ∈ R to t . Bob tart Setting the capacity of each edge 1. Dan cookie DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 2 / 18
Bipartite matching, 2 bipartite matching → network flow Carol cake Add a source and target verts s and t . Alice pie Add edges from s to each u ∈ L . s t Add edges from each v ∈ R to t . Bob tart Set the capacity of each edge 1. Dan cookie Problem We do not want fractional flows. (E.g., Dan wants a whole cookie!) Saving Fact If all edge capacities are integers, then our algorithm finds an integral optimal flow. DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 3 / 18
Bipartite matching, 2 bipartite matching → network flow Carol cake Add a source and target verts s and t . Alice pie Add edges from s to each u ∈ L . s t Add edges from each v ∈ R to t . Bob tart Set the capacity of each edge 1. Dan cookie Problem We do not want fractional flows. (E.g., Dan wants a whole cookie!) BUT! In general it is hard to find Saving Fact solutions to LP problems if you demand all variables If all edge capacities are integers, then our algorithm finds an integral optimal flow. have integer values. (Set up for Chapter 8.) DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 3 / 18
Simplex at a very high level, 1 v ← any vertex in the feasible region while there is a neighbor v ′ of v with a better objective value do v ← v ′ With n variables, we are working in R n . The feasible region is defined by the constraints: ◮ a 1 x 1 + · · · + a n x n = b defines a hyperplane in R n ◮ a 1 x 1 + · · · + a n x n ≤ b and a 1 x 1 + · · · + a n x n ≥ b define halfspaces in R n . ◮ The intersection of halfspaces gives a convex polyhedron. x 2 max x 1 + 6 x 2 + 13 x 3 A � 2 � x 1 ≤ 200 � 1 7 x 2 ≤ 300 � C 2 B x 1 + x 2 + x 3 ≤ 400 � 3 � 3 x 2 + 3 x 3 ≤ 600 � 4 � 1 � 5 x 1 x 1 ≥ 0 � 5 x 2 ≥ 0 � 6 x 3 ≥ 0 � 7 � 6 � 4 x 3 DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 4 / 18
Simplex at a very high level, 2 v ← any vertex in the feasible region while there is a neighbor v ′ of v with a better objective value do v ← v ′ Q: What is a vertex? A: A “corner.” ◮ In 2-D, two lines intersect in a point ∗ . ◮ In 3-D, three planes intersect in a point ∗ . ∗ Watch out for E.g., ➀ , ➁ , and ➆ with equality meet at point A . ◮ In n -D, n hyperplanes intersect in a point ∗ . degeneracy! x 2 max x 1 + 6 x 2 + 13 x 3 A � 2 � x 1 ≤ 200 � 1 7 x 2 ≤ 300 � C 2 B x 1 + x 2 + x 3 ≤ 400 � 3 � 3 x 2 + 3 x 3 ≤ 600 � 4 � 1 � 5 x 1 x 1 ≥ 0 � 5 x 2 ≥ 0 � 6 x 3 ≥ 0 � 7 � 6 � 4 x 3 DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 5 / 18
Simplex at a very high level, 3 v ← any vertex in the feasible region while there is a neighbor v ′ of v with a better objective value do v ← v ′ Q: What is a neighbor of a vertex? A: They have n − 1 defining constraints in common. E.g., A and C share ➂ and ➆ . x 2 max x 1 + 6 x 2 + 13 x 3 A � 2 x 1 ≤ 200 � � 7 1 x 2 ≤ 300 � C 2 B x 1 + x 2 + x 3 ≤ 400 � 3 � 3 x 2 + 3 x 3 ≤ 600 � 4 � 1 � 5 x 1 ≥ 0 x 1 � 5 x 2 ≥ 0 � 6 x 3 ≥ 0 � 7 � 6 � 4 x 3 DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 6 / 18
Simplex: Towards the Algorithm The algorithm has two basic jobs Job 1. See if the current vertex is optimal. (If so, halt.) Job 2. Determine where to move next. Both jobs are easy at the origin: � 0 = ( 0, . . . , 0 ) . Why is the origin so special? Suppose � 0 is feasible. c T � max : � x Job 1. � 0 is optimal ⇐ ⇒ c i ≤ 0 for each i . (Why?) x ≤ � A � b Job 2. If � x ≥ � 0 is not optimal, pick some i with c i > 0 and � 0 increase x i until we hit another constraint. What do we do if we are not at the origin? Transform coordinates to move the origin to where we are. DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 7 / 18
Simplex: Moving the origin Suppose we want to move the origin to � u . Suppose � u is given by the constraints: � a i · � x ≤ b i where i = 1, . . . , n . For i = 1, . . . , n , let y i = b i − � a i · � x . Then: in � x -space in � y -space � a i · � x ≤ b i y i ≥ 0 ❀ � � u 0 ❀ c ′ T · � c T · � max: ( c u + � max: � x y ) ❀ where c u = the cost at � u and � c ′ = the transformed cost vector DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 8 / 18
Example from DPV, 1 Initial LP: Current vertex: { 4 � , 5 � } (origin). Objective value: 0 . max 2 x 1 + 5 x 2 Move: increase x 2 . 2 x 1 − x 2 ≤ 4 � 1 � is released, 3 � becomes tight. Stop at x 2 = 3 . 5 x 1 + 2 x 2 ≤ 9 � 2 − x 1 + x 2 ≤ 3 � 3 New vertex { 4 � , 3 � } has local coordinates ( y 1 , y 2 ) : 0 ≥ � 4 x 1 y 1 = x 1 , y 2 = 3 + x 1 − x 2 0 ≥ � 5 x 2 { 2 � } � , 3 Increase y 1 { 3 � } � , 4 { 1 � , 2 � } Increase x 2 { 4 � , 5 � } { 1 � , 5 � } DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 9 / 18
Example from DPV, 2 Rewritten LP: Current vertex: { 4 � , 3 � } . Objective value: 15 . max 15 + 7 y 1 − 5 y 2 Move: increase y 1 . y 1 + y 2 ≤ 7 � 1 � is released, 2 � becomes tight. Stop at y 1 = 1 . 4 3 y 1 − 2 y 2 ≤ 3 � 2 ≥ 0 � y 2 3 New vertex { 2 � , 3 � } has local coordinates ( z 1 , z 2 ) : ≥ 0 � y 1 4 z 1 = 3 − 3 y 1 + 2 y 2 , z 2 = y 2 − y 1 + y 2 ≤ 3 � 5 { 2 � } � , 3 Increase y 1 { 3 � } � , 4 { 1 � , 2 � } Increase x 2 { 4 � , 5 � } { 1 � , 5 � } DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 10 / 18
Example from DPV, 3 Current vertex: { 2 � } . Rewritten LP: � , 3 Objective value: 22 . max 22 − 7 3 z 1 − 1 3 z 2 Optimal: all c i < 0 . − 1 3 z 1 + 5 6 ≤ � 1 3 z 2 ≥ 0 � z 1 2 Solve � (in original LP) to get optimal solution � , 3 2 ≥ 0 � 3 ( x 1 , x 2 ) = (1 , 4) . z 2 1 3 z 1 − 2 1 ≤ � 3 z 2 4 3 z 1 + 1 1 ≤ 4 � 3 z 2 5 { 2 � , 3 � } Increase y 1 { 3 � , 4 � } { 1 � , 2 � } Increase x 2 { 1 � , 5 � } { 4 � , 5 � } DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 11 / 18
Example from DPV, 3 Linear Programming Current vertex: { 2 � } . Rewritten LP: � , 3 Objective value: 22 . max 22 − 7 3 z 1 − 1 3 z 2 Optimal: all c i < 0 . 2019-03-25 − 1 3 z 1 + 5 3 z 2 ≤ 6 � 1 z 1 ≥ 0 � 2 Solve � (in original LP) to get optimal solution � , 3 2 ≥ 0 � z 2 3 ( x 1 , x 2 ) = (1 , 4) . 3 z 1 − 2 1 1 3 z 2 ≤ � 4 3 z 1 + 1 1 3 z 2 ≤ 4 � 5 Example from DPV, 3 { 2 � , 3 � } Increase y 1 { 3 � , 4 � } { 1 � , 2 � } Increase x 2 { 4 � , 5 � } { 1 � , 5 � } ( x 1 , x 2 ) = ( 1, 4 )
Simplex Issues: Finding the starting vertex The origin is not always in the feasible region. Q: So how to find a starting vertex? A: It turns out this is another LP problem: c T · � x = � x ≥ � Suppose we have min : � x A � b and � 0. ∋ Then: ◮ Make sure each b i ≥ 0. If b i < 0, multiply both sides of the i -th eqn. by − 1. ◮ Create new variables z 1 , . . . , z m ≥ 0 where m = # of equations. ◮ Add z i to the left-hand side of equation i . ◮ min : z 1 + · · · + z m is the objective function. ◮ z 1 = b 1 , . . . , z m = b m and all other variables = 0 is a starting vertex. Case: Simplex reports 0 is the optimal value of the objective function. Then ignore the z i ’s and the value of the other vars gives a starting vertex. Case: Simplex reports 0 is not the opt. value of the objective function. Then the original LP problem must be infeasible. (Why?) DPV Chapter 7 (Part 2) Linear Programming March 25, 2019 12 / 18
Recommend
More recommend