III. Linear Programming

Similar documents
An example of LP problem: Political Elections

29 Linear Programming

The simplex algorithm

Lecture 9 Tuesday, 4/20/10. Linear Programming

Linear Programming. Jie Wang. University of Massachusetts Lowell Department of Computer Science. J. Wang (UMass Lowell) Linear Programming 1 / 47

CSC373: Algorithm Design, Analysis and Complexity Fall 2017 DENIS PANKRATOV NOVEMBER 1, 2017

Today: Linear Programming

Optimization (168) Lecture 7-8-9

The Simplex Algorithm

CSC Design and Analysis of Algorithms. LP Shader Electronics Example

Lecture slides by Kevin Wayne

LINEAR PROGRAMMING I. a refreshing example standard form fundamental questions geometry linear algebra simplex algorithm

9.1 Linear Programs in canonical form

Lecture 4: Algebra, Geometry, and Complexity of the Simplex Method. Reading: Sections 2.6.4, 3.5,

AM 121: Intro to Optimization

Linear Programming. Linear Programming I. Lecture 1. Linear Programming. Linear Programming

1 The linear algebra of linear programs (March 15 and 22, 2015)

Motivating examples Introduction to algorithms Simplex algorithm. On a particular example General algorithm. Duality An application to game theory

LP. Lecture 3. Chapter 3: degeneracy. degeneracy example cycling the lexicographic method other pivot rules the fundamental theorem of LP

COMP3121/9101/3821/9801 Lecture Notes. Linear Programming

The Simplex Algorithm: Technicalities 1

Linear programming. Saad Mneimneh. maximize x 1 + x 2 subject to 4x 1 x 2 8 2x 1 + x x 1 2x 2 2

Linear Programming Duality P&S Chapter 3 Last Revised Nov 1, 2004

Lecture 2: The Simplex method

Lecture #21. c T x Ax b. maximize subject to

CO 250 Final Exam Guide

A Parametric Simplex Algorithm for Linear Vector Optimization Problems

BBM402-Lecture 20: LP Duality

COT 6936: Topics in Algorithms! Giri Narasimhan. ECS 254A / EC 2443; Phone: x3748

The Avis-Kalunzy Algorithm is designed to find a basic feasible solution (BFS) of a given set of constraints. Its input: A R m n and b R m such that

Supplementary lecture notes on linear programming. We will present an algorithm to solve linear programs of the form. maximize.

CO350 Linear Programming Chapter 8: Degeneracy and Finite Termination

15-780: LinearProgramming

Summary of the simplex method

Introduction to Linear and Combinatorial Optimization (ADM I)

Input: System of inequalities or equalities over the reals R. Output: Value for variables that minimizes cost function

Chapter 1 Linear Programming. Paragraph 5 Duality

1 Review Session. 1.1 Lecture 2

CO 602/CM 740: Fundamentals of Optimization Problem Set 4

CS 6820 Fall 2014 Lectures, October 3-20, 2014

Optimization WS 13/14:, by Y. Goldstein/K. Reinert, 9. Dezember 2013, 16: Linear programming. Optimization Problems

An introductory example

Part 1. The Review of Linear Programming

Linear Programming Redux

A Review of Linear Programming

Introduction to Algorithms

"SYMMETRIC" PRIMAL-DUAL PAIR

CSCI 1951-G Optimization Methods in Finance Part 01: Linear Programming

Termination, Cycling, and Degeneracy

MAT016: Optimization

TIM 206 Lecture 3: The Simplex Method

Algorithms and Theory of Computation. Lecture 11: Network Flow

Lesson 27 Linear Programming; The Simplex Method

min 4x 1 5x 2 + 3x 3 s.t. x 1 + 2x 2 + x 3 = 10 x 1 x 2 6 x 1 + 3x 2 + x 3 14

IE 400: Principles of Engineering Management. Simplex Method Continued

Discrete Optimization

Simplex Algorithm Using Canonical Tableaus

F 1 F 2 Daily Requirement Cost N N N

4.5 Simplex method. LP in standard form: min z = c T x s.t. Ax = b

Developing an Algorithm for LP Preamble to Section 3 (Simplex Method)

Lecture 6 Simplex method for linear programming

x 1 + x 2 2 x 1 x 2 1 x 2 2 min 3x 1 + 2x 2

Optimization methods NOPT048

4.5 Simplex method. min z = c T x s.v. Ax = b. LP in standard form

Section Notes 9. IP: Cutting Planes. Applied Math 121. Week of April 12, 2010

Yinyu Ye, MS&E, Stanford MS&E310 Lecture Note #06. The Simplex Method

Standard Form An LP is in standard form when: All variables are non-negativenegative All constraints are equalities Putting an LP formulation into sta

3 The Simplex Method. 3.1 Basic Solutions

IE 5531: Engineering Optimization I

Example. 1 Rows 1,..., m of the simplex tableau remain lexicographically positive

Part 1. The Review of Linear Programming

Chap6 Duality Theory and Sensitivity Analysis

We say that a flow is feasible for G (or just feasible if the graph and capacity function in question are obvious) if

Ω R n is called the constraint set or feasible set. x 1

IE 5531: Engineering Optimization I

3. THE SIMPLEX ALGORITHM

Linear Programming Duality

Optimization methods NOPT048

Introduction to Linear Programming

Duality of LPs and Applications

Chapter 5 Linear Programming (LP)

Introduction to optimization

Linear Programming, Lecture 4

Summary of the simplex method

Discrete Optimization. Guyslain Naves

Ann-Brith Strömberg. Lecture 4 Linear and Integer Optimization with Applications 1/10

ORF 522. Linear Programming and Convex Analysis

