integer programming part 2

41
1 15.053/8 March 4, 2014 Integer Programming Formulations 2 references: IP Formulation Guide (on the website) Tutorial on IP formulations. Applied Math Programming

Upload: missmit

Post on 11-May-2017

239 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Integer Programming Part 2

1

15.053/8 March 4, 2014

Integer Programming Formulations 2

references: IP Formulation Guide (on the website) Tutorial on IP formulations. Applied Math Programming

Page 2: Integer Programming Part 2

2

Quote of the Day

What chiefly characterizes creative thinking from more mundane forms are (i) willingness to accept vaguely defined problem statements and gradually structure them, (ii) continuing preoccupation with problems over a considerable period of time, and (iii) extensive background knowledge in relevant and potentially relevant areas.

-- Herbert Simon

Page 3: Integer Programming Part 2

3

Overview of today’s lecture Very quick review of integer programming

Building blocks for creating IP models

Logical constraints

Non-linear functions

Set covering and packing.

Other combinatorial problems modeled as IPs

Page 4: Integer Programming Part 2

4

Integer Programs

Integer programs: a linear program plus the additional constraints that some or all of the variables must be integer valued.

We also permit “xj {0,1}∈ ,” or equivalently, “xj is binary” This is a shortcut for writing the constraints:

0 ≤ xj ≤ 1 and xj integer.

Page 5: Integer Programming Part 2

5

Modeling the constraint “x ≤ 2 or x ≥ 5” Suppose that 0 ≤ x ≤ 8

Choose a binary variable w so that if w = 1, then x ≥ 5. if w = 0, then x ≤ 2.

x

w

0 2 4 6 108

x0 2 4 6 108

Page 6: Integer Programming Part 2

6

The geometry of the constraint “x ≤ 2 or x ≥ 5”

x

Suppose that 0 ≤ x ≤ 8

Choose a binary variable w so that if w = 1, then x ≥ 5. if w = 0, then x ≤ 2.w

0 2 4 6 10

x ≤ 2 + 6w

x ≥ 5 – 5(1-w) = 5w These two constraints eliminate all infeasible solutions, but no feasible solution.

8

Page 7: Integer Programming Part 2

7

The big M method: “x ≤ 2 or x ≥ 5”

x

Suppose that 0 ≤ x ≤ 8

Choose a binary variable w so that if w = 1, then x ≥ 5. if w = 0, then x ≤ 2.w

0 2 4 6 10

x ≤ 2 + Mw

x ≥ 5 – M(1-w) These two constraints eliminate all infeasible solutions, but no feasible solution. (But there are more solutions for the LP.)

8

Page 8: Integer Programming Part 2

8

BIG M Method for IP Formulations Assume that all variables are integer valued. Assume a bound u* on coefficients and variables;

e.g., xj ≤ 10,000 for all j. |aij| ≤ 10,000 for all i, j.

Choose M really large so that for every constraint i,

|ai1x1 + ai2 x2 + … + ain xn| ≤ bi + M

That is, we will be able to satisfy any “≤” constraint by adding M to the RHS.

And we can satisfy any “≥” constraint by subtracting M from the RHS.

Page 9: Integer Programming Part 2

Modeling “or constraints”

If w = 1, then x1 + 2x2 ≥ 12

If w = 0, then 4x2 – 10x3 ≤ 1

Therefore, the logical constraints are satisfied.

Suppose that (x, w) is feasible, for the IP.

To show: The logical constraints are equivalent to the IP constraints.

Suppose that xi is bounded for all i.

x1 + 2x2 ≥ 12 or 4x2 – 10x3 ≤ 1. Logical constraints.

x1 + 2x2 ≥ 12 – M(1-w)4x2 – 10x3 ≤ 1 + Mw. IP constraints.

Suppose that M is very large.

Page 10: Integer Programming Part 2

Suppose that x satisfies the logical constraints.

Suppose that xi is bounded for all i.

x1 + 2x2 ≥ 12 or 4x2 – 10x3 ≤ 1. Logical constraints.

x1 + 2x2 ≥ 12 – M(1-w)4x2 – 10x3 ≤ 1 + Mw.

IP constraints.

Suppose that M is very large.

If x1 + 2x2 ≥ 12, then let w = 1

