CS Algorithms and Complexity

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

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

Lesson 27 Linear Programming; The Simplex Method

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

Lecture slides by Kevin Wayne

The augmented form of this LP is the following linear system of equations:

Part III: A Simplex pivot

CSC Design and Analysis of Algorithms. LP Shader Electronics Example

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

3 The Simplex Method. 3.1 Basic Solutions

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

Summary of the simplex method

Math Models of OR: Some Definitions

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

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

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

IE 5531: Engineering Optimization I

Introduction to Mathematical Programming IE406. Lecture 21. Dr. Ted Ralphs

Combinatorial optimization problems

Optimization Methods in Management Science

Algorithm Design Strategies V

SOLVING INTEGER LINEAR PROGRAMS. 1. Solving the LP relaxation. 2. How to deal with fractional solutions?

maxz = 3x 1 +4x 2 2x 1 +x 2 6 2x 1 +3x 2 9 x 1,x 2

Prelude to the Simplex Algorithm. The Algebraic Approach The search for extreme point solutions.

Slide 1 Math 1520, Lecture 10

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

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

Today s class. Constrained optimization Linear programming. Prof. Jinbo Bi CSE, UConn. Numerical Methods, Fall 2011 Lecture 12

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

1 Column Generation and the Cutting Stock Problem

Introduction to Linear and Combinatorial Optimization (ADM I)

P, NP, NP-Complete. Ruth Anderson

Linear Programming: Simplex

Topics in Theoretical Computer Science April 08, Lecture 8

min3x 1 + 4x 2 + 5x 3 2x 1 + 2x 2 + x 3 6 x 1 + 2x 2 + 3x 3 5 x 1, x 2, x 3 0.

Optimization (168) Lecture 7-8-9

4/12/2011. Chapter 8. NP and Computational Intractability. Directed Hamiltonian Cycle. Traveling Salesman Problem. Directed Hamiltonian Cycle

Non-Standard Constraints. Setting up Phase 1 Phase 2

Math 354 Summer 2004 Solutions to review problems for Midterm #1

Decision Procedures An Algorithmic Point of View

Section #2: Linear and Integer Programming

Data Structures in Java

Lectures 6, 7 and part of 8

3. THE SIMPLEX ALGORITHM

(tree searching technique) (Boolean formulas) satisfying assignment: (X 1, X 2 )

Systems Analysis in Construction

Gauss-Jordan Elimination for Solving Linear Equations Example: 1. Solve the following equations: (3)

An introductory example

ECE 307 Techniques for Engineering Decisions

(P ) Minimize 4x 1 + 6x 2 + 5x 3 s.t. 2x 1 3x 3 3 3x 2 2x 3 6

The simplex algorithm

Preliminaries and Complexity Theory

REVISION SHEET DECISION MATHS 2 DECISION ANALYSIS

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

Task Assignment. Consider this very small instance: t1 t2 t3 t4 t5 p p p p p

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

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

Distributed Real-Time Control Systems. Lecture Distributed Control Linear Programming

Section Notes 8. Integer Programming II. Applied Math 121. Week of April 5, expand your knowledge of big M s and logical constraints.

Optimization Prof. A. Goswami Department of Mathematics Indian Institute of Technology, Kharagpur. Lecture - 20 Travelling Salesman Problem

15-780: LinearProgramming

Introduction to the Simplex Algorithm Active Learning Module 3

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

Transform and Conquer

Travelling Salesman Problem

The Simplex Method. Formulate Constrained Maximization or Minimization Problem. Convert to Standard Form. Convert to Canonical Form

Computer Science 385 Analysis of Algorithms Siena College Spring Topic Notes: Limitations of Algorithms

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

Section 4.1 Solving Systems of Linear Inequalities

Linear and Integer Programming - ideas

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

21. Solve the LP given in Exercise 19 using the big-m method discussed in Exercise 20.

Week 2. The Simplex method was developed by Dantzig in the late 40-ties.

Homework Assignment 4 Solutions

Week Cuts, Branch & Bound, and Lagrangean Relaxation

3.7 Cutting plane methods

1. Algebraic and geometric treatments Consider an LP problem in the standard form. x 0. Solutions to the system of linear equations

Lecture 2: The Simplex method

CS 350 Algorithms and Complexity

BBM402-Lecture 20: LP Duality

