The Simplex Method Combinatorial Problem Solving (CPS) Javier - - PowerPoint PPT Presentation

the simplex method
SMART_READER_LITE
LIVE PREVIEW

The Simplex Method Combinatorial Problem Solving (CPS) Javier - - PowerPoint PPT Presentation

The Simplex Method Combinatorial Problem Solving (CPS) Javier Larrosa Albert Oliveras Enric Rodr guez-Carbonell May 6, 2020 Global Idea The Fundamental Theorem of Linear Programming ensures it is sufficient to explore basic


slide-1
SLIDE 1

The Simplex Method

Combinatorial Problem Solving (CPS)

Javier Larrosa Albert Oliveras Enric Rodr´ ıguez-Carbonell

May 6, 2020

slide-2
SLIDE 2

Global Idea

2 / 37

The Fundamental Theorem of Linear Programming ensures it is sufficient to explore basic feasible solutions to find the optimum of a feasible and bounded LP

The simplex method moves from one basic feasible solution to another that does not worsen the objective function while

  • ptimality or

unboundedness are not detected

slide-3
SLIDE 3

Bases and Tableaux

3 / 37

Given a basis B, its tableau is the system of equations xB = B−1b − B−1RxR which expresses values of basic variables in terms of non-basic variables min −x − 2y x + y + s1 = 3 x + s2 = 2 y + s3 = 2 x, y, s1, s2, s3 ≥ 0 B = {x, y, s2}    x = 1 + s3 − s1 y = 2 − s3 s2 = 1 − s3 + s1

slide-4
SLIDE 4

Basic Solution in a Tableau

4 / 37

The basic solution can be easily obtained from the tableau by looking at independent terms    x = 1 + s3 − s1 y = 2 − s3 s2 = 1 − s3 + s1 Note that by definition of basic solution, the values for non-basic variables are null

slide-5
SLIDE 5

Detecting Optimality (1)

5 / 37

Tableaux can be extended with the expression of the cost function in terms of the non-basic variables        min −x − 2y = ⇒ min −5 + s1 + s3 x = 1 + s3 − s1 y = 2 − s3 s2 = 1 − s3 + s1

Value of objective function at basic solution can be easily found by looking at independent term

slide-6
SLIDE 6

Detecting Optimality (1)

5 / 37

Tableaux can be extended with the expression of the cost function in terms of the non-basic variables        min −x − 2y = ⇒ min −5 + s1 + s3 x = 1 + s3 − s1 y = 2 − s3 s2 = 1 − s3 + s1

Value of objective function at basic solution can be easily found by looking at independent term

Coefficients of non-basic variables in objective function after substitution are called reduced costs

By convention, reduced costs of basic variables are 0

slide-7
SLIDE 7

Detecting Optimality (1)

5 / 37

Tableaux can be extended with the expression of the cost function in terms of the non-basic variables        min −x − 2y = ⇒ min −5 + s1 + s3 x = 1 + s3 − s1 y = 2 − s3 s2 = 1 − s3 + s1

Value of objective function at basic solution can be easily found by looking at independent term

Coefficients of non-basic variables in objective function after substitution are called reduced costs

By convention, reduced costs of basic variables are 0

Sufficient condition for optimality: all reduced costs are ≥ 0 The cost of any other feasible solution can’t improve on the basic solution So the basic solution is optimal!

slide-8
SLIDE 8

Detecting Optimality (2)

6 / 37

If reduced costs ≥ 0: sufficient condition for optimality but not necessary

In the example, both bases are optimal but in one we cannot detect optimality! min x + 2y x + y = 0 x, y ≥ 0 B = {x} min y x = −y B = {y} min −x y = −x

slide-9
SLIDE 9

Improving the Basic Solution

7 / 37

What to do when the tableau does not satisfy the optimality condition? min −x − 2y x + y + s1 = 3 x + s2 = 2 y + s3 = 2 x, y, s1, s2, s3 ≥ 0 B = (s1, s2, s3)        min −x − 2y s1 = 3 − x − y s2 = 2 − x s3 = 2 − y

E.g. variable y has a negative reduced cost

If we can get a new solution where y > 0 and the rest of non-basic variables does not worsen the objective value, we will get a better solution

In general, to improve the objective value: increase the value of a non-basic variable with negative reduced cost while the rest of non-basic variables are frozen to 0 E.g. increase y while keeping x = 0

slide-10
SLIDE 10

Improving the Basic Solution

8 / 37

Let us increase value of variable y while satisfying non-negativity constraints on basic variables    s1 = 3 − x − y Limits new value to ≤ 3 s2 = 2 − x Does not limit new value s3 = 2 − y Limits new value to ≤ 2

Best possible new value for y is min(3, 2) = 2

The bound due to s3 is tight, i.e., the constraint s3 ≥ 0 limits the new value for y