x1 + 2x2 ≥ 12the other constraint is redundant

Else 4x2 – 10x3 ≤ 1 then let w = 0

4x2 – 10x3 ≤ 1.the other constraint is redundant

In both cases, the IP constraints are satisfied.

Page 11: Integer Programming Part 2

11

If-then constraints

“If A then B” is equivalent to “(Not A) or B or both.”“If it is a crow, then it is black.”“Either it isn’t a crow, or it is black, or both.”

How would one model “If x1 ≥ 12 then x2 ≤ 7”? You may assume that

0 ≤ x1 ≤ 100 0 ≤ x2 ≤ 100x1, x2 are integers.

And let w {0,1} be the new variable.∈

Page 12: Integer Programming Part 2

12

Which constraints are equivalent to: If x1 ≥ 12 then x2 ≤ 7.

A. x1 ≥ 12 + Mw x2 ≤ 7 – M(1-w)w {0,1}∈

B. x1 ≥ 12 – Mw x2 ≤ 7 + M(1-w)w {0,1}∈

C. x1 ≤ 11 – Mw x2 ≤ 7 – M(1-w)w {0,1}∈

D. x1 ≤ 11 + Mw x2 ≤ 7 + M(1-w)w {0,1}∈

Page 13: Integer Programming Part 2

13

Fixed charge problems Suppose that there is a linear cost of production,

after the process is set up.

There is a cost of setting up the production process.

The process is not set up unless there is production.

Page 14: Integer Programming Part 2

14

Modeling piecewise linear functions.

y = 0 if x = 0y = 2 + 2x if x ≥ 1

Assume that x is integer valued.

We will create an IP formulation so that the variable y is correctly modeled.

0 2 8 10

cost

x4 6

2

810

46

0

12

Page 15: Integer Programming Part 2

15

Modeling piecewise linear functions.

y = 0 if x = 0y = 2 + 2x if x ≥ 1

Assume that 0 ≤ x ≤ 10 and x is integer

Create a new variable w.

0 2 8 10

cost

x4 6

2

810

46

0

12

y = 2w + 2x w {0,1}∈

Page 16: Integer Programming Part 2

16

Is this variable and constraint sufficient?

A. Yes. The variables are all correctly defined.

B. No. There is nothing to prevent y = 2x even if x > 0.

Page 17: Integer Programming Part 2

17

The fixed charge model

0 ≤ x ≤ 10 and x is integer

x

w

0 2 4 6 108

1

0

w ≤ xx ≤ 10w y = 2w + 2x

Page 18: Integer Programming Part 2

18

The fixed charge model: big M version

x

w

0 2 4 6 108

1

0

w ≤ xx ≤ Mw y = 2w + 2x

0 ≤ x ≤ 10 and x is integer

Page 19: Integer Programming Part 2

The Alchemist's Problem

19

Gold Silver Bronze AvailableTA labor (days) 2 4 5 100

lead (kilos) 1 1 1 30

pixie dust (grams) 10 5 2 204

Profit ($) 52 30 20

Cost to set up $500 $400 $300

Zor is unable to get any of his reactions going without an expensive set up.

In 1502, the alchemist Zor Primal has set up shop creating gold, silver, and bronze medallions to celebrate the 10th anniversary of the discovery of America. His trainee alchemist (TA) makes the medallions out of lead and pixie dust. Here is the data table.

Page 20: Integer Programming Part 2

20

Zor’s problem with set up costsMaximize f1(x1) + f2(x2) + f3(x3)

subject to 2 x1 + 4 x2 + 5 x3 ≤ 100

1 x1 + 1 x2 + 1 x3 ≤ 30

10 x1 + 5 x2 + 2 x3 ≤ 204

x1, x2 , x3 ≥ 0 integer

Page 21: Integer Programming Part 2

21

The IP Formulation

Max -500 w1 + 52 x1 - 500 w2 + 30 x2 - 300 w3 + 20 x3

s.t. 2 x1 + 4 x2 + 5 x3 ≤ 100

1 x1 + 1 x2 + 1 x3 ≤ 30

10 x1 + 5 x2 + 2 x3 ≤ 204

x1 ≤ M w1; x2 ≤ M w2; x3 ≤ M w3;

x1, x2 , x3 ≥ 0 integer