CS675: Convex and Combinatorial Optimization Fall 2016 Combinatorial Problems as Linear and Convex Programs. Instructor: Shaddin Dughmi

CS261: Problem Set #3

CS261: A Second Course in Algorithms Lecture #9: Linear Programming Duality (Part 2)

Algorithms and Theory of Computation. Lecture 13: Linear Programming (2)

Understanding the Simplex algorithm. Standard Optimization Problems.

CHAPTER 2. The Simplex Method

OPTIMISATION 3: NOTES ON THE SIMPLEX ALGORITHM

The Dual Simplex Algorithm

4.6 Linear Programming duality

Linear and Integer Programming - ideas

CS675: Convex and Combinatorial Optimization Fall 2014 Combinatorial Problems as Linear Programs. Instructor: Shaddin Dughmi

Revised Simplex Method

A primal-simplex based Tardos algorithm

Transcription:

III. Linear Programming Thomas Sauerwald Easter 2017

Outline Introduction Standard and Slack Forms Formulating Problems as Linear Programs Simplex Algorithm Finding an Initial Solution III. Linear Programming Introduction 2

Introduction Linear Programming (informal definition) maximize or minimize an objective, given limited resources and competing constraint constraints are specified as (in)equalities Example: Political Advertising Imagine you are a politician trying to win an election Your district has three different types of areas: Urban, suburban and rural, each with, respectively, 100,000, 200,000 and 50,000 registered voters Aim: at least half of the registered voters in each of the three regions should vote for you Possible Actions: Advertise on one of the primary issues which are (i) building more roads, (ii) gun control, (iii) farm subsidies and (iv) a gasoline tax dedicated to improve public transit. III. Linear Programming Introduction 3

Political Advertising Continued policy urban suburban rural build roads 2 5 3 gun control 8 2 5 farm subsidies 0 0 10 gasoline tax 10 0 2 The effects of policies on voters. Each entry describes the number of thousands of voters who could be won (lost) over by spending $1,000 on advertising support of a policy on a particular issue. Possible Solution: $20,000 on advertising to building roads $0 on advertising to gun control $4,000 on advertising to farm subsidies $9,000 on advertising to a gasoline tax Total cost: $33,000 What is the best possible strategy? III. Linear Programming Introduction 4

Towards a Linear Program policy urban suburban rural build roads 2 5 3 gun control 8 2 5 farm subsidies 0 0 10 gasoline tax 10 0 2 The effects of policies on voters. Each entry describes the number of thousands of voters who could be won (lost) over by spending $1,000 on advertising support of a policy on a particular issue. x 1 = number of thousands of dollars spent on advertising on building roads x 2 = number of thousands of dollars spent on advertising on gun control x 3 = number of thousands of dollars spent on advertising on farm subsidies x 4 = number of thousands of dollars spent on advertising on gasoline tax Constraints: 2x 1 + 8x 2 + 0x 3 + 10x 4 50 Objective: Minimize x 5x 1 + 2x 2 + 0x 3 + 0x 4 100 1 + x 2 + x 3 + x 4 3x 1 5x 2 + 10x 3 2x 4 25 III. Linear Programming Introduction 5

The Linear Program Linear Program for the Advertising Problem minimize x 1 + x 2 + x 3 + x 4 subject to 2x 1 + 8x 2 + 0x 3 + 10x 4 50 5x 1 + 2x 2 + 0x 3 + 0x 4 100 3x 1 5x 2 + 10x 3 2x 4 25 x 1, x 2, x 3, x 4 0 The solution of this linear program yields the optimal advertising strategy. Formal Definition of Linear Program Given a 1, a 2,..., a n and a set of variables x 1, x 2,..., x n, a linear function f is defined by f (x 1, x 2,..., x n) = a 1 x 1 + a 2 x 2 + + a nx n. Linear Equality: f (x 1, x 2,..., x n) = b Linear Inequality: f (x 1, x 2,..., x n) b Linear Constraints Linear-Progamming Problem: either minimize or maximize a linear function subject to a set of linear constraints III. Linear Programming Introduction 6

A Small(er) Example maximize x 1 + x 2 subject to 4x 1 x 2 8 2x 1 + x 2 10 5x 1 2x 2 2 x 1, x 2 0 x 1 0 x 2 5x 1 2x 2 2 4x 1 x 2 8 2x 1 + x 2 10 Any setting of x 1 and x 2 satisfying all constraints is a feasible solution x 2 0 x 1 III. Linear Programming Introduction 7.1

A Small(er) Example maximize x 1 + x 2 subject to 4x 1 x 2 8 2x 1 + x 2 10 5x 1 2x 2 2 x 1, x 2 0 x 2 x1 + x 2 = 8 x 1 0 5x 1 2x 2 2 4x 1 x 2 8 Graphical Procedure: Move the line x 1 + x 2 = z as far up as possible. 2x 1 + x 2 10 x 2 0 x 1 While the same approach also works for higher-dimensions, we need to take a more systematic and algebraic procedure. III. Linear Programming Introduction 7.2

Outline Introduction Standard and Slack Forms Formulating Problems as Linear Programs Simplex Algorithm Finding an Initial Solution III. Linear Programming Standard and Slack Forms 8

Standard and Slack Forms Standard Form maximize subject to n + m Constraints n c j x j Objective Function j=1 n a ij x j b i for i = 1, 2,..., m j=1 x j 0 for j = 1, 2,..., n Standard Form (Matrix-Vector-Notation) Non-Negativity Constraints maximize subject to c T x Inner product of two vectors Ax b Matrix-vector product x 0 III. Linear Programming Standard and Slack Forms 9