slide-11
SLIDE 11

Improving the Basic Solution

9 / 37

The new solution does not seem to be basic... but in fact it is. We only need to change the basis.

When increasing the value of the improving non-basic variable, all basic variables for which the bound is tight become 0 y = 2 → s3 = 0

Choose a tight basic variable, here s3, to be exchanged with the improving non-basic variable, here y

We can get the tableau of the new basis by solving the non-basic variable in terms of the basic one and substituting: s3 = 2 − y ⇒ y = 2 − s3        min −x − 2y s1 = 3 − x − y s2 = 2 − x s3 = 2 − y = ⇒        min −4 − x + 2s3 s1 = 1 + s3 − x s2 = 2 − x y = 2 − s3

slide-12
SLIDE 12

Improving the Basic Solution

10 / 37

x y x ≤ 2 x + y ≤ 3 y ≤ 2 y ≥ 0 x ≥ 0 (0, 2) (0, 0) min −x − 2y

slide-13
SLIDE 13

Improving the Basic Solution

11 / 37

Let us now increase value of variable x        min −4 − x + 2s3 s1 = 1 + s3 − x Limits new value to ≤ 1 s2 = 2 − x Limits new value to ≤ 2 y = 2 − s3 Does not limit new value

Best possible new value for x is min(2, 1) = 1

Variable s1 leaves the basis and variable x enters        min −4 − x + 2s3 s1 = 1 + s3 − x s2 = 2 − x y = 2 − s3 = ⇒        min −5 + s1 + s3 x = 1 + s3 − s1 s2 = 1 − s3 + s1 y = 2 − s3

slide-14
SLIDE 14

Improving the Basic Solution

12 / 37

x y x ≤ 2 x + y ≤ 3 y ≥ 0 x ≥ 0 (1, 2) y ≤ 2 min −x − 2y (0, 2) (0, 0)

slide-15
SLIDE 15

Unboundedness

13 / 37

Unboundedness is detected when the new value for the chosen non-basic variable is not bounded.

x y 2x + y ≥ 3 y ≥ 0 x ≥ 0

max x + y 2x + y ≥ 3 x, y ≥ 0 ⇓ min −x − y −2x − y + s = −3 ⇓ min −3 + x − s y = 3 − 2x + s

slide-16
SLIDE 16

Outline of the Simplex Algorithm

14 / 37

1. Initialization: Pick a feasible basis. 2. Pricing: If all reduced costs are ≥ 0, then return OPTIMAL. Else pick a non-basic variable with reduced cost < 0. 3. Ratio test: Compute best value for improving non-basic variable respecting non-negativity constraints of basic variables. If best value is not bounded, then return UNBOUNDED. Else select basic variable for exchange with improving non-basic variable. 4. Update: Update the tableau and go to 2.

slide-17
SLIDE 17

Finding an Initial Basis

15 / 37

Note that to optimize min cT x Ax = b x ≥ 0 initially we need a feasible basis at step 1.

Step 1 (looking for a feasible basis) is called Phase I of the simplex algorithm

Steps 2-4 (optimizing) are called phase II

We will see how to get a feasible basis with the same simplex algorithm by solving another LP for which phase I is trivial

slide-18
SLIDE 18

Finding an Initial Basis

16 / 37

For example        min −x − 2y 1 ≤ x + y ≤ 3 0 ≤ x ≤ 2 0 ≤ y ≤ 2 ⇒            min −x − 2y x + y + s1 = 3 x + y − s2 = 1 x + s3 = 2 y + s4 = 2 An initial basis consisting of slacks is simple as the inverse is the identity:        s1 = 3 − x − y s2 = −1 + x + y s3 = 2 − x s4 = 2 − y But in this example it turns out not to be feasible!

slide-19
SLIDE 19

Finding an Initial Basis

17 / 37

Problem: the slack of constraint x + y ≥ 1 has the “wrong” sign x + y ≥ 1 → x + y − s2 = 1 → s2 = −1 + x + y We can add an artificial variable z1 to the equation with the “right” sign and use it in the basis instead of s2        x + y + s1 = 3 x + y − s2 + z1 = 1 x + s3 = 2 y + s4 = 2 ⇒        s1 = 3 − x − y z1 = 1 − x − y + s2 s3 = 2 − x s4 = 2 − y Variable z1 represents how far we are from satisfying constraint x + y ≥ 1 So we should minimize it (and forget the original objective function for the time being)

slide-20
SLIDE 20

Finding an Initial Basis

18 / 37

