The Simplex Algorithm. Chapter 5. Decision Procedures. An Algorithmic Point of View. Revision 1.0

Similar documents
Advanced Operations Research Techniques IE316. Quiz 1 Review. Dr. Ted Ralphs

DM545 Linear and Integer Programming. Lecture 2. The Simplex Method. Marco Chiarandini

Linear Optimization. Andongwisye John. November 17, Linkoping University. Andongwisye John (Linkoping University) November 17, / 25

Some Advanced Topics in Linear Programming

Solutions for Operations Research Final Exam

CSC 8301 Design & Analysis of Algorithms: Linear Programming

Part 4. Decomposition Algorithms Dantzig-Wolf Decomposition Algorithm

Section Notes 5. Review of Linear Programming. Applied Math / Engineering Sciences 121. Week of October 15, 2017

Advanced Operations Research Techniques IE316. Quiz 2 Review. Dr. Ted Ralphs

Linear Programming. Linear programming provides methods for allocating limited resources among competing activities in an optimal way.

VARIANTS OF THE SIMPLEX METHOD

How to Solve a Standard Maximization Problem Using the Simplex Method and the Rowops Program

Outline. CS38 Introduction to Algorithms. Linear programming 5/21/2014. Linear programming. Lecture 15 May 20, 2014

Linear Programming. Course review MS-E2140. v. 1.1

The Simplex Algorithm

NATCOR Convex Optimization Linear Programming 1

4.1 The original problem and the optimal tableau

What is linear programming (LP)? NATCOR Convex Optimization Linear Programming 1. Solving LP problems: The standard simplex method

Introduction to Operations Research

The Simplex Algorithm

Introduction to Mathematical Programming IE496. Final Review. Dr. Ted Ralphs

Optimization of Design. Lecturer:Dung-An Wang Lecture 8

Math 5593 Linear Programming Lecture Notes

5 The Theory of the Simplex Method

4.1 Graphical solution of a linear program and standard form

BCN Decision and Risk Analysis. Syed M. Ahmed, Ph.D.

3. The Simplex algorithmn The Simplex algorithmn 3.1 Forms of linear programs

Lecture notes on the simplex method September We will present an algorithm to solve linear programs of the form. maximize.

Part 1. The Review of Linear Programming The Revised Simplex Method

An iteration of the simplex method (a pivot )

Chapter 4: The Mechanics of the Simplex Method

Lecture 4: Linear Programming

Civil Engineering Systems Analysis Lecture XV. Instructor: Prof. Naveen Eluru Department of Civil Engineering and Applied Mechanics

A PARAMETRIC SIMPLEX METHOD FOR OPTIMIZING A LINEAR FUNCTION OVER THE EFFICIENT SET OF A BICRITERIA LINEAR PROBLEM. 1.

Finite Math Linear Programming 1 May / 7

Linear Programming Terminology

Lesson 17. Geometry and Algebra of Corner Points

16.410/413 Principles of Autonomy and Decision Making

Discrete Optimization 2010 Lecture 5 Min-Cost Flows & Total Unimodularity

Math 414 Lecture 30. The greedy algorithm provides the initial transportation matrix.

COLUMN GENERATION IN LINEAR PROGRAMMING

MA4254: Discrete Optimization. Defeng Sun. Department of Mathematics National University of Singapore Office: S Telephone:

CS 473: Algorithms. Ruta Mehta. Spring University of Illinois, Urbana-Champaign. Ruta (UIUC) CS473 1 Spring / 29

Discrete Optimization. Lecture Notes 2

Linear programming II João Carlos Lourenço

Lecture 9: Linear Programming

POLYHEDRAL GEOMETRY. Convex functions and sets. Mathematical Programming Niels Lauritzen Recall that a subset C R n is convex if

MATH 310 : Degeneracy and Geometry in the Simplex Method

Section Notes 4. Duality, Sensitivity, and the Dual Simplex Algorithm. Applied Math / Engineering Sciences 121. Week of October 8, 2018

Chapter 1 Linear Programming. Paragraph 4 The Simplex Algorithm

