Sei sulla pagina 1di 41

15.

053/8

March 4, 2014

Integer Programming Formulations 2

references:

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

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

Overview of todays 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

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.

Modeling the constraint

x 2 or x 5
x

Suppose that 0 x 8
0 2 4 6 8 10

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

10
5

The geometry of 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. w if w = 0, then x 2.

x 0 2 4 6 8 10

x 5 5(1-w) = 5w x 2 + 6w

These two constraints eliminate all infeasible solutions, but no feasible solution.
6

The big M method:

x 2 or x 5

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

x 0 2 4 6 8 10

x 5 M(1-w) x 2 + Mw

These two constraints eliminate all infeasible solutions, but no feasible solution. (But there are more solutions for the LP.)

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.
8

Modeling
x1 + 2x2 12 or 4x2 10x3 1.
Logical constraints.
Suppose that xi is bounded for all i.

or constraints
x1 + 2x2 12 M(1-w) 4x2 10x3 1 + Mw.
IP constraints. Suppose that M is very large.

To show: The logical constraints are equivalent to the IP constraints. Suppose that (x, w) is feasible, for the IP. If w = 1, then x1 + 2x2 12

If w = 0, then 4x2 10x3 1 Therefore, the logical constraints are satisfied.

x1 + 2x2 12 or 4x2 10x3 1.


Logical constraints. Suppose that xi is bounded for all i.

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


IP constraints. Suppose that M is very large.

Suppose that x satisfies the logical constraints.

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


Else 4x2 10x3 1 then let w = 0

x1 + 2x2

12

the other constraint is redundant

4x2 10x3 1.
the other constraint is redundant

In both cases, the IP constraints are satisfied.

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 isnt 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 100 x1, x2 are integers. And let w {0,1} be the new variable.
11

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


A.

x1 12 + Mw x2 7 M(1-w) w {0,1} x1 12 Mw x2 7 + M(1-w) w {0,1} x1 11 Mw x2 7 M(1-w) w {0,1} x1 11 + Mw x2 7 + M(1-w) w {0,1}

B.

C.

D.

12

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.

13

Modeling piecewise linear functions.


cost

12 10 8 6 4 2 0

y = 0

if x = 0

y = 2 + 2x

if x 1

Assume that x is integer valued. x

10

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


14

Modeling piecewise linear functions.


cost

12 10 8 6 4 2 0

y = 0

if x = 0

y = 2 + 2x

if x 1

Assume that 0 x 10 and x is integer 0 2 4 6 8 10 x

Create a new variable w.

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

Is this variable and constraint sufficient?


A.

Yes. The variables are all correctly defined. No. There is nothing to prevent y = 2x even if x > 0.

B.

16

The fixed charge model


0 x 10 and x is integer

w
1

10

wx x 10w

y = 2w + 2x
17

The fixed charge model: big M version


0 x 10 and x is integer

w
1

10

wx x Mw

y = 2w + 2x
18

The Alchemist's Problem


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. Gold TA labor (days) lead (kilos) pixie dust (grams) Profit ($) 2 1 10 52 Silver 4 1 5 30 Bronze 5 1 2 20 Available 100 30 204

Zor is unable to get any of his reactions going without an expensive set up. Cost to set up $500 $400 $300
19

Zors problem with set up costs


Maximize
subject to

f1(x1) + f2(x2) + f3(x3)


2 x 1 + 4 x2 + 5 x3 100 30 1 x1 + 1 x 2 + 1 x3 x1, x2 , x3 0 integer

10 x1 + 5 x2 + 2 x3 204

20

The IP Formulation

Max
s.t.

-500 w1 + 52 x1 2 x1 + 4 x2 + 5 x3 1 x1 + 1 x2 + 1 x3

500 w2 + 30 x2 - 300 w3 + 20 x3
100 30

We have omitted the constraints

10 x1 + 5 x2 + 2 x3 204

wi xi for all i.
x 3 M w 3;

x 1 M w 1;

x 2 M w 2;

x1, x2 , x3 0 integer w1, w2, w3 {0,1}.

Is that OK?

21

We have omitted the constraints wi xi for all i. This is OK because:


A.

B.

C.

The constraint wi xi is satisfied by every feasible solution. If xi = 0, then the optimal solution will wi xi is satisfied by every feasible solution. The formulation is wrong if these constraints are eliminated.
22

Modeling piecewise linear functions.


cost

y = 2x

if 0 x 3

y = 9x
y = -5 + x

if 4 x 7
if 8 x 9

Assume that x is integer valued. 0 3 7 9

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

Create new binary and integer variables.


cost

y = 2x y = 9x y = -5 + x
3 7 9 x

if 0 x 3 if 4 x 7 if 8 x 9

x is integer valued.

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

24

Add constraints
Definitions of the variables. Constraints
0 x1 3 w 1 w1 {0, 1} 4w2 x2 7 w2 w2 {0, 1} 8w3 x3 9 w3

w3 {0, 1} w1 + w 2 + w3 = 1 x = x1 + x 2 + x 3
Suppose that 0 x 9, x integer. xi integer i

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

Mental Break

26

053 Chocolates

5
4 8 11 10 14

6
7 9

Locate 053 Chocolate stores so that each district has a store in it or next to it. Minimize the number of stores needed.

12 15

13 16

27

How do we represent this as an IP?


xj = 1 if set j is selected xj = 0 otherwise Minimize x1 + x2 + + x16 s.t. x1 + x2 + x4 + x5 1 x1 + x2 + x3 + x5 + x6 1 Constraints Variables Objective

x13 + x15 + x16 1

xj {0, 1} for each j.

28

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.
29

Set covering as an integer program

30

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.
31

Set Packing Problems

1 5 4

2 6

7
8 9

Locate as many 053 Chocolate stores as possible so that no two stores are in adjacent districts.
How many stores can you find?

11
10 14

12
15

13
16 16 16
32

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.
33

Set packing as an integer program

34

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.

35

Graph Coloring

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?

36

Graph Coloring

Here is a four coloring of the map.


37

Graph Coloring Problem


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.

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

1 if color k is used yk = 0 if color k is not used


x ik

1 if region i is given color k = 0 otherwise

38

The Integer Programming Formulation


1 if color k is used yk = 0 if color k is not used
x ik

1 if region i is given color k = 0 otherwise

Min s.t

k y k x
k

Minimize the number of colors.

ik

=1 " i N
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.

x ik + x jk 1
for (i , j ) A and for k = 1 to 4

x ik y k

for i N and for k = 1 to 4

x ik {0,1}

y k {0,1}

39

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.

x ik

1 if exam i is assigned in period k = 0 otherwise


for (i , j ) A and "k [1, 28]

x ik + x jk 1

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


40

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

41