So let us solve            min z1 x + y + s1 = 3 x + y − s2 + z1 = 1 x + s3 = 2 y + s4 = 2 Applying the simplex algorithm:            min 1 − x − y + s2 s1 = 3 − x − y z1 = 1 − x − y + s2 s3 = 2 − x s4 = 2 − y ⇒            min z1 s1 = 2 + z1 − s2 x = 1 − z1 − y + s2 s3 = 1 + z1 + y − s2 s4 = 2 − y Feasible tableau for original LP        s1 = 2 − s2 x = 1 − y + s2 s3 = 1 + y − s2 s4 = 2 − y

slide-21
SLIDE 21

Finding an Initial Basis

19 / 37

x ≤ 2 y ≤ 2 y ≥ 0 (1, 0) y x + y ≤ 3 x + y ≥ 1 x ≥ 0 x (0, 0)

slide-22
SLIDE 22

Finding an Initial Basis

20 / 37

In general, let us imagine we want to get an initial feasible basis for min cT x Ax = b x ≥ 0

Let us assume wlog. that b ≥ 0

We introduce new vector of artificial variables z and solve min 1T z Ax + z = b x, z ≥ 0

We may not need to add an artificial variable for each row if the slack has the right sign (but we will do so here, for the sake of presentation)

slide-23
SLIDE 23

Finding an Initial Basis

21 / 37

[LP] min cT x Ax = b x ≥ 0 = ⇒ [LP ′] min 1T z Ax + z = b where b ≥ 0 x, z ≥ 0

LP ′ is feasible, and a trivial feasible basis is B = (z)

LP ′ cannot be unbounded: z ≥ 0 implies 1T z ≥ 0 So LP ′ has optimal solution with objective value ≥ 0

If x∗ is feasible solution to LP then (x, z) = (x∗, 0) is optimal solution to LP ′ with objective value 0

If (x, z) = (x∗, z∗) is optimal solution to LP ′ with objective value 0 then z∗ = 0 and so x∗ is feasible solution to LP

slide-24
SLIDE 24

Finding an Initial Basis

22 / 37

[LP] min cT x Ax = b x ≥ 0 = ⇒ [LP ′] min 1T z Ax + z = b where b ≥ 0 x, z ≥ 0

LP is feasible iff optimum of LP ′ is 0

Still: how can we get a feasible basis for LP?

Assume that optimum of LP ′ is 0. Then: 1. If all artificial variables are non-basic, then an optimal basis for LP ′ is a feasible basis for LP 2. Any basic artificial variable can be made non-basic by Gaussian elimination (since A has full rank)

slide-25
SLIDE 25

Big M Method

23 / 37

Alternative to phase I + phase II approach

LP is changed as follows, where M is a “big number” min cT x Ax = b x ≥ 0 = ⇒ min cT x + M · 1T z Ax + z = b where b ≥ 0 x, z ≥ 0

Again by taking the artificial variables we get an initial feasible basis

The search of a feasible basis for the original problem is not blind wrt. cost

Problems:

If M is a fixed big number, then the algorithm becomes numerically unstable

If M is kept symbolically, then handling costs becomes too expensive

slide-26
SLIDE 26

Big M Method

24 / 37

       min −x − 2y 1 ≤ x + y ≤ 3 0 ≤ x ≤ 2 0 ≤ y ≤ 2 ⇒            min −x − 2y x + y + s1 = 3 x + y − s2 = 1 x + s3 = 2 y + s4 = 2 ⇒            min −x − 2y + Mz x + y + s1 = 3 x + y − s2 + z = 1 x + s3 = 2 y + s4 = 2 Let us solve            min −x − 2y + Mz x + y + s1 = 3 x + y − s2 + z = 1 x + s3 = 2 y + s4 = 2 starting with initial feasible basis (s1, z, s3, s4)

slide-27
SLIDE 27

Big M Method

25 / 37

           min M + (−1 − M)x + (−2 − M)y + Ms2 s1 = 3 − x − y z = 1 − x − y + s2 s3 = 2 − x s4 = 2 − y = ⇒            min x − 2 − 2s2 + (M + 2)z s1 = 2 + z − s2 y = 1 − x − z + s2 s3 = 2 − x s4 = 1 + z + x − s2 Once z is non-basic we can drop it and continue the optimization:            min x − 2 − 2s2 s1 = 2 − s2 y = 1 − x + s2 s3 = 2 − x s4 = 1 + x − s2

slide-28
SLIDE 28

Termination and Complexity

26 / 37

A step of the simplex algorithm is degenerate if the increment of the chosen non-basic variable is 0

At each step of the simplex algorithm: cost improvement = reduced cost · increment (of chosen non-basic var)

If the step is degenerate then there is no cost improvement

But degenerate steps can only happen with degenerate bases

Assume no degenerate bases occur. Then there is a strict improvement from a base to the next one So simplex terminates, as bases cannot be repeated

  • No. steps is at most exponential: there are ≤

n

m

  • bases

Tight bound for pathological cases (Klee-Minty cube) In practice the cost is polynomial