LP Geometry: outline. A general LP. minimize x c T x s.t. a T i. x b i, i 2 M 1 a T i x = b i, i 2 M 3 x j 0, j 2 N 1. where

Convex Optimization. Chapter 1 - chapter 2.2

Read: H&L chapters 1-6

LP-Modelling. dr.ir. C.A.J. Hurkens Technische Universiteit Eindhoven. January 30, 2008

Conic Duality. yyye

Lecture Notes 2: The Simplex Algorithm

AM 121: Intro to Optimization Models and Methods Fall 2017

3 INTEGER LINEAR PROGRAMMING

ISE203 Optimization 1 Linear Models. Dr. Arslan Örnek Chapter 4 Solving LP problems: The Simplex Method SIMPLEX

CSE 40/60236 Sam Bailey

CE 601: Numerical Methods Lecture 5. Course Coordinator: Dr. Suresh A. Kartha, Associate Professor, Department of Civil Engineering, IIT Guwahati.

Introductory Operations Research

Lecture 2 - Introduction to Polytopes

Simulation. Lecture O1 Optimization: Linear Programming. Saeed Bastani April 2016

CS675: Convex and Combinatorial Optimization Spring 2018 The Simplex Algorithm. Instructor: Shaddin Dughmi

Graphs and Network Flows IE411. Lecture 20. Dr. Ted Ralphs

Improved Gomory Cuts for Primal Cutting Plane Algorithms

Easter Term OPTIMIZATION

Farming Example. Lecture 22. Solving a Linear Program. withthe Simplex Algorithm and with Excel s Solver

Chapter 15 Introduction to Linear Programming

Linear Programming Duality and Algorithms

Copyright 2007 Pearson Addison-Wesley. All rights reserved. A. Levitin Introduction to the Design & Analysis of Algorithms, 2 nd ed., Ch.

Linear programming and duality theory

Name: THE SIMPLEX METHOD: STANDARD MAXIMIZATION PROBLEMS

60 2 Convex sets. {x a T x b} {x ã T x b}

Introduction. Linear because it requires linear functions. Programming as synonymous of planning.

Convex Optimization. 2. Convex Sets. Prof. Ying Cui. Department of Electrical Engineering Shanghai Jiao Tong University. SJTU Ying Cui 1 / 33

Solving Linear Programs Using the Simplex Method (Manual)

Generalized Network Flow Programming

Linear Programming Motivation: The Diet Problem

Parallel Implementations of Gaussian Elimination

MATH 423 Linear Algebra II Lecture 17: Reduced row echelon form (continued). Determinant of a matrix.

Aim. Structure and matrix sparsity: Part 1 The simplex method: Exploiting sparsity. Structure and matrix sparsity: Overview

Chapter II. Linear Programming

Introduction to Optimization Problems and Methods

CSE 460. Today we will look at" Classes of Optimization Problems" Linear Programming" The Simplex Algorithm"

Lecture The Ellipsoid Algorithm

Unit.9 Integer Programming

CASE STUDY. fourteen. Animating The Simplex Method. case study OVERVIEW. Application Overview and Model Development.

hp calculators hp 39g+ & hp 39g/40g Using Matrices How are matrices stored? How do I solve a system of equations? Quick and easy roots of a polynomial

Chapter 3: Towards the Simplex Method for Efficient Solution of Linear Programs

Introduction to Operations Research Prof. G. Srinivasan Department of Management Studies Indian Institute of Technology, Madras

4 LINEAR PROGRAMMING (LP) E. Amaldi Fondamenti di R.O. Politecnico di Milano 1

New Directions in Linear Programming

THE simplex algorithm [1] has been popularly used

The Ascendance of the Dual Simplex Method: A Geometric View

MEI Conference 2009: D2

THEORY OF LINEAR AND INTEGER PROGRAMMING

Department of Mathematics Oleg Burdakov of 30 October Consider the following linear programming problem (LP):

Numerical Algorithms

Transcription:

The Simplex Algorithm Chapter 5 Decision Procedures An Algorithmic Point of View D.Kroening O.Strichman Revision 1.0

Outline 1 Gaussian Elimination 2 Satisfiability with Simplex 3 General Simplex Form 4 Simplex Basics 5 The General Simplex Algorithm Decision Procedures The Simplex Algorithm 2

