CSC 8301 Design & Analysis of Algorithms: Linear Programming Professor Henry Carter Fall 2016
Iterative Improvement Start with a feasible solution Improve some part of the solution Repeat until the solution is optimal 2
A Geometric Solution y ( 0, 2 ) ( 3, 1 ) ( 0, 0 ) ( 4, 0 ) x 3x + 5y = 20 3x + 5y = 14 3x + 5y = 10 Maximize: 3x + 5y 3
The Simplex Method A convenient means for iterating over extreme points Problem must be: Maximization problem All constraints must be linear equations with nonnegative right-hand sides All variables must be nonnegative 4
Step 0: Standard Form Min-max conversion Representing inequalities with slack variables Replace negative variables with two nonnegative variables 5
Example Standard Form Maximize: 3x + 5y Subject to: x + y 4 x + 3y 6 x 0, y 0 Maximize: 3x + 5y + 0u + 0v Subject to: x + y + u = 4 x + 3y + v = 6 x, y, u, v 0 6
Basic Feasible Solution Find an initial extreme point to begin iterative improvement For m constraints over n variables, set (n - m) variables to 0 Common approach is to zero the original variables and set the slack variables accordingly For our example, (0, 0, 4, 6) 7
Constructing the Simplex Tableau Constraint Coefficients Objective Row Recognize the corresponding solution Maximize: 3x + 5y + 0u + 0v Subject to: x + y + u = 4 x + 3y + v = 6 x, y, u, v 0 8
Example Tableau x y u v u 1 1 1 0 4 v 1 3 0 1 6-3 -5 0 0 0 9
Iterating the Extreme Point Choose the entering variable (new basic variable) Choose the departing variable (new nonbasic variable) Pivot Operations 10
Example Iteration x y u v u 1 1 1 0 4 v 1 3 0 1 6-3 -5 0 0 0 11
Example Iteration x y u v u 1 1 1 0 4 θ u = v 1 3 0 1 6 θ v = -3-5 0 0 0 12
Example Iteration x y u v u 1 1 1 0 4 v 1 3 0 1 6-3 -5 0 0 0 13
Example Iteration x y u v u 1 1 1 0 4 v 1/3 1 0 1/3 2-3 -5 0 0 0 14
Example Iteration x y u v u 2/3 0 1-1/3 2 y 1/3 1 0 1/3 2-4/3 0 0 5/3 10 15
Example Iteration x y u v u 2/3 0 1-1/3 2 y 1/3 1 0 1/3 2-4/3 0 0 5/3 10 16
Example Iteration x y u v x 1 0 3/2-1/2 3 y 0 1-1/2 1/2 1 0 0 2 1 14 17
Practical Points Prevent cycling with Bland s Rule Algorithmically finding an initial feasible solution Two-phase Simplex Method 18
Analysis Number of extreme points grows exponentially In practice, between m and 3m iterations are needed Operations per iteration: O(mn) Other approaches: Ellipsoid method (polynomial worst-case) Karmarkar s algorithm (empirically efficient) 19
Practice Set up the first simplex tableau for the following linear programming problem: Maximize: x + 2y subject to: 4x y y 3 + x x 0, y 0 20
Recap Iterative methods start with a solution then iteratively improve it until optimal Linear programming optimizes a linear equation with constraints The Simplex Method iterates over extreme points in the feasible region Very common in practice (even included in Excel addon) 21
Modeling a Transportation Network Recall: weighted digraphs Represent start and end as a source vertex and a sink vertex Represent paths with positive capacity using edge weight Flow Network 22
Finding a Flow Rules: Flow-conservation Edge capacity Flow value Maximize the value 23
Ford-Fulkerson Initialize a 0-value flow Iteratively search for an augmented path Any path from source to sink with available flow capacity When no more augmenting paths can be found, the flow is maximized 24
Greedy Approach Example 5 3 4 1 2 5 2 3 2 6 3 4 1 25
Shortest Augmenting Path Uses a BFS to traverse the graph Along the path, adjust the incoming flow for each vertex if there is edge capacity available If a vertex with no outgoing capacity is encountered, adjust the incoming flow on a back edge Augment the current flow each time a new augmenting path reaches the sink Terminate if no augmenting path to the sink exists 26
Example: 1 st augmenting path 5 0/3 0/4 1 0/2 0/5 2 3 0/2 6 0/3 4 0/1 Queue: 1-2 3 4 5 6 27
Example: 2 nd augmenting path 5 0/3 0/4 1 2/2 2/5 2 3 2/2 6 0/3 4 0/1 Queue: 1-2 3 4 5 6 28
Example: no more augmenting paths 5 1/3 1/4 1 2/2 1/5 2 3 2/2 6 1/3 4 1/1 Queue: 1-2 3 4 5 6 29
Analysis Time to find one augmenting path (using adjacency lists): O( E ) Maximum iterations needed: E V /2 Worst-case: O( ) 30
Max-flow Min-cut theorem A cut is a set of edges that, when removed, eliminate all paths from source to sink A min-cut is a cut where the sum of the edge weights is minimized The value of a max-flow is equal to the capacity of the min-cut 31
Finding the Min-cut 5 1/3 1/4 1 2/2 1/5 2 3 2/2 6 1/3 4 1/1 Queue: 1, 4 1-2 3 4 2 1+ 5 6 32
Practice 5 1 2 5 2 6 4 4 3 7 8 4 6 33
Recap Iterative improvement of a max-flow using augmented paths Shortest augmenting path algorithm considers both forward and backward edges to find an augmenting path The max-flow value of a network is equal to the min-cut capacity 34
Next Time... Levitin Chapter 10.3-10.4 Remember, you need to read it BEFORE you come to class! Homework: 10.1: 3, 5, 8 10.2: 1-4, 10 35