Converting Linear Programs into Standard Form Reasons for a LP not being in standard form: 1. The objective might be a minimization rather than maximization. 2. There might be variables without nonnegativity constraints. 3. There might be equality constraints. 4. There might be inequality constraints (with instead of ). Goal: Convert linear program into an equivalent program which is in standard form Equivalence: a correspondence (not necessarily a bijection) between solutions so that their objective values are identical. When switching from maximization to minimization, sign of objective value changes. III. Linear Programming Standard and Slack Forms 10

Converting into Standard Form (1/5) Reasons for a LP not being in standard form: 1. The objective might be a minimization rather than maximization. minimize 2x 1 + 3x 2 subject to x 1 + x 2 = 7 x 1 2x 2 4 x 1 0 Negate objective function maximize 2x 1 3x 2 subject to x 1 + x 2 = 7 x 1 2x 2 4 x 1 0 III. Linear Programming Standard and Slack Forms 11

Converting into Standard Form (2/5) Reasons for a LP not being in standard form: 2. There might be variables without nonnegativity constraints. maximize 2x 1 3x 2 subject to x 1 + x 2 = 7 x 1 2x 2 4 x 1 0 Replace x 2 by two non-negative variables x 2 and x 2 maximize 2x 1 3x 2 + 3x 2 subject to x 1 + x 2 x 2 = 7 x 1 2x 2 + 2x 2 4 x 1, x 2, x 2 0 III. Linear Programming Standard and Slack Forms 12

Converting into Standard Form (3/5) Reasons for a LP not being in standard form: 3. There might be equality constraints. maximize 2x 1 3x 2 + 3x 2 subject to x 1 + x 2 x 2 = 7 x 1 2x 2 + 2x 2 4 x 1, x 2, x 2 0 Replace each equality by two inequalities. maximize 2x 1 3x 2 + 3x 2 subject to x 1 + x 2 x 2 7 x 1 + x 2 x 2 7 x 1 2x 2 + 2x 2 4 x 1, x 2, x 2 0 III. Linear Programming Standard and Slack Forms 13

Converting into Standard Form (4/5) Reasons for a LP not being in standard form: 4. There might be inequality constraints (with instead of ). maximize 2x 1 3x 2 + 3x 2 subject to x 1 + x 2 x 2 7 x 1 + x 2 x 2 7 x 1 2x 2 + 2x 2 4 x 1, x 2, x 2 0 Negate respective inequalities. maximize 2x 1 3x 2 + 3x 2 subject to x 1 + x 2 x 2 7 x 1 x 2 + x 2 7 x 1 2x 2 + 2x 2 4 x 1, x 2, x 2 0 III. Linear Programming Standard and Slack Forms 14

Converting into Standard Form (5/5) Rename variable names (for consistency). maximize 2x 1 3x 2 + 3x 3 subject to x 1 + x 2 x 3 7 x 1 x 2 + x 3 7 x 1 2x 2 + 2x 3 4 x 1, x 2, x 3 0 It is always possible to convert a linear program into standard form. III. Linear Programming Standard and Slack Forms 15

Converting Standard Form into Slack Form (1/3) Goal: Convert standard form into slack form, where all constraints except for the non-negativity constraints are equalities. For the simplex algorithm, it is more convenient to work with equality constraints. Introducing Slack Variables Let n j=1 a ijx j b i be an inequality constraint Introduce a slack variable s by s measures the slack between the two sides of the inequality. s = b i s 0. n a ij x j j=1 Denote slack variable of the ith inequality by x n+i III. Linear Programming Standard and Slack Forms 16

Converting Standard Form into Slack Form (2/3) maximize 2x 1 3x 2 + 3x 3 subject to x 1 + x 2 x 3 7 x 1 x 2 + x 3 7 x 1 2x 2 + 2x 3 4 x 1, x 2, x 3 0 Introduce slack variables maximize 2x 1 3x 2 + 3x 3 subject to x 4 = 7 x 1 x 2 + x 3 x 5 = 7 + x 1 + x 2 x 3 x 6 = 4 x 1 + 2x 2 2x 3 x 1, x 2, x 3, x 4, x 5, x 6 0 III. Linear Programming Standard and Slack Forms 17

Converting Standard Form into Slack Form (3/3) maximize 2x 1 3x 2 + 3x 3 subject to x 4 = 7 x 1 x 2 + x 3 x 5 = 7 + x 1 + x 2 x 3 x 6 = 4 x 1 + 2x 2 2x 3 x 1, x 2, x 3, x 4, x 5, x 6 0 Use variable z to denote objective function and omit the nonnegativity constraints. z = 2x 1 3x 2 + 3x 3 x 4 = 7 x 1 x 2 + x 3 x 5 = 7 + x 1 + x 2 x 3 x 6 = 4 x 1 + 2x 2 2x 3 This is called slack form. III. Linear Programming Standard and Slack Forms 18

Basic and Non-Basic Variables z = 2x 1 3x 2 + 3x 3 x 4 = 7 x 1 x 2 + x 3 x 5 = 7 + x 1 + x 2 x 3 x 6 = 4 x 1 + 2x 2 2x 3 Basic Variables: B = {4, 5, 6} Non-Basic Variables: N = {1, 2, 3} Slack Form (Formal Definition) Slack form is given by a tuple (N, B, A, b, c, v) so that z = v + c j x j j N x i = b i a ij x j for i B, j N and all variables are non-negative. Variables/Coefficients on the right hand side are indexed by B and N. III. Linear Programming Standard and Slack Forms 19