Gaussian Elimination Given a linear system Ax = b a 11 a 12... a 1k a 21 a 22... a 2k...... x 1 x 2. = b 1 b 2. a k1 a k2... a kk x k b k Manipulate A b to obtain an upper-triangular form a 11 a 12... a 1k b 0 a 22... a 1 2k b...... 2. 0 0... a kk b k Decision Procedures The Simplex Algorithm 3

Gaussian Elimination Then, solve backwards from k s row according to: x i = 1 a (b i ii k j=i+1 a ijx j ) Decision Procedures The Simplex Algorithm 4

Example 1 2 1 2 3 4 4 1 8 x 1 x 2 x 3 = 6 3 9 1 2 1 2 3 4 4 1 8 6 3 9 Decision Procedures The Simplex Algorithm 5

Example 1 2 1 2 3 4 4 1 8 x 1 x 2 x 3 = 6 3 9 R3 = ( 4, 1, 8 9 ) 4R1 = ( 4, 8, 4 24 ) R3 + = 4R1 1 2 1 2 3 4 4 1 8 6 3 9 1 2 1 2 3 4 0 9 12 6 3 15 Decision Procedures The Simplex Algorithm 5

Example 1 2 1 2 3 4 4 1 8 x 1 x 2 x 3 = 6 3 9 R3 = ( 4, 1, 8 9 ) 4R1 = ( 4, 8, 4 24 ) R3 + = 4R1 1 2 1 2 3 4 4 1 8 6 3 9 1 2 1 2 3 4 0 9 12 6 3 15 R2 = ( 2, 3, 4 3 ) 2R1 = ( 2, 4, 2 12 ) R2 + = 2R1 1 2 1 0 7 6 0 9 12 6 15 15 Decision Procedures The Simplex Algorithm 5

Example 1 2 1 2 3 4 4 1 8 x 1 x 2 x 3 = 6 3 9 R3 = ( 4, 1, 8 9 ) 4R1 = ( 4, 8, 4 24 ) R3 + = 4R1 1 2 1 2 3 4 4 1 8 6 3 9 1 2 1 2 3 4 0 9 12 6 3 15 R2 = ( 2, 3, 4 3 ) 2R1 = ( 2, 4, 2 12 ) R2 + = 2R1 1 2 1 0 7 6 0 9 12 6 15 15 R3 = ( 0, 9, 12 15 ) 9 7 R2 = ( 0, 9, 6 9 15 9 7 7 ) R3 + = 9 7 R2 1 2 1 0 7 6 0 0 30 7 6 15 30 7 Decision Procedures The Simplex Algorithm 5

Example 1 2 1 2 3 4 4 1 8 x 1 x 2 x 3 = 6 3 9 R3 = ( 4, 1, 8 9 ) 4R1 = ( 4, 8, 4 24 ) R3 + = 4R1 1 2 1 2 3 4 4 1 8 6 3 9 1 2 1 2 3 4 0 9 12 6 3 15 R2 = ( 2, 3, 4 3 ) 2R1 = ( 2, 4, 2 12 ) R2 + = 2R1 1 2 1 0 7 6 0 9 12 6 15 15 R3 = ( 0, 9, 12 15 ) 9 7 R2 = ( 0, 9, 6 9 15 9 7 7 ) R3 + = 9 7 R2 Now: x 3 = 1, x 2 = 3, x 1 = 1. Problem solved! 1 2 1 0 7 6 0 0 30 7 Decision Procedures The Simplex Algorithm 5 6 15 30 7

Satisfiability with Simplex Simplex was originally designed for solving the optimization problem: max c x s.t. A x b, x 0 We are only interested in the feasibility problem = satisfiability problem. Decision Procedures The Simplex Algorithm 6

General Simplex We will learn a variant called general simplex. Very suitable for solving the satisfiability problem fast. Decision Procedures The Simplex Algorithm 7

General Simplex We will learn a variant called general simplex. Very suitable for solving the satisfiability problem fast. The input: A x b A is a m n coefficient matrix The problem variables are x = x 1,..., x n First step: convert the input to general form Decision Procedures The Simplex Algorithm 7