w1, w2, w3 {0,1}.∈

We have omitted the constraints wi ≤ xi for all i.

Is that OK?

Page 22: Integer Programming Part 2

22

We have omitted the constraints wi ≤ xi for all i. This is OK because:A. The constraint “wi ≤ xi”

is satisfied by every feasible solution.

B. If xi = 0, then the optimal solution will “wi ≤ xi” is satisfied by every feasible solution.

C. The formulation is wrong if these constraints are eliminated.

Page 23: Integer Programming Part 2

23

Modeling piecewise linear functions.

y = 2 x if 0 ≤ x ≤ 3y = 9 – x if 4 ≤ x ≤ 7y = -5 + x if 8 ≤ x ≤ 9

Assume that x is integer valued.

0 3 7 9

cost

x

It can be accomplished using integer programming.One method is given on the next slides.

Page 24: Integer Programming Part 2

24

Create new binary and integer variables.

y = 2 x if 0 ≤ x ≤ 3y = 9 – x if 4 ≤ x ≤ 7y = -5 + x if 8 ≤ x ≤ 9

x is integer valued.0 3 7 9

cost

x

If the variables are defined as above, then y = 2x1 + (9w2 - x2) + ( - 5 w3 + x3)

Page 25: Integer Programming Part 2

25

Add constraints

4w2 ≤ x2 ≤ 7 w2

w2 {0, 1} ∈

0 ≤ x1 ≤ 3 w1

w1 {0, 1} ∈

8w3 ≤ x3 ≤ 9 w3

w3 {0, 1} ∈

Definitions of the variables. Constraints

If (x, w) satisfies the definitions, then it also satisfies the constraints.

If (x, w) satisfies the constraints, then it also satisfies the definitions.

x = x1 + x2 + x3

xi integer i∀

w1 + w2 + w3 = 1

Suppose that 0 ≤ x ≤ 9, x integer.

Page 26: Integer Programming Part 2

26

Mental Break

Page 27: Integer Programming Part 2

27

053 Chocolates

1 2 3

4

5 67

8 9

1110

12

14 15

13

16

Locate 053 Chocolate stores so that each district has a store in it or next to it.

Minimize the number of stores needed.

Page 28: Integer Programming Part 2

28

How do we represent this as an IP?

xj = 1 if set j is selectedxj = 0 otherwise

Minimize x1 + x2 + … + x16

s.t. x1 + x2 + x4 + x5 ≥ 1

x1 + x2 + x3 + x5 + x6 ≥ 1

x13 + x15 + x16 ≥ 1

xj {0, 1} for each j.∈

Variables

Objective

Constraints

Page 29: Integer Programming Part 2

29

Set covering problems

There is a set of elements S = {1, 2, …, m}. In 053-chocolates, elements are districts

There is a collection S1, S2, …, Sn of subsets of elements. Sj ⊆ S for each j. In 053-chocolates, the subsets are districts

that are “covered” by placing a store. We say that index set J is a cover if S =

Set Cover Problem: find a minimum size (or min cost) cover of S.

Page 30: Integer Programming Part 2

30

Set covering as an integer program

Page 31: Integer Programming Part 2

31

Applications of the set cover problem

• Locating fire stations, or hospitals, or ambulances.

• Delivering orders from Amazon from as few warehouses as possible

• Collecting information about a set of items from as few databases as possible

• Scheduling crews to airplanes• Identifying computer viruses (IBM example)

• Out of 5000 viruses, they identified 9000 strings of 20 bytes not found in good code.

• They found a set cover of 180 strings. This made searching easier.

Page 32: Integer Programming Part 2

32

16

7

12

14

4

2

Set Packing Problems

1 2 3

4

5 67

8 9

1110

12

14 15

13

3Locate as many 053 Chocolate stores as possible so that no two stores are in adjacent districts.

1616

How many stores can you find?

Page 33: Integer Programming Part 2

33

Set packing problems

There is a set of elements S = {1, 2, …, m}.

There is a collection S1, S2, …, Sn of subsets of elements. Sj ⊆ S for each j.

We say that index set J is a feasible packing if Si ∩ Sj = for all i, j J with i ≠ j.∅ ∈

Set Cover Problem: find a maximum size (or min cost) cover of S.

Page 34: Integer Programming Part 2