Slack Form (Example) Slack Form Notation z = 28 x 1 = 8 + x 3 6 x 3 + 6 x 2 = 4 8x 3 3 x 4 = 18 x 3 2 + B = {1, 2, 4}, N = {3, 5, 6} v = 28 x 5 2x 6 6 3 x 5 x 6 6 3 2x5 x + 6 3 3 x 5 2 a 13 a 15 a 16 1/6 1/6 1/3 A = a 23 a 25 a 26 = 8/3 2/3 1/3 a 43 a 45 a 46 1/2 1/2 0 b 1 8 c 3 1/6 b = b 2 = 4, c = c 5 = 1/6 b 3 18 c 6 2/3 III. Linear Programming Standard and Slack Forms 20

The Structure of Optimal Solutions Definition A point x is a vertex if it cannot be represented as a strict convex combination of two other points in the feasible set. The set of feasible solutions is a convex set. Theorem If the slack form has an optimal solution, one of them occurs at a vertex. Proof: Let x be an optimal solution which is not a vertex vector d so that x d and x + d are feasible Since A(x + d) = b and Ax = b Ad = 0 W.l.o.g. assume c T d 0 (otherwise replace d by d) Consider x + λd as a function of λ 0 x 2 Case 1: There exists j with d j < 0 x + d Increase λ from 0 to λ until a new entry of x + λd x becomes zero x + λ d feasible, since A(x + λ x d d) = Ax = b and x + λ d 0 c T (x + λ d) = c T x + c T λ d c T x x 1 III. Linear Programming Standard and Slack Forms 21.1

The Structure of Optimal Solutions Definition A point x is a vertex if it cannot be represented as a strict convex combination of two other points in the feasible set. The set of feasible solutions is a convex set. Theorem If the slack form has an optimal solution, one of them occurs at a vertex. Proof: Let x be an optimal solution which is not a vertex vector d so that x d and x + d are feasible Since A(x + d) = b and Ax = b Ad = 0 W.l.o.g. assume c T d 0 (otherwise replace d by d) Consider x + λd as a function of λ 0 x 2 Case 2: For all j, d j 0 x + d x + λd is feasible for all λ 0: A(x + λd) = b and x x + λd x 0 If λ, then c T x d (x + λd) This contradicts the assumption that there exists an optimal solution. x 1 III. Linear Programming Standard and Slack Forms 21.2

Outline Introduction Standard and Slack Forms Formulating Problems as Linear Programs Simplex Algorithm Finding an Initial Solution III. Linear Programming Formulating Problems as Linear Programs 22