General Form Definition (General Form) A x = 0 and m l i s i u i i=1 A combination of Linear equalities of the form i a ix i = 0 Lower and upper bounds on variables Decision Procedures The Simplex Algorithm 8

Transformation to General Form Replace i a ix i b j (where {=,, }) with i a ix i s j = 0 and s j b j. s 1,..., s m are called the additional variables Decision Procedures The Simplex Algorithm 9

Example 1 Convert x + y 2! Decision Procedures The Simplex Algorithm 10

Example 1 Convert x + y 2! Result: x + y s 1 = 0 s 1 2 It is common to keep the conjunctions implicit Decision Procedures The Simplex Algorithm 10

Example 2 Convert x +y 2 2x y 0 x +2y 1 Decision Procedures The Simplex Algorithm 11

Example 2 Convert x +y 2 2x y 0 x +2y 1 Result: x +y s 1 = 0 2x y s 2 = 0 x +2y s 3 = 0 s 1 2 s 2 0 s 3 1 Decision Procedures The Simplex Algorithm 11

Geometrical Interpretation Linear inequality constraints, geometrically, define a convex polyhedron. c Wikipedia Decision Procedures The Simplex Algorithm 12

Geometrical Interpretation Our example from before: y 2x y 0 x +y 2 2x y 0 x +2y 1 3 2 1 x + 2y 0 (C) x + y 2 (A) (B) 1 2 3 4 x Decision Procedures The Simplex Algorithm 13

Matrix Form Recall the general form: A x = 0 and m i=1 l i s i u i A is now an m (n + m) matrix due to the additional variables. x +y s 1 = 0 2x y s 2 = 0 x +2y s 3 = 0 s 1 2 s 2 0 s 3 1 x y s 1 s 2 s 3 1 1 1 0 0 2 1 0 1 0 1 2 0 0 1 Decision Procedures The Simplex Algorithm 14

The Tableau The diagonal part is inherent to the general form: x y s 1 s 2 s 3 1 1 1 0 0 2 1 0 1 0 1 2 0 0 1 Instead, we can write: s 1 s 2 s 3 x y 2 1 1 1 1 2 Decision Procedures The Simplex Algorithm 15

The Tableau The tableaux changes throughout the algorithm, but maintains its m n structure Distinguish basic and nonbasic variables Basic variables s 1 s 2 s 3 x y 2 1 1 1 1 2 Nonbasic variables Initially, basic variables = the additional variables Decision Procedures The Simplex Algorithm 16

The Tableau Notation: B N the basic variables the nonbasic variables The tableaux is simply a different notation for the system (x i = ) a ij x j x i B x j N The basic variables are also called the dependent variables. Decision Procedures The Simplex Algorithm 17

Data Structures Simplex maintains: The tableau, an assignment α to all variables, an assignment to the bounds. Initially, B = additional variables, N = problem variables, α(xi) = 0 for i {1,..., n + m} Decision Procedures The Simplex Algorithm 18

Invariants Two invariants are maintained throughout: 1 A x = 0 2 All nonbasic variables satisfy their bounds The basic variables need not satisy their bounds Decision Procedures The Simplex Algorithm 19

Invariants Two invariants are maintained throughout: 1 A x = 0 2 All nonbasic variables satisfy their bounds The basic variables need not satisy their bounds Can you see why these invariants are maintained initially? We should check that they are indeed maintained Decision Procedures The Simplex Algorithm 19

Invariants The initial assignment satisfies A x = 0 If the bounds of all basic variables are satisfied by α, return Satisfiable Otherwise... pivot. Decision Procedures The Simplex Algorithm 20

Pivoting 1 Find a basic variable x i that violates its bounds. Suppose that α(x i ) < l i. 2 Find a nonbasic variable x j such that a ij > 0 and α(x j ) < u j, or a ij < 0 and α(x j ) > l j. Why? Decision Procedures The Simplex Algorithm 21