4.4 The Simplex Method and the Standard Minimization Problem

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Algorithms Design & Analysis. Approximation Algorithm

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

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

The Ellipsoid Algorithm

Chapter 1 Linear Programming. Paragraph 5 Duality

February 17, Simplex Method Continued

- Well-characterized problems, min-max relations, approximate certificates. - LP problems in the standard form, primal and dual linear programs

Chapter 11. Approximation Algorithms. Slides by Kevin Wayne Pearson-Addison Wesley. All rights reserved.

Spring 2017 CO 250 Course Notes TABLE OF CONTENTS. richardwu.ca. CO 250 Course Notes. Introduction to Optimization

MATH 445/545 Test 1 Spring 2016

Nondeterministic Polynomial Time

Chapter 4 The Simplex Algorithm Part I

A New Approximation Algorithm for the Asymmetric TSP with Triangle Inequality By Markus Bläser

CS6999 Probabilistic Methods in Integer Programming Randomized Rounding Andrew D. Smith April 2003

CS 350 Algorithms and Complexity

The Simplex Algorithm

III. Linear Programming

Tractable & Intractable Problems

Transcription:

CS 50 - Algorithms and Complexity Linear Programming, the Simplex Method, and Hard Problems Sean Anderson 2/15/18 Portland State University

Table of contents 1. The Simplex Method 2. The Graph Problem to End all (of our) Graph Problems. Dynamic Programming and Time/Space Trade-offs 1

The Simplex Method

Linear Programming Revisited Programming = Planning Systems of n variables, m constraints of form: a 1 x 1 + + a n x n / / = b 2

A Touch of Linear Algebra I m breaking my promise not to do much linear algebra, but don t worry, we don t need much. A few key terms: Linear Combination: a vector Y is a linear combination of vectors X 1, X 2 if a 1 X 1 + + a i X i = Y Linear Independence: a set of vectors is linearly independent if none of its elements are a linear combination of the others Basis: a set of linearly independent vectors in a vector space such that all other vectors are a linear combination of them

Word Problem The Brewer s Problem: suppose an amateur brewer has 4 units of wheat and 6 units of hops. Brewing a normal beer requires 1 unit of each; brewing a ridiculous IPA requires 1 unit of wheat and of hops. But an IPA sells for $5 and a regular beer only sells for $. How much of each should they make? Optimize: z = b + 5a Where: 0 b + a 4 0 b + a 6 4

Geometric This is equivalent to finding the closest point to an m-dimensional hyperplane on the surface of a convex region 5

Vertices Provably, the optimal solution is at a vertex 6

Profit Brewery problem: objective function (0, 2) (12, 28) 1A + 2B = $1600 (26, 14) Beer 1A + 2B = $800 (0, 0) Ale (4, 0) 1A + 2B = $442 16 Source: Kleinberg and Tardos Slides 7

Standard Form The simplex method requires our equations to be actual equations, not inequalities, and a few other things Some changes: Must be maximization problem - if minimization, negate all weights All variables must be positive - negative/free x becomes x 1 x 2 All constraints must be equalities - add slack variables Optimize: z = b + 5a Where: b + a + u = 4 b + a + v = 6 8

Strategy and Tableaus Strategy: find a Basic Feasible Solution - a solution with respect to a given basis The basis is m independent variables, and the solution assumes we maximize them and compute the rest accordingly We build a tableau to track the equations and update with new, adjacent bases 9

Simplex Tableau b a u v Solution u 1 1 1 0 4 v 1 0 1 6 - -5 0 0 0 Translation: our proposed solution is that u = 4 and v = 6. This is a Basic Feasible Solution for the basis of (u, v), and represents a vertex where b, a = 0. Bottom row: negative values represent the weights of the variables we could increase, and the last column represents the objective value of this solution. Increasing b to 6 would yield z = 12, and a to 2 would yield z = 10. These are the two neighboring vertices. 10

Rebasing a has the highest negative weight in the objective row, so let s make it basic. We need to choose one of u or v to make non-basic. We choose by the θ ratio: old value / new variable s entry θ u = 4 1 ; θ v = 6 So we will keep u basic and remove v 11