Shortest Paths Single-Pair Shortest Path Problem Given: directed graph G = (V, E) with edge weights w : E R, pair of vertices s, t V Goal: Find a path of minimum weight from s to t in G s 6 2 2 a b 5 4 4 2 d e 2 1 3 5 t p = (v 0 = s, v 1,..., v k = t) such that w(p) = k i=1 w(v k 1, v k ) is minimized. c 1 f Shortest Paths as LP maximize subject to this is a maximization problem! d t Recall: When BELLMAN-FORD terminates, all these inequalities are satisfied. d v d u + w(u, v) for each edge (u, v) E, d s = 0. } Solution d satisfies d v = min u : (u,v) E {d u + w(u, v) III. Linear Programming Formulating Problems as Linear Programs 23

Maximum Flow Maximum Flow Problem Given: directed graph G = (V, E) with edge capacities c : E R +, pair of vertices s, t V Goal: Find a maximum flow f : V V R from s to t which satisfies the capacity constraints and flow conservation s 10/10 9/10 4/4 2 4 f = 19 6/8 9/10 0/2 5/6 9/9 10/10 3 5 t Maximum Flow as LP maximize subject to v V fsv v V fvs f uv c(u, v) for each u, v V, v V fvu = v V fuv for each u V \ {s, t}, f uv 0 for each u, v V. III. Linear Programming Formulating Problems as Linear Programs 24

Minimum-Cost Flow Extension of the Maximum Flow Problem Minimum-Cost-Flow Problem Given: directed graph G = (V, E) with capacities c : E R +, pair of vertices s, t V, cost function a : E R +, flow demand of d units Goal: Find a flow f : V V R from s to t with f = d while minimising the total cost (u,v) E a(u, v)fuv incurrred by the flow. 862 Chapter 29 Linear Programming (u,v) E Optimal Solution with total cost: a(u, v)fuv = (2 2)+(5 2)+(3 1)+(7 1)+(1 3) = 27 s c = 5 a = 2 c = 2 a = 5 x y c = 1 a = 3 c = 2 a = 7 c = 4 a = 1 t s 2/5 a = 2 2/2 a = 5 x y 1/1 a = 3 1/2 a = 7 3/4 a = 1 t (a) (b) Figure 29.3 (a) An example of a minimum-cost-flow problem. We denote the capacities by c and the costs by a. Vertexs is the source and vertex t is the sink, and we wish to send 4 units of flow from s to t. (b) Asolutiontotheminimum-costflowprobleminwhich4 units of flow are sent from s to t. Foreachedge,theflowandcapacityarewrittenasflow/capacity. III. Linear Programming Formulating Problems as Linear Programs 25

Minimum-Cost Flow as a LP Minimum Cost Flow as LP minimize (u,v) E a(u, v)fuv subject to f uv c(u, v) for each u, v V, v V fvu v V fuv = 0 for each u V \ {s, t}, v V fsv v V fvs = d, f uv 0 for each u, v V. Real power of Linear Programming comes from the ability to solve new problems! III. Linear Programming Formulating Problems as Linear Programs 26

Outline Introduction Standard and Slack Forms Formulating Problems as Linear Programs Simplex Algorithm Finding an Initial Solution III. Linear Programming Simplex Algorithm 27

Simplex Algorithm: Introduction Simplex Algorithm classical method for solving linear programs (Dantzig, 1947) usually fast in practice although worst-case runtime not polynomial iterative procedure somewhat similar to Gaussian elimination Basic Idea: Each iteration corresponds to a basic solution of the slack form All non-basic variables are 0, and the basic variables are determined from the equality constraints Each iteration converts one slack form into an equivalent one while the objective value will not decrease In that sense, it is a greedy algorithm. Conversion ( pivoting ) is achieved by switching the roles of one basic and one non-basic variable III. Linear Programming Simplex Algorithm 28

Extended Example: Conversion into Slack Form maximize 3x 1 + x 2 + 2x 3 subject to x 1 + x 2 + 3x 3 30 2x 1 + 2x 2 + 5x 3 24 4x 1 + x 2 + 2x 3 36 x 1, x 2, x 3 0 Conversion into slack form z = 3x 1 + x 2 + 2x 3 x 4 = 30 x 1 x 2 3x 3 x 5 = 24 2x 1 2x 2 5x 3 x 6 = 36 4x 1 x 2 2x 3 III. Linear Programming Simplex Algorithm 29

Extended Example: Iteration 1 z = 3x 1 + x 2 + 2x 3 x 4 = 30 x 1 x 2 3x 3 x 5 = 24 2x 1 2x 2 5x 3 x 6 = 36 4x 1 x 2 2x 3 Basic solution: (x 1, x 2,..., x 6 ) = (0, 0, 0, 30, 24, 36) This basic solution is feasible Objective value is 0. III. Linear Programming Simplex Algorithm 30.1

Extended Example: Iteration 1 Increasing the value of x 1 would increase the objective value. z = 3x 1 + x 2 + 2x 3 x 4 = 30 x 1 x 2 3x 3 x 5 = 24 2x 1 2x 2 5x 3 x 6 = 36 4x 1 x 2 2x 3 The third constraint is the tightest and limits how much we can increase x 1. Switch roles of x 1 and x 6 : Solving for x 1 yields: x 1 = 9 x 2 4 x 3 2 x 6 4. Substitute this into x 1 in the other three equations III. Linear Programming Simplex Algorithm 30.2

Extended Example: Iteration 2 Increasing the value of x 3 would increase the objective value. z = 27 + x 1 = 9 x 2 x 4 = 21 3x 2 4 x 5 = 6 3x 2 2 + 4 x 2 4 x 3 5x 3 2 3x 6 2 4 x 3 x 6 2 4 + 4x 3 + Basic solution: (x 1, x 2,..., x 6 ) = (9, 0, 0, 21, 6, 0) with objective value 27 x 6 4 x 6 2 III. Linear Programming Simplex Algorithm 30.3

Extended Example: Iteration 2 z = 27 + x 1 = 9 x 2 x 4 = 21 3x 2 4 x 5 = 6 3x 2 2 + 4 x 2 4 x 3 5x 3 2 3x 6 2 4 x 3 x 6 2 4 + 4x 3 + The third constraint is the tightest and limits how much we can increase x 3. x 6 4 x 6 2 Switch roles of x 3 and x 5: Solving for x 3 yields: x 3 = 3 2 3x 2 8 x5 4 x 6 8. Substitute this into x 3 in the other three equations III. Linear Programming Simplex Algorithm 30.4

Extended Example: Iteration 3 Increasing the value of x 2 would increase the objective value. z = 111 4 + x 1 = 33 4 x 3 = x 4 = x 2 16 x 2 16 3 2 3x 2 8 69 4 + 3x 2 16 x 5 8 11x 6 16 + x 5 5x 6 8 16 x 5 x + 6 4 8 + 5x5 x 6 8 16 Basic solution: (x 1, x 2,..., x 6 ) = ( 33 4, 0, 3 2, 69 4, 0, 0) with objective value 111 4 = 27.75 III. Linear Programming Simplex Algorithm 30.5

Extended Example: Iteration 3 z = 111 4 + x 1 = 33 4 x 3 = x 4 = x 2 16 x 2 16 3 2 3x 2 8 69 4 + 3x 2 16 x 5 8 11x 6 16 + x 5 5x 6 8 16 x 5 x + 6 4 8 + 5x5 x 6 8 16 The second constraint is the tightest and limits how much we can increase x 2. Switch roles of x 2 and x 3 : Solving for x 2 yields: x 2 = 4 8x 3 3 2x5 3 + x 6 3. Substitute this into x 2 in the other three equations III. Linear Programming Simplex Algorithm 30.6

Extended Example: Iteration 4 All coefficients are negative, and hence this basic solution is optimal! z = 28 x 1 = 8 + x 3 6 x 3 + 6 x 2 = 4 8x 3 3 x 4 = 18 x 3 2 + x 5 2x 6 6 3 x 5 x 6 6 3 2x5 x + 6 3 3 x 5 2 Basic solution: (x 1, x 2,..., x 6 ) = (8, 4, 0, 18, 0, 0) with objective value 28 III. Linear Programming Simplex Algorithm 30.7

Extended Example: Visualization of SIMPLEX x 3 (0, 0, 4.8) 9.6 x 2 (0, 12, 0) 12 (0, 0, 0) 0 (8.25, 0, 1.5) 27.75 (9, 0, 0) 27 (8, 4, 0) 28 x 1 Exercise: How many basic solutions (including non-feasible ones) are there? III. Linear Programming Simplex Algorithm 31

Extended Example: Alternative Runs (1/2) z = 3x 1 + x 2 + 2x 3 x 4 = 30 x 1 x 2 3x 3 x 5 = 24 2x 1 2x 2 5x 3 x 6 = 36 4x 1 x 2 2x 3 Switch roles of x 2 and x 5 z = 12 + 2x 1 x 3 2 x 5 2 x 2 = 12 x 1 x 4 = 18 x 2 x 6 = 24 3x 1 + 5x 3 2 x 3 2 x 3 2 + + x 5 2 x 5 2 x 5 2 Switch roles of x 1 and x 6 z = 28 x 1 = 8 + x 3 6 x 3 6 + x 5 6 x 5 6 2x 6 3 x 6 3 x 2 = 4 x 4 = 18 8x 3 3 x 3 2 + 2x 5 3 x 5 2 + x 6 3 III. Linear Programming Simplex Algorithm 32

Extended Example: Alternative Runs (2/2) z = 3x 1 + x 2 + 2x 3 x 4 = 30 x 1 x 2 3x 3 x 5 = 24 2x 1 2x 2 5x 3 x 6 = 36 4x 1 x 2 2x 3 Switch roles of x 3 and x 5 z = x 4 = x 3 = x 6 = 48 5 + 78 5 + 24 5 132 5 11x 1 5 + x 1 5 + 2x 1 5 16x 1 5 x 2 5 x 2 5 + 2x 2 5 x 2 5 + 2x 5 5 3x 5 5 x 5 5 2x 3 5 Switch roles of x 1 and x 6 Switch roles of x 2 and x 3 z = x 1 = x 3 = x 4 = 111 4 33 4 3 2 69 4 + + x 2 16 x 2 16 3x 2 8 3x 2 16 + + x 5 8 x 5 8 x 5 4 5x 5 8 + 11x 6 16 5x 6 16 x 6 8 x 6 16 z = 28 x 1 = 8 + x 2 = 4 x 4 = 18 x 3 6 x 3 6 8x 3 3 x 3 2 + + x 5 6 x 5 6 2x 5 3 x 5 2 + 2x 6 3 x 6 3 x 6 3 III. Linear Programming Simplex Algorithm 33

. yn; yb; ya; b; y yc; y/ describing the new slack form. (Recall again that the entries of the mn matrices A and ya are actually the negatives of the coefficients that appear in the slack form.) The Pivot Step Formally PIVOT.N; B; A; b; c; ;l;e/ 1 // Compute the coefficients of the equation for new basic variable x e. 2 let ya be a new m n matrix 3 be y D b l =a le 4 for each j 2 N feg Need that a le 0! 5 ya ej D a lj =a le 6 ya el D 1=a le 7 // Compute the coefficients of the remaining constraints. 8 for each i 2 B flg 9 bi y D b i a iebe y 10 for each j 2 N feg 11 ya ij D a ij a ie ya ej 12 ya il D a ie ya el 13 // Compute the objective function. 14 y D C c ebe y 15 for each j 2 N feg 16 yc j D c j c e ya ej 17 yc l D c e ya el 18 // Compute new sets of basic and nonbasic variables. 19 yn D N feg [ flg 20 yb D B flg [ feg 21 return. yn; yb; ya; b; y yc; y/ Rewrite tight equation for enterring variable x e. Substituting x e into other equations. Substituting x e into objective function. Update non-basic and basic variables PIVOT works as follows. Lines 3 6 compute the coefficients in the new equation for x e by rewriting the equation that has x l on the left-hand side to instead have x e III. Linear Programming Simplex Algorithm 34

Effect of the Pivot Step Lemma 29.1 Consider a call to PIVOT(N, B, A, b, c, v, l, e) in which a le 0. Let the values returned from the call be ( N, B, Â, b, ĉ, v), and let x denote the basic solution after the call. Then 1. x j = 0 for each j N. 2. x e = b l /a le. 3. x i = b i a ie be for each i B \ {e}. Proof: 1. holds since the basic solution always sets all non-basic variables to zero. 2. When we set each non-basic variable to 0 in a constraint x i = b i j N â ij x j, we have x i = b i for each i B. Hence x e = b e = b l /a le. 3. After the substituting in the other constraints, we have x i = b i = b i a ie be. III. Linear Programming Simplex Algorithm 35

Formalizing the Simplex Algorithm: Questions Questions: How do we determine whether a linear program is feasible? What do we do if the linear program is feasible, but the initial basic solution is not feasible? How do we determine whether a linear program is unbounded? How do we choose the entering and leaving variables? Example before was a particularly nice one! III. Linear Programming Simplex Algorithm 36

Theprocedure SIMPLEX takes as input a linear program in standard form, as just described. It returns an n-vector Nx D. Nx j / that is an optimal solution to the linear program described in (29.19) (29.21). The formal procedure SIMPLEX SIMPLEX.A; b; c/ Returns a slack form with a 1.N; B; A; b; c; / D INITIALIZE-SIMPLEX.A; b; c/ feasible basic solution (if it exists) 2 let be a new vector of length mn 3 while some index j 2 N has c j >0 4 choose anindex e 2 N for which c e >0 Main Loop: 5 for each index i 2 B terminates if all coefficients in 6 if a ie >0 objective function are negative 7 i D b i =a ie Line 4 picks enterring variable 8 else i D1 x e with negative coefficient 9 choose anindex l 2 B that minimizes i Lines 6 9 pick the tightest 10 if l == 1 constraint, associated with x l 11 return unbounded Line 11 returns unbounded if 12 else.n;b;a;b;c;/ D PIVOT.N;B;A;b;c;;l;e/ there are no constraints 13 for i D 1 to n 14 if i 2 B Line 12 calls PIVOT, switching 15 Nx i D b roles of x l and x e i 16 else Nx i D 0 17 return. Nx 1 ; Nx 2 ;:::; Nx n / Return corresponding solution. The SIMPLEX procedure works as follows. In line 1, it calls the procedure INITIALIZE-SIMPLEX.A; b; c/, describedabove,whicheitherdeterminesthatthe linear program is infeasible or returns a slack form for which the basic solution is feasible. The while loop of lines 3 12 forms the main part of the algorithm. If all coefficients in the objective function are negative, then the while loop terminates. Otherwise, line 4 selects a variable x e,whosecoefficientintheobjectivefunction is positive, as the entering variable. Although we may choose any such variable as III. Linear Programming Simplex Algorithm 37.1

Theprocedure SIMPLEX takes as input a linear program in standard form, as just described. It returns an n-vector Nx D. Nx j / that is an optimal solution to the linear program described in (29.19) (29.21). The formal procedure SIMPLEX SIMPLEX.A; b; c/ 1.N; B; A; b; c; / D INITIALIZE-SIMPLEX.A; b; c/ 2 let be a new vector of length mn 3 while some index j 2 N has c j >0 4 choose anindex e 2 N for which c e >0 5 for each index i 2 B 6 if a ie >0 7 i D b i =a ie 8 else i D1 9 choose anindex l 2 B that minimizes i 10 if l == 1 11 return unbounded Proof 12is based else.n;b;a;b;c;/ on the following D PIVOT.N;B;A;b;c;;l;e/ three-part loop invariant: 13 for i D 1 to n 1. the 14 slackif iform 2 B is always equivalent to the one returned by INITIALIZE-SIMPLEX, 15 Nx i D b 2. for each i B, we i have b i 0, 16 else Nx i D 0 3. the 17 basic return solution. Nx 1 ; Nx 2 ;:::; associated Nx n / with the (current) slack form is feasible. The SIMPLEX Lemma 29.2 procedure works as follows. In line 1, it calls the procedure INITIALIZE-SIMPLEX.A; Suppose the call to b; c/, describedabove,whicheitherdeterminesthatthe INITIALIZE-SIMPLEX in line 1 returns a slack form for which linear the basic program solution is infeasible is feasible. or returns Then a slack if form for which the basic solution is SIMPLEX returns a solution, it is a feasible feasible. solution. The If while loop of lines 3 12 forms the main part of the algorithm. If all SIMPLEX returns unbounded, the linear program is unbounded. coefficients in the objective function are negative, then the while loop terminates. Otherwise, line 4 selects a variable x e,whosecoefficientintheobjectivefunction is positive, as the entering variable. Although we may choose any such variable as III. Linear Programming Simplex Algorithm 37.2

Termination Degeneracy: One iteration of SIMPLEX leaves the objective value unchanged. z = x 1 + x 2 + x 3 x 4 = 8 x 1 x 2 x 5 = x 2 x 3 Pivot with x 1 entering and x 4 leaving z = 8 + x 3 x 4 x 1 = 8 x 2 x 4 x 5 = x 2 x 3 Cycling: If additionally slack at two iterations are identical, SIMPLEX fails to terminate! Pivot with x 3 entering and x 5 leaving z = 8 + x 2 x 4 x 5 x 1 = 8 x 2 x 4 x 3 = x 2 x 5 III. Linear Programming Simplex Algorithm 38

Termination and Running Time It is theoretically possible, but very rare in practice. Cycling: SIMPLEX may fail to terminate. Anti-Cycling Strategies 1. Bland s rule: Choose entering variable with smallest index 2. Random rule: Choose entering variable uniformly at random 3. Perturbation: Perturb the input slightly so that it is impossible to have two solutions with the same objective value Lemma 29.7 Replace each b i by b i = b i + ɛ i, where ɛ i ɛ i+1 are all small. Assuming INITIALIZE-SIMPLEX returns a slack form for which the basic solution is feasible, SIMPLEX either reports that the program is unbounded or returns a feasible solution in at most ( ) n+m m iterations. Every set B of basic variables uniquely determines a slack form, and there are at most ( ) n+m m unique slack forms. III. Linear Programming Simplex Algorithm 39

Outline Introduction Standard and Slack Forms Formulating Problems as Linear Programs Simplex Algorithm Finding an Initial Solution III. Linear Programming Finding an Initial Solution 40

Finding an Initial Solution maximize 2x 1 x 2 subject to 2x 1 x 2 2 x 1 5x 2 4 x 1, x 2 0 Conversion into slack form z = 2x 1 x 2 x 3 = 2 2x 1 + x 2 x 4 = 4 x 1 + 5x 2 Basic solution (x 1, x 2, x 3, x 4 ) = (0, 0, 2, 4) is not feasible! III. Linear Programming Finding an Initial Solution 41

Geometric Illustration maximize 2x 1 x 2 subject to 2x 1 x 2 2 x 1 5x 2 4 x 1, x 2 0 x 2 2x 1 x 2 2 Questions: How to determine whether there is any feasible solution? If there is one, how to determine an initial basic solution? x 1 5x 2 4 x 1 III. Linear Programming Finding an Initial Solution 42

Formulating an Auxiliary Linear Program maximize n j=1 c jx j subject to n j=1 a ijx j b i for i = 1, 2,..., m, x j 0 for j = 1, 2,..., n Formulating an Auxiliary Linear Program maximize x 0 subject to Lemma 29.11 n j=1 a ijx j x 0 b i for i = 1, 2,..., m, x j 0 for j = 0, 1,..., n Let L aux be the auxiliary LP of a linear program L in standard form. Then L is feasible if and only if the optimal objective value of L aux is 0. Proof. : Suppose L has a feasible solution x = (x 1, x 2,..., x n) x 0 = 0 combined with x is a feasible solution to L aux with objective value 0. Since x 0 0 and the objective is to maximize x 0, this is optimal for L aux : Suppose that the optimal objective value of L aux is 0 Then x 0 = 0, and the remaining solution values (x 1, x 2,..., x n) satisfy L. III. Linear Programming Finding an Initial Solution 43

maximize x 0,thissolutionmustbeoptimalforL aux. Conversely, suppose that the optimal objective value of L aux is 0. ThenNx 0 D 0, INITIALIZE-SIMPLEX and the remaining solution values of Nx satisfy the constraints of L. We now describe our strategy to find an initial basic feasible solution for a linear program L in standard form: Test solution with N = {1, 2,..., n}, B = {n + 1, n + INITIALIZE-SIMPLEX.A; b; c/ 2,..., n + m}, x i = b i for i B, x i = 0 otherwise. 1 let k be the index of the minimum b i 2 if b k 0 // is the initial basic solution feasible? 3 return.f1; 2; : : : ; ng ; fn C 1; n C 2;: : : ;n C mg ;A;b;c;0/ 4 form L aux by adding x 0 to the left-hand side of each constraint and setting the objective function to x 0 5 let.n; B; A; b; c; / be the resulting slack form for L aux l will be the leaving variable so 6 l D n C k that x l has the most negative value. 7 // L aux has n C 1 nonbasic variables and m basic variables. 8.N; B; A; b; c; / D PIVOT.N; B; A; b; c; ;l;0/ Pivot step with x l leaving and x 0 entering. 9 // The basic solution is now feasible for L aux. 10 iterate the while loop of lines 3 12 of SIMPLEX until an optimal solution to L aux is found 11 if the optimal solution to L aux sets Nx 0 to 0 This pivot step does not change 12 if Nx 0 is basic 13 perform one (degenerate) pivot to make it nonbasic the value of any variable. 14 from the final slack form of L aux,removex 0 from the constraints and restore the original objective function of L,butreplaceeachbasic variable in this objective function by the right-hand side of its associated constraint 15 return the modified final slack form 16 else return infeasible III. Linear Programming Finding an Initial Solution 44

Example of INITIALIZE-SIMPLEX (1/3) maximize 2x 1 x 2 subject to 2x 1 x 2 2 x 1 5x 2 4 x 1, x 2 0 Formulating the auxiliary linear program maximize x 0 subject to 2x 1 x 2 x 0 2 x 1 5x 2 x 0 4 x 1, x 2, x 0 0 Basic solution (0, 0, 0, 2, 4) not feasible! Converting into slack form z = x 0 x 3 = 2 2x 1 + x 2 + x 0 x 4 = 4 x 1 + 5x 2 + x 0 III. Linear Programming Finding an Initial Solution 45

Example of INITIALIZE-SIMPLEX (2/3) z = x 0 x 3 = 2 2x 1 + x 2 + x 0 x 4 = 4 x 1 + 5x 2 + x 0 Pivot with x 0 entering and x 4 leaving z = 4 x 1 + 5x 2 x 4 x 0 = 4 + x 1 5x 2 + x 4 x 3 = 6 x 1 4x 2 + x 4 Basic solution (4, 0, 0, 6, 0) is feasible! Pivot with x 2 entering and x 0 leaving z = x 0 x 2 = 4 x 0 x + 1 + x 4 5 5 5 5 x 3 = 14 + 4x 0 9x 1 + x 4 5 5 5 5 Optimal solution has x 0 = 0, hence the initial problem was feasible! III. Linear Programming Finding an Initial Solution 46

Example of INITIALIZE-SIMPLEX (3/3) 2x 1 x 2 = 2x 1 ( 4 5 x 0 5 + x 1 5 + x 4 5 ) z = x 0 x 2 = 4 x 0 x + 1 + x 4 5 5 5 5 x 3 = 14 + 4x 0 9x 1 + x 4 5 5 5 5 Set x 0 = 0 and express objective function by non-basic variables z = 4 + 9x 1 x 4 5 5 5 x 2 = 4 x + 1 + x 4 5 5 5 x 3 = 14 9x 1 + x 4 5 5 5 Basic solution (0, 4, 14, 0), which is feasible! 5 5 Lemma 29.12 If a linear program L has no feasible solution, then INITIALIZE-SIMPLEX returns infeasible. Otherwise, it returns a valid slack form for which the basic solution is feasible. III. Linear Programming Finding an Initial Solution 47

Fundamental Theorem of Linear Programming Theorem 29.13 (Fundamental Theorem of Linear Programming) Any linear program L, given in standard form, either 1. has an optimal solution with a finite objective value, 2. is infeasible, or 3. is unbounded. If L is infeasible, SIMPLEX returns infeasible. If L is unbounded, SIMPLEX returns unbounded. Otherwise, SIMPLEX returns an optimal solution with a finite objective value. Proof requires the concept of duality, which is not covered in this course (for details see CLRS3, Chapter 29.4) III. Linear Programming Finding an Initial Solution 48

Workflow for Solving Linear Programs Linear Program (in any form) Standard Form Slack Form No Feasible Solution INITIALIZE-SIMPLEX terminates Feasible Basic Solution INITIALIZE-SIMPLEX followed by SIMPLEX LP unbounded SIMPLEX terminates LP bounded SIMPLEX returns optimum III. Linear Programming Finding an Initial Solution 49

Linear Programming and Simplex: Summary and Outlook Linear Programming extremely versatile tool for modelling problems of all kinds basis of Integer Programming, to be discussed in later lectures Simplex Algorithm In practice: usually terminates in polynomial time, i.e., O(m + n) In theory: even with anti-cycling may need exponential time Research Problem: Is there a pivoting rule which makes SIMPLEX a polynomial-time algorithm? Polynomial-Time Algorithms Interior-Point Methods: traverses the interior of the feasible set of solutions (not just vertices!) x 3 x 3 x 2 x 2 x 1 x 1 III. Linear Programming Finding an Initial Solution 50