Pivoting 1 Find a basic variable x i that violates its bounds. Suppose that α(x i ) < l i. 2 Find a nonbasic variable x j such that a ij > 0 and α(x j ) < u j, or a ij < 0 and α(x j ) > l j. Why? Such a variable is called suitable. Decision Procedures The Simplex Algorithm 21

Pivoting 1 Find a basic variable x i that violates its bounds. Suppose that α(x i ) < l i. 2 Find a nonbasic variable x j such that a ij > 0 and α(x j ) < u j, or a ij < 0 and α(x j ) > l j. Why? Such a variable is called suitable. 3 If there is no suitable variable, return Unsatisfiable Why? Decision Procedures The Simplex Algorithm 21

Pivoting x i and x j (1) 1 Solve equation i for x j : From: x i = a ij x j + k j a ik x k To: x j = x i a ik x k a ij a ij k j Decision Procedures The Simplex Algorithm 22

Pivoting x i and x j (1) 1 Solve equation i for x j : From: x i = a ij x j + k j a ik x k To: x j = x i a ik x k a ij a ij k j 2 Swap x i and x j, and update the i-th row accordingly From: a i1... a ij... a in To: a i1 a ij... 1 a ij... a in a ij Decision Procedures The Simplex Algorithm 22

Pivoting x i and x j (2) 3 Update all other rows: Replace x j with its equivalent obtained from row i: x j = x i a ik x k a ij a ij k j Decision Procedures The Simplex Algorithm 23

Pivoting x i and x j (2) 3 Update all other rows: Replace x j with its equivalent obtained from row i: x j = x i a ik x k a ij a ij k j 4 Update α as follows: Increase α(x j ) by θ = l i α(x i ) a ij Now x j is a basic variable: it may violate its bounds Update α(x i ) accordingly Q: What is α(x i ) now? Update α for all other basic (dependent) variables Decision Procedures The Simplex Algorithm 23

Pivoting: Example (1) Recall the tableau and constraints in our example: x y s 1 1 1 s 2 2 1 s 3 1 2 2 s 1 0 s 2 1 s 3 Initially, α assigns 0 to all variables = The bounds of s 1 and s 3 are violated Decision Procedures The Simplex Algorithm 24

Pivoting: Example (1) Recall the tableau and constraints in our example: x y s 1 1 1 s 2 2 1 s 3 1 2 2 s 1 0 s 2 1 s 3 Initially, α assigns 0 to all variables = The bounds of s 1 and s 3 are violated We will fix s 1. x is a suitable nonbasic variable for pivoting. It has no upper bound! So now we pivot s 1 with x Decision Procedures The Simplex Algorithm 24

Pivoting: Example (2) x y s 1 1 1 s 2 2 1 s 3 1 2 2 s 1 0 s 2 1 s 3 Decision Procedures The Simplex Algorithm 25

Pivoting: Example (2) x y s 1 1 1 s 2 2 1 s 3 1 2 2 s 1 0 s 2 1 s 3 Solve 1 st row for x: s 1 = x + y x = s 1 y Decision Procedures The Simplex Algorithm 25

Pivoting: Example (2) x y s 1 1 1 s 2 2 1 s 3 1 2 2 s 1 0 s 2 1 s 3 Solve 1 st row for x: s 1 = x + y x = s 1 y Replace x in other rows: s 2 = 2(s 1 y) y s 2 = 2s 1 3y s 3 = (s 1 y) + 2y s 3 = s 1 + 3y Decision Procedures The Simplex Algorithm 25

Pivoting: Example (3) x = s 1 y s 2 = 2s 1 3y s 3 = s 1 + 3y Decision Procedures The Simplex Algorithm 26

Pivoting: Example (3) x = s 1 y s 2 = 2s 1 3y s 3 = s 1 + 3y This results in the following new tableau: s1 y x 1 1 s 2 2 3 s 3 1 3 2 s 1 0 s 2 1 s 3 Decision Procedures The Simplex Algorithm 26

Pivoting: Example (3) x = s 1 y s 2 = 2s 1 3y s 3 = s 1 + 3y This results in the following new tableau: s1 y x 1 1 s 2 2 3 s 3 1 3 2 s 1 0 s 2 1 s 3 What about the assignment? We should increase x by θ = 2 0 1 Hence, α(x) = 0 + 2 = 2 = 2 Now s 1 is equal to its lower bound: α(s1) = 2 Update all the others Decision Procedures The Simplex Algorithm 26