slide-29
SLIDE 29

Termination and Complexity

27 / 37

When there is degeneracy simplex may loop forever

Termination guaranteed with anticycling rules, e.g. Bland’s rule: Assume there is a fixed ordering of variables. Pricing: among non-basic vars with reduced cost < 0, take the least one Ratio test: among tight basic vars, take the least one

slide-30
SLIDE 30

Pricing Strategies

28 / 37

1. Full pricing Choose the variable with the most negative reduced cost 2. Partial pricing Make a list with the indices of the P variables with the most negative reduced costs. In following iterations choose variables from the list until reduced costs are all ≥ 0

slide-31
SLIDE 31

Pricing Strategies

29 / 37

3. Best-improvement pricing Let θk be the increment for a non-basic variable xk with reduced cost dk < 0. Choose the variable j such that |dj| · θj = max{|dk| · θk such that dk < 0, k ∈ R} 4. Normalized pricing. Let nk = ||αk|| (in practice nk =

  • 1 + ||αk||2)

where αk is the column in the tableau of variable xk. Take criteria 1. or 2. but using dk

nk instead of dk

5. Other more sophisticate normalized pricing strategies: steepest edge, devex

slide-32
SLIDE 32

Bounded Variables

30 / 37

LP solvers implement a variant of the simplex algorithm that handles bounds more efficiently for LP’s of the form min cT x Ax = b ℓ ≤ x ≤ u

These bounded LP’s arise when solving combinatorial problems

Bounds are incorporated into pricing and ratio test

Now non-basic variables will take values at the lower or the upper bound

slide-33
SLIDE 33

Bounded Variables

31 / 37

min −x − 2y x + y ≤ 3 0 ≤ x ≤ 2 0 ≤ y ≤ 2 = ⇒ min −x − 2y x + y + s = 3 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0 = ⇒ min −x − 2y s = 3 − x − y 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0

Initially non-basic variables x, y are at lower bound

We choose variable x in pricing

slide-34
SLIDE 34

Bounded Variables

32 / 37

           min −x − 2y s = 3 − x − y Limits new value to ≤ 3 as s ≥ 0 0 ≤ x ≤ 2 Limits new value to ≤ 2 as x ≤ 2 0 ≤ y ≤ 2 s ≥ 0

Best possible new value for x is min(3, 2) = 2

Bound flip: x is still non-basic, but is now at upper bound            min −x − 2y s = 3 − x − y 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0

slide-35
SLIDE 35

Bounded Variables

33 / 37

Pricing considers the bound status of non-basic variables

A non-basic variable xj with reduced cost dj can improve the cost function

if xj is at lower bound and dj < 0; or

if xj is at upper bound and dj > 0

Choose y in pricing:            min −x − 2y s = 3 − x − y Limits new value to ≤ 1 as s ≥ 0 0 ≤ x ≤ 2 0 ≤ y ≤ 2 Limits new value to ≤ 2 as y ≤ 2 s ≥ 0

Best possible new value for y is min(1, 2) = 1

slide-36
SLIDE 36

Bounded Variables

34 / 37

Usual pivoting step now: s = 3 − x − y ⇒ y = 3 − x − s            min −x − 2y s = 3 − x − y 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0 = ⇒            min −6 + x + 2s y = 3 − x − s 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0

slide-37
SLIDE 37

Bounded Variables

35 / 37

Choose x in pricing. To respect bounds for y: 0 ≤ y(x) ≤ 2 0 ≤ 3 − x ≤ 2 (since x decreases its value, 0 ≤ y(x) is OK) 3 − x ≤ 2 1 ≤ x            min −6 + x + 2s y = 3 − x − s Limits new value to ≥ 1 0 ≤ x ≤ 2 Limits new value to ≥ 0 0 ≤ y ≤ 2 s ≥ 0

Best possible new value for x is max(1, 0) = 1

slide-38
SLIDE 38

Bounded Variables

36 / 37

Usual pivoting step now: y = 3 − x − s ⇒ x = 3 − y − s

slide-39
SLIDE 39

Bounded Variables

36 / 37

Usual pivoting step now: y = 3 − x − s ⇒ x = 3 − y − s            min −6 + x + 2s y = 3 − x − s 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0 = ⇒            min −3 + s − y x = 3 − y − s 0 ≤ x ≤ 2 0 ≤ y ≤ 2 s ≥ 0

Since upper bound of y was tight, now y is set to its upper bound

Optimal solution: (x, y, s) = (1, 2, 0) with cost −5

Now reading the basic solution and its cost is more involved!

slide-40
SLIDE 40

Bounded Variables

37 / 37

min −x − 2y x y ≤ 2 (0, 0) y ≥ 0 x ≤ 2 x ≥ 0 (2, 0) (2, 1) x + y ≤ 3 y (1, 2)