34

Set packing as an integer program

Page 35: Integer Programming Part 2

35

Applications of the set packing problem

• Seating students during an exam

• Cutting doors (for manufacturing of cars) out of large metal sheets

• Combinatorial auction problem (on problem set)

• Assigning students to rooms in a dorm.

• Scheduling surgeries in a hospital at 9 AM.

Page 36: Integer Programming Part 2

36

Graph Coloring

Adams

Alamosa

Arapahoe

Archuleta

Baca

Bent

Boulder

Chaffee

Cheyenne

Clear

Creek

Conejos Costilla

Crowley

Custer

Delta

Denver

Dolores

Douglas

Eagle

Elbert

El Paso

Fremont

Garfield

Gilpin

Grand

Gunnison

Hinsdale

Huerfano

Jackson

Jefferson

Kiowa

Kit Carson

Lake

La Plata

Larimer

Las Animas

Lincoln

Logan

Mesa

Mineral

Moffat

Montezuma

Montrose

Morgan

Otero

Ouray

Park

Phillips

Pitkin

Prowers

Pueblo

Rio Blanco

Rio Grande

Routt

Saguache

San

Juan

San Miguel

Sedgwick

Summit

Teller

Washington

Weld

Yuma

This is a map of the counties in Colorado. What is the fewest number of colors need to color all of the counties so that no counties with a common border have the same color?

Page 37: Integer Programming Part 2

37

Graph Coloring

Adams

Alamosa

Arapahoe

Archuleta

Baca

Bent

Boulder

Chaffee

Cheyenne

Clear

Creek

Conejos Costilla

Crowley

Custer

Delta

Denver

Dolores

Douglas

Eagle

Elbert

El Paso

Fremont

Garfield

Gilpin

Grand

Gunnison

Hinsdale

Huerfano

Jackson

Jefferson

Kiowa

Kit Carson

Lake

La Plata

Larimer

Las Animas

Lincoln

Logan

Mesa

Mineral

Moffat

Montezuma

Montrose

Morgan

Otero

Ouray

Park

Phillips

Pitkin

Prowers

Pueblo

Rio Blanco

Rio Grande

Routt

Saguache

San

Juan

San Miguel

Sedgwick

Summit

Teller

Washington

Weld

Yuma

Here is a four coloring of the map.

Page 38: Integer Programming Part 2

38

Graph Coloring Problem

Adams

Alamosa

Arapahoe

Archuleta

Baca

Bent

Boulder

ChaffeeCheyenne

ClearCreek

Conejos Costilla

Crowley

Custer

Delta

Denver

Dolores

Douglas

Eagle

Elbert

El Paso

Fremont

Garfield

Gilpin

Grand

Gunnison

Hinsdale

Huerfano

Jackson

Jefferson

Kiowa

Kit Carson

Lake

La Plata

Larimer

Las Animas

Lincoln

Logan

Mesa

Mineral

Moffat

Montezuma

Montrose

Morgan

Otero

Ouray

Park

Phillips

Pitkin

ProwersPueblo

Rio Blanco

Rio Grande

Routt

Saguache

SanJuan

San Miguel

Sedgwick

Summit

Teller

Washington

Weld

Yuma

Exercise: write an integer program whose solution gives the minimum number of colors to color a map.

G = (N, A)

N = {1, 2, 3, … n} set of counties

A = set of arcs. (i, j) A if counties∈ i and j are adjacent.

Page 39: Integer Programming Part 2

39

The Integer Programming Formulation

Min

s.t

Minimize the number of colors.

Each county is given a color.

If counties i and j share a common boundary, then they are not both assigned color k.

If county i is assigned color k, then color k is used.

Page 40: Integer Programming Part 2

40

An Exam Scheduling Problem (coloring)The University of Waterloo has to schedule 500 exams in 28 exam periods so that there are no exam conflicts.

G = (N, A)

N = {1, 2, 3, … n} set of exams. 28 periods.

A = set of arcs. (i, j) A if a person needs to take exam i and exam j.∈

Equivalently, can the exam conflict graph be colored with 28 colors?

Page 41: Integer Programming Part 2

41

Summary of types of IP formulations Logical constraints

Non-linear objectives

Set covering, and set packing

Coloring and partitioning

and many more not mentioned yet