Pivoting: Example (4) The new state: s 1 y x 1 1 s 2 2 3 s 3 1 3 α(x) = 2 α(y) = 0 α(s 1 ) = 2 α(s 2 ) = 4 α(s 3 ) = 2 2 s 1 0 s 2 1 s 3 Decision Procedures The Simplex Algorithm 27

Pivoting: Example (4) The new state: s 1 y x 1 1 s 2 2 3 s 3 1 3 α(x) = 2 α(y) = 0 α(s 1 ) = 2 α(s 2 ) = 4 α(s 3 ) = 2 2 s 1 0 s 2 1 s 3 Now s 3 violates its lower bound Which nonbasic variable is suitable for pivoting? Decision Procedures The Simplex Algorithm 27

Pivoting: Example (4) The new state: s 1 y x 1 1 s 2 2 3 s 3 1 3 α(x) = 2 α(y) = 0 α(s 1 ) = 2 α(s 2 ) = 4 α(s 3 ) = 2 2 s 1 0 s 2 1 s 3 Now s 3 violates its lower bound Which nonbasic variable is suitable for pivoting? That s right... y Decision Procedures The Simplex Algorithm 27

Pivoting: Example (4) The new state: s 1 y x 1 1 s 2 2 3 s 3 1 3 α(x) = 2 α(y) = 0 α(s 1 ) = 2 α(s 2 ) = 4 α(s 3 ) = 2 2 s 1 0 s 2 1 s 3 Now s 3 violates its lower bound Which nonbasic variable is suitable for pivoting? That s right... y We should increase y by θ = 1 ( 2) 3 = 1 Decision Procedures The Simplex Algorithm 27

Pivoting: Example (5) The final state: s 1 s 3 x 2/3 1/3 s 2 1 1 y 1/3 1/3 α(x) = 1 α(y) = 1 α(s 1 ) = 2 α(s 2 ) = 1 α(s 3 ) = 1 2 s 1 0 s 2 1 s 3 All constraints are satisfied. Decision Procedures The Simplex Algorithm 28

Observations I The additional variables: Only additional variables have bounds. These bounds are permanent. Additional variables enter the base only on extreme points (their lower or upper bounds). When entering the base, they shift towards the other bound and possibly cross it (violate it). Decision Procedures The Simplex Algorithm 29

Observations II Q: Can it be that we pivot x i, x j and then pivot x j, x i and thus enter a (local) cycle? Decision Procedures The Simplex Algorithm 30

Observations II Q: Can it be that we pivot x i, x j and then pivot x j, x i and thus enter a (local) cycle? A: No. For example, suppose that a ij > 0. We increased α(x j ) so now α(x i ) = l i. After pivoting, possibly α(x j ) > u j, but a ij = 1/a ij > 0, hence the coefficient of x i is not suitable Decision Procedures The Simplex Algorithm 30

Termination Is termination guaranteed? Decision Procedures The Simplex Algorithm 31

Termination Is termination guaranteed? Not obvious. Perhaps there are bigger cycles. In order to avoid circles, we use Bland s rule: 1 Determine a total order on the variables 2 Choose the first basic variable that violates its bounds, and the first nonbasic suitable variable for pivoting. 3 It can be shown that this guarantees that no base is repeated, which implies termination. Decision Procedures The Simplex Algorithm 31

General simplex With Bland s Rule 1 Transform the system into the general form A x = 0 and m l i s i u i. i=1 2 Set B to be the set of additional variables s 1,..., s m. 3 Construct the tableau for A. 4 Determine a fixed order on the variables. 5 If there is no basic variable that violates its bounds, return Satisfiable. Otherwise, let x i be the first basic variable in the order that violates its bounds. 6 Search for the first suitable nonbasic variable x j in the order for pivoting with x i. If there is no such variable, return Unsatisfiable. 7 Perform the pivot operation on x i and x j. 8 Go to step 5. Decision Procedures The Simplex Algorithm 32