Tableau 2 Need to normalize a in its row: b a u v Solution u 1 1 1 0 4 1 1 a 1 0 2 - -5 0 0 0 Then substitute for a in the other equations (subtract each entry*a s value in the other equation): b a u v Solution u 1 1 1-1 1-0 0-1 4-2 1 1 a 1 0 2 ( 5 1 ) 5 ( 5 1) 0 ( 5 1 ) -5*-2 12

Tableau 2 b a u v Solution 2 u 0 1 1 2 1 1 a 1 0 2 4 5 0 2 10 So now we have a solution when u and a are both 2. But we can see that b still has more to contribute! θ u = 2 2 = ; θ b = 2 1 = 6 So repeat again, replacing u with b as a basis. 1

Tableau b a u v Solution b 1 0 2 1 2 1 a 1 1 0 - ( 2 )( 1 ) 1 ( 1 2 )( 1 ) 2 1 4 ( 4 ) 0 0 ( 2 )( 4 ) 5 ( 1 2 )( 4 ) 10 ( 4 ) b a u v Solution b 1 0 2 1 2 a 0 1 1 1 2 2 1 0 0 2 1 14 All variables in solution are non-negative, so this is an optimal solution! b =, a = 1, u = 0, v = 0: z = 14 Note that sometimes our slack variables might be positive still, but in this case they aren t - we re efficient with our materials. 14

Simplex Procedure 1. Initialize a tableau with the problem in standard form and solution row 2. Check if solution row is all positive; if it is, stop - optimal solution. If not, choose a variable to make basic (entering variable) - probably the one with the lowest value in the solution row. Mark it as the pivot column. 4. Choose a basic variable to make non-basic (departing variable) - the one with the smallest θ ratio. Mark its row as the pivot row. 5. Form the new tableau by: Divide the elements of the pivot row by its element in the pivot column Subtract from each other row (its value in the pivot column)*(the pivot row) (This is similar to Gaussian elimination; it represents solving for one variable in terms of the others and substituting) 15

Simplex Analysis In some degenerate cases, multiple bases might represent the same vertex - this could lead to infinite loops! Some variations resolve θ ties systematically to avoid repeats, or other ways of fixing these. Still, worst case performance is exponential - systematic walk of O(m n ) vertices! In practice, most problems run in O(mn) time. Another algorithm, the Ellipsoid Method, is guaranteed (weak) polynomial time but in practice is much slower. Interior point method is also polynomial and actually competitive in practice. 16

The Graph Problem to End all (of our) Graph Problems

Traveling Salesman Traveling Salesman Instance: a connected weighted graph G Solution: a minimum Hamiltonian circuit of G - a cycle that visits every node exactly once 17

Brute Forcing Traveling Salesman In the worst case, an n-clique, every ordering of vertices is a Hamiltonian path So brute force is O( V!) - permutations of V 18

Discrete Knapsack {0,1} Knapsack Instance: a set of n items with values {v 1,, v n } and weights {w 1,, w n }, and a capacity W Solution: a vector X {0, 1} n that maximizes v 1 x 1 + + v n x n constrained by w 1 x 1 + + w n x n W 19

Brute Forcing Discrete Knapsack A solution is n independent binary decisions, so a brute force method is O(2 n ) 20

Integer Linear Programming Traveling Salesman can be thought of as a system of linear equations, if we think of each variable x i {0, 1} representing whether edge i is in the path. Like the {0,1} Knapsack Problem, it can be consider Integer Linear Programming or just Integer Programming. Integer Programming is HARD - we can no longer guarantee that our optimum is at a vertex, because the vertices of the constrained system may not be at integers! 21

Branch-and-Bound Idea: search the solution space using the (continuous) linear programming to guide us to upper and lower bounds. Build a search tree of candidates and prune aggressively. Notation: U i (x) and L i (x) are upper and lower bounds of variable v at node i 22

Branch-and-Bound Procedure Basic Procedure Without Pruning 1. Find optimal relaxed linear solution; round all variables down and find z 2. Root node: U i relaxed optimum; L i rounded. Select variable x M with greatest fractional part 4. Create child nodes with additional constraints: x M U i (x M ) x M L i (x M ) 5. Recurse on child nodes Find maximum non-fractional node Use α β pruning from AI 2

BnB Analysis Tree search: O(2 n ) worst case Still better than the O(n!) of a brute force approach 24

Dynamic Programming and Time/Space Trade-offs

Next Week Another approach to hard problems: writing things down! 25

References i