Linear Programming DPV Chapter 7, Part 1 Jim Royer March 20, 2019 Uncredited diagrams are from DPV or homemade. DPV Chapter 7, Part 1 Linear Programming 1 / 1
Linear Programming: Introduction, 1 Ingredients of Linear Programming ◮ a set of variables ◮ a set of linear equations/inequalities over these variables ◮ a linear objective function to min/max An Example Problem: Maximizing Profits Item # made per day profit per unit max # per day 1 x 1 $1 200 2 x 2 $6 300 We also cannot make more than a total of 400 units per day of items 1 and 2 combined. Q: What should x 1 and x 2 be to maximize profits? DPV Chapter 7, Part 1 Linear Programming 2 / 1
Sample Problem, Continued An Example Problem: Maximizing Profits Item # made per day profit per unit max # per day 1 x 1 $1 200 2 x 2 $6 300 We also cannot make more than a total of 400 units per day of items 1 and 2 combined. The problem expressed as a linear program max: x 1 + 6 x 2 Objective function x 1 ≤ 200 Constraints x 2 ≤ 300 x 1 + x 2 ≤ 400 x 1 , x 2 ≥ 0 DPV Chapter 7, Part 1 Linear Programming 3 / 1
Sample Problem, Continued The problem Figure 7.1 (a) The feasible region for a linear program. (b) Contour lines of the objective expressed as a function: x 1 + 6 x 2 = c for different values of the profit c . linear program x 2 x 2 (a) (b) 400 400 Objective function Optimum point Profit = $1900 max: x 1 + 6 x 2 300 300 Constraints c = 1500 200 200 x 1 ≤ 200 c = 1200 x 2 ≤ 300 100 100 c = 600 x 1 + x 2 ≤ 400 x 1 x 1 x 1 , x 2 ≥ 0 0 100 200 300 400 0 100 200 300 400 DPV Chapter 7, Part 1 Linear Programming 4 / 1
Linear Programming, 2 ◮ The constraints describe a convex polygon. (Why?) Generally ... The optimum is achieved at a vertex of the feasible region. (Why?) ...except when there is no optimum. E.g.: ◮ the linear program is infeasible , meaning the constraints are so tight it is impossible to satisfy them all. E.g.: x ≤ 1, x ≥ 2. ◮ the feasible region is unbounded , meaning the constraints are so loose that the objective function takes on arbitrarily large values. E.g.: maximize x 1 + x 2 under x 1 , x 2 ≥ 0. DPV Chapter 7, Part 1 Linear Programming 5 / 1
How to Solve Linear Programs The Simplex Method Profit $1900 ◮ Warning: Far from the whole story!! 300 ◮ The feasible region is a polygon. ◮ Suppose p is a vertex of the feasible region polygon. $1400 ◮ p is a local maximum when the value of 200 the objective function is larger at p and at any of its neighbors. ◮ The method hill-climbs . 100 p ← the origin while p is not a local max do p ← the neighbor at which the $200 $0 obj. function is larger 0 100 200 return p no better neighbor, simplex ?? Why is the local max the true max? DPV Chapter 7, Part 1 Linear Programming 6 / 1
Sample Problem, Continued An Example Problem: Maximizing Profits Item # made per day profit per unit max # per day 1 x 1 $1 200 2 x 2 $6 300 3 x 3 $13 Other production constraints: x 1 + x 2 + x 3 ≤ 400 and x 2 + 3 x 3 ≤ 600. The problem expressed as a linear program Objective function max: x 1 + 6 x 2 + 13 x 3 x 1 ≤ 200 Constraints x 2 ≤ 300 x 1 + x 2 + x 3 ≤ 400 x 2 + 3 x 3 ≤ 400 x 1 , x 2 , x 3 ≥ 0 DPV Chapter 7, Part 1 Linear Programming 7 / 1
Sample Problem, Continued x 2 Optimum The problem expressed as a linear program max: x 1 + 6 x 2 + 13 x 3 Objective function x 1 ≤ 200 Constraints x 2 ≤ 300 x 1 x 1 + x 2 + x 3 ≤ 400 x 2 + 3 x 3 ≤ 400 x 1 , x 2 , x 3 ≥ 0 x 3 (0 , 0 , 0) → (200 , 0 , 0) → (200 , 200 , 0) → (200 , 0 , 200) → (0 , 300 , 100) − − − − $0 $200 $1400 $2800 $3100 DPV Chapter 7, Part 1 Linear Programming 8 / 1
Notes ◮ At higher dimensions, things are harder to visualize, but the math still works! ◮ There are lots of professional packages that quickly and accurately solve linear programming problems. ◮ So the key thing to know is: how to precisely express a problem as a LP-problem. DPV Chapter 7, Part 1 Linear Programming 9 / 1
Bandwidth Allocation, 1 ◮ We have a network as shown in the figure. user ◮ The numbers on edges are max-bandwidth capacities. A ◮ We need connections between users A&B, A&C, and 12 B&C. a ◮ Each connection requires at least two units of bandwidth, 11 6 but more can be used. ◮ Connection A–B pays $3 per bandwidth unit; A–C pays c b $4 and B–C pays $2. 13 10 8 ◮ Each connection can be routed via the short route, long user user B C route, or a combination of the two. ?? How do we route connections to maximize profit? DPV Chapter 7, Part 1 Linear Programming 10 / 1
Bandwidth Allocation, 2 user ◮ Each connection needs at least two units of bandwidth. A 12 ◮ Connection A–B pays $3 per bandwidth unit; A–C pays $4 and a B–C pays $2. 6 11 ?? How do we route connections to maximize profit? c b 13 max 3 x AB + 3 x � AB + 2 x BC + 2 x � BC + 4 x AC + 4 x � AC 10 8 user user x AB + x � AB + x BC + x � BC ≤ 10 [edge ( b, B ) ] B C x AB + x � AB + x AC + x � AC ≤ 12 [edge ( a, A ) ] Solution via Simplex: x BC + x � BC + x AC + x � AC ≤ 8 [edge ( c, C ) ] x AB = 0.0 x AB + x � BC + x � AC ≤ 6 [edge ( a, b ) ] x ′ AB = 7.0 x � AB + x BC + x � AC ≤ 13 [edge ( b, c ) ] x � AB + x � BC + x AC ≤ 11 [edge ( a, c ) ] x BC = 1.5 x AB + x � AB ≥ 2 x ′ BC = 1.5 x BC + x � BC ≥ 2 x AC = 0.5 x AC + x � AC ≥ 2 x ′ AC = 4.5 x AB , x � AB , x BC , x � BC , x AC , x � AC ≥ 0 ⋆ x UV = the short path allocation for U - V ⋆ x ′ UV = the long path allocation for U - V DPV Chapter 7, Part 1 Linear Programming 11 / 1
Variations on Linear Programming, 1 LP in Standard Form LP in General ◮ the objective function is minimized ◮ the objective function is minimized or maximized ◮ the variables are constrained to be ≥ 0 ◮ the variables may take on negative values ◮ the other constraints are equations ◮ the other constraints are equations or inequalities Reduction to Standard Form ⇐ ⇒ min : ( − f ) max : f x + , x − ≥ 0 & x = x + − x − x positive/negative ⇐ ⇒ ( ∑ a i x i ) + s = b & a 1 x 1 + · · · + a n x n ≤ b ⇐ ⇒ s ≥ 0 s as above is called a slack variable. DPV Chapter 7, Part 1 Linear Programming 12 / 1
Variations on Linear Programming, 2 Reduction to Standard Form max : f ⇐ ⇒ min : ( − f ) x + , x − ≥ 0 & x = x + − x − x positive/negative ⇐ ⇒ ( ∑ a i x i ) + s = b & s ≥ 0 a 1 x 1 + · · · + a n x n ≤ b ⇐ ⇒ Example max: x 1 + 6 x 2 min: − x 1 − 6 x 2 x 1 ≤ 200 x 1 + s 1 = 200 x 2 ≤ 300 = ⇒ x 2 + s 2 = 300 x 1 + x 2 ≤ 400 x 1 + x 2 + s 3 = 400 x 1 , x 2 ≥ 0 x 1 , x 2 , s 1 , s 2 , s 3 ≥ 0 DPV Chapter 7, Part 1 Linear Programming 13 / 1
Linear Programming in Matrix Form Example c T · � max: x 1 + 6 x 2 max: � x x ≤ � x 1 ≤ 200 = ⇒ � A b x 2 ≤ 300 � x ≥ 0 x 1 + x 2 ≤ 400 x 1 , x 2 ≥ 0 200 1 0 � � � � 1 x 1 � � c = � x = b = A = where , , 300 , 0 1 6 x 2 400 1 1 DPV Chapter 7, Part 1 Linear Programming 14 / 1
Network Flows (a) (b) 2 2 a a d d 2 2 3 2 10 1 0 1 0 s s b t b t 1 1 3 1 1 4 4 5 5 c e c e 5 5 (a) A network of oil pipelines. The number on each edge is its maximum capacity. No storage in nodes. s = source node. t = target node. Goal: Send as much oil from s to t as the network allows. (b) A flow in the network, shipping 7 units. Can we do better? How do we find out? DPV Chapter 7, Part 1 Linear Programming 15 / 1
Network Flow as an LP Problem ◮ A variable for each edge: f e = the flow on that edge. 0 ≤ f e ≤ c e = the capacity of edge e . ◮ Flow is conserved at each node except s and t : f wu = ∑ ∑ f uz ( w , u ) ∈ E ( u , z ) ∈ E ◮ The size of the flow is the amount sent from s to t . By conservation: size ( f ) = ∑ f su . ( s , u ) ∈ E ◮ Goal: Assign values to the f uv ’s that satisfy the constraints and maximize size ( f ) . ∴ This is a linear programming problem, so Simplex can solve these problems for us. DPV Chapter 7, Part 1 Linear Programming 16 / 1
From Simplex to a Direct Network Flow Algorithm, 1 If you analyze how Simplex solves (a) (b) Network Flow Problems, it is roughly a a equivalent to: 1 1 1 s t s t Start with zero flow. Repeat 1 1 b Choose an appropriate path from s to t Increase the flow along the path’s edges (c) (d) as much as possible a 1 1 until there is no path that improves the flow s s 0 t t 1 1 (a) Initial network. b b (b) First path chosen. (e) (f) (c) Second path chosen. a a 1 (d) Final flow. 1 s 1 s t t (e) Alternative first path. 1 1 1 (f) Alternative second path. b b The b → a edge cancels flow. DPV Chapter 7, Part 1 Linear Programming 17 / 1
Recommend
More recommend