23
Modeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no decisions Enforcing disjunctions Enforcing logical conditions Modeling fixed costs Modeling piecewise linear functions 1 Modeling Yes/No Decisions We can use binary variables to model yes/no decisions. Example: 0-1 Knapsack We are given a set of items j =1 ...n with associated values p j and weights w j . We wish to select a subset of maximum value such that the total weight is less than a constant b. We can associate a 0-1 variable x j with each item indicating whether it is selected or not. max n j =1 p j x j s.t. n j =1 w j x j b x ∈{0, 1} n . Variants are: Subset-Sum, KP-Min, Equality-KP, Multiple-Choice-KP, Bounded-KP, Two- Constrained-KP, Multiple-KP. 1

Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

  • Upload
    others

  • View
    17

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Modeling with Integer Programming

Laura Galli

December 18, 2014

We can use 0-1 (binary) variables for a variety of purposes, such as:

• Modeling yes/no decisions

• Enforcing disjunctions

• Enforcing logical conditions

• Modeling fixed costs

• Modeling piecewise linear functions

1 Modeling Yes/No Decisions

We can use binary variables to model yes/no decisions.

Example: 0-1 Knapsack

• We are given a set of items j = 1 . . . n with associated values pj and weights wj.

• We wish to select a subset of maximum value such that the total weight is less than aconstant b.

• We can associate a 0-1 variable xj with each item indicating whether it is selected ornot.

max∑n

j=1 pjxj

s.t.∑n

j=1wjxj ≤ b

x ∈ {0, 1}n.

Variants are: Subset-Sum, KP-Min, Equality-KP, Multiple-Choice-KP, Bounded-KP, Two-Constrained-KP, Multiple-KP.

1

Page 2: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Example: (Linear) Assignment

• We are given n people and m jobs.

• Each job must be done by exactly one person.

• Each person can do at most one job.

• The cost of person j = 1, . . . , n doing job i = 1, . . . ,m is cij.

• We wish to find a minimum cost assignment.

• We can associate a 0-1 variable xij to each possible assignment (job i to person j)indicating whether it is selected or not.

min∑m

i=1

∑nj=1 cijxij

s.t.∑n

j=1 xij = 1 (i = 1, . . . ,m)∑mi=1 xij ≤ 1 (j = 1, . . . , n)

x ∈ {0, 1}mn.

Note that we can always assume m = n, w.l.o.g.:

• If m > n the problem is infeasible (pigeonhole principle).

• If n > m we can set m = n adding n−m “dummy” jobs such that the correspondingcost cij = 0 for i = m+ 1, . . . , n and j = 1, . . . , n.

• So, the model becomes:

min∑n

i=1

∑nj=1 cijxij

s.t.∑n

j=1 xij = 1 (i = 1, . . . , n)∑ni=1 xij = 1 (j = 1, . . . , n)

x ∈ {0, 1}n2.

• Thus, assignment problems deal with the question of how to assign n items to n otheritems.

• There are different ways in math to describe an assignment. For example, we can viewan assignment as a bijective mapping ψ between two finite sets U and V of n elements.

• This way, we get a representation of an assignment by a permutation ψ, we can justrepresent the permutation as ψ = ψ(1), ψ(2), . . . , ψ(n).

2

Page 3: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• Every permutation ψ corresponds in a unique way to an n×n permutation matrix Xψ

with xij = 1 if j = ψ(i), 0 otherwise.

• So there is a one-to-one correspondence between assignments and permutations of{1, . . . , n} elements.

Note that this is an “easy” problem, indeed constraint matrix is TU.

Example: Generalized Assignment

A NP-hard version is the so called Generalized Assignment Problem, where each personj = 1, . . . , n has a “capacity” bj (e.g., max working hours), and each job i = 1, . . . ,massigned to person j uses up wij of the person capacity bj. Each job must be assignedexactly to one person, and each person cannot exceed his/her own capacity.

min∑m

i=1

∑nj=1 cijxij

s.t.∑n

j=1 xij = 1 (i = 1, . . . ,m)∑mi=1wijxij ≤ bj (j = 1, . . . , n)

x ∈ {0, 1}mn.

2 Selecting from a Set, Fixed Costs, and Dependent

Decisions

• We can use binary variables to model conditions such as at most one, exactly one, atleast one when selecting elements from a set M :

• Let M = {1 . . .m} be a finite set.

• Let {Mj}, j ∈ N = {1 . . . n} be a collection of subsets of M .

• We say F ⊆ N covers M if ∪j∈FMj = M (i.e., at least one).

• We say F ⊆ N is a packing of M if Mj ∩Mk = ∅,∀(j, k), j 6= k (i.e., at most one).

• If F is both a packing and a cover, we say F is a partition of M (i.e., exactly one).

• These problems can be easily represented as IPs.

• We define an incidence matrix Am×n of the family {Mj}:

– Each row of A represents an item of set M

– Each column of A represents a subset Mj of the items

3

Page 4: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• We can associate a 0-1 variable to each subset indicating whether the subset is selectedor not.

• This is a 01-IP model for the set covering problem:

min cTx

s.t. Ax ≥ 1

x ∈ {0, 1}n,

where cj, j = 1 . . . n is the cost vector of the n subsets.

Similarly, the model for set partitioning:

min cTx

s.t. Ax = 1

x ∈ {0, 1}n,

and the model for set packing:

max cTx

s.t. Ax ≤ 1

x ∈ {0, 1}n.

• We can use binary variables to model fixed costs: h(x) = f + px if 0 < x ≤ C andh(x) = 0 if x = 0. To do this we define an additional binary variable y = 1 ifx > 0 and y = 0 otherwise. We replace h(x) by fy + px, and add the constraintsx ≤ Cy, y ∈ {0, 1}.

• Note that this is not a completely satisfactory formulation, because although the costsare correct when x > 0, it is possible to have the solution x = 0, y = 1. So we did notmodel the set X = {(0, 0), (x, 1) for 0 < x ≤ C}, but the set X ∪ {0, 1}. However, asa typical objective is of minimization, this will not arise in an optimal solution.

• We can use binary variables to enforce the condition that a certain action X can only betaken if some other action Y is also taken, i.e., dependent decisions. We introduce twobinary variables x and y for actions X and Y , respectively, and impose the constraint:x ≤ y.

4

Page 5: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Example: Uncapacitated Facility Location

• We are given n potential facility locations and m customers that must be serviced fromthose locations.

• There is a fixed cost dj of opening facility j.

• There is a cost cij associated with serving customer i from facility j.

• We can use two sets of binary variables:

– yj is a binary variable taking value 1 if facility j is opened, 0 otherwise.

– xij is a binary variable taking value 1 if customer i is served by facility j, 0otherwise.

min∑n

j=1 djyj +∑m

i=1

∑nj=1 cijxij

s.t.∑n

j=1 xij = 1 (i = 1, . . . ,m)

xij ≤ yj (i = 1, . . . ,m; j = 1 . . . n) (1)

x ∈ {0, 1}mn, y ∈ {0, 1}n.

Alternatively, we can model dependency constraints (1) as follows:

m∑i=1

xij ≤ myj (j = 1 . . . n).

Example: Capacitated Facility Location

In the capacitated version we are given a demand ri for each customer i and a capacity bjfor each facility j. The following is a valid IP formulation:

min∑n

j=1 djyj +∑m

i=1

∑nj=1 cijxij

s.t.∑n

j=1 xij = 1 (i = 1, . . . ,m)∑mi=1 rixij ≤ bjyj (j = 1, . . . , n) (2)

x ∈ {0, 1}mn, y ∈ {0, 1}n.

5

Page 6: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Example: Bin Packing

We are given n bins with the same capacity b and m items with weight ri, i = 1 . . .m. Wewant to pack all items in the bins and minimize the number of bins used:

min∑n

j=1 yj

s.t.∑n

j=1 xij = 1 (i = 1, . . . ,m)∑mi=1 rixij ≤ byj (j = 1, . . . , n) (3)

x ∈ {0, 1}mn, y ∈ {0, 1}n.

Example: Cutting Stock

There are n rolls of fixed size b awaiting to be cut, aka raws. There are s manufacturers whowant different numbers di of rolls of various-sized widths wi, i = 1, . . . , s, aka finals.How should the raws be cut so that the least number of rolls are cut?The following model by Kantorovich is a valid formulation for the cutting stock problem:

min∑n

j=1 yj

s.t.∑n

j=1 xij ≥ di (i = 1, . . . , s)∑si=1wixij ≤ byj (j = 1, . . . , n) (4)

x ∈ Zsn+ , y ∈ {0, 1}n.

An alternative, stronger formulation, is due to Gilmore & Gomory. The idea is toenumerate all possible raw cutting patterns. A pattern j ∈ J is described by the vector(a1j, a2j, . . . , asj), where aij representes the number of final rolls of width wi obtained fromcutting a raw roll according to pattern j. In this model we have an integer variable xj foreach pattern j ∈ J , indicating how many times pattern j is used, i.e., how many raw rollsare cut according to pattern j.

min∑

j∈J xj

s.t.∑

j∈J aijxj ≥ di (i = 1, . . . , s)

x ∈ Z|J |+ .

Clearly, the Gilmore-Gomory model must be solved using column generation techniques.Note that Bin Packing and Cutting Stock are in fact the same problem! In bin packing

we are given an item vector (ri), i = 1, . . . ,m and we want to minimize the number ofbins of capacity b used to pack all items. In cutting stock we are given a size vector (wi),i = 1, . . . , s, a multiplicity vector di, i = 1, . . . , s, and we want to minimize the number ofbins of capacity b used to pack all items. So, in priciple the problems are equivalent. Yet,cutting stock uses a more “compact” input representation, thus:

6

Page 7: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• poly-time algorithm for BPP is not necessarily poly-time for CSP

• poly-size formulation for BPP is not necessarily poly-size for CSP

..because the size of the input of CSP can be exponentially small compared to BPP inputsize!

Example: Fixed Charge Network Design

This problem often appears in design problems that involve material flows in networks, suchas water supply, heating, roads, telecomm. etc.

• We are given a directed graph G = (V,A).

• Each node i ∈ V has a demand/supply/transit bi.

• An arc (i, j) ∈ A means that direct shipping from i to j is allowed (possibly withmaximum capacity uij if the network is capacitated).

• There is also a variable cost cij associated with each unit of flow along arc (i, j).

• There is a fixed cost dij associated with “opening” arc (i, j) (think of this as the costto “build” the link).

• We can associate two variables with each arc:

– xij is a binary variable taking value 1 if arc (i, j) is open, 0 otherwise.

– fij is a nonnegative continuous variable representing the flow on arc (i, j).

min∑

(i,j)∈A(dijxij + cijfij)

s.t.∑

(i,j)∈A fij −∑

(j,i)∈A fji = bi ∀i ∈ Vfij ≤Mxij ∀(i, j) ∈ A (5)

x ∈ {0, 1}|A|, f ∈ R|A|+ .

If the network is capacitated we also need: fij ≤ uij, ∀(i, j) ∈ A.

Note that if the network is capacitated, we can model dependency constraints (5) aswell as capacity constraints as follows: fij ≤ uijxij ∀(i, j) ∈ A.

7

Page 8: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

3 Modeling a Restricted Set of Values

• We may want a variable x to only take on values in the set {a1, . . . , am}

• We introduce m binary variables yj, j = 1, . . . ,m and the following constraints:

x =∑m

j=1 ajyj∑mj=1 yj = 1

y ∈ {0, 1}m.

• The set of variables yj, j = 1, . . . ,m is called a special ordered set (SOS) of variables.

4 Piecewise Linear Cost Functions

• We can use binary variables to model arbitrary piecewise linear cost functions.

• The function is specified by ordered pairs (ai, f(ai)) and we wish to evaluate it at pointx.

• We can use a binary variable yi, which indicates whether ai ≤ x ≤ ai+1.

• To evaluate the function, we will take linear combinations∑k

i=1 λif(ai) of the givenfunction values.

• This works iff the only two nonzero λ’s are the ones corresponding to the endpoints ofthe interval in which x lies... otherwise the description is not unique!

• Note that piecewise linear functions that are convex (concave) can be minimized (max-imized) by linear programming because the slope of the segments are increasing (de-creasing)...

If f(x) is convex piecewise linear we can represent it as f(x) = maxi=1,...,k−1{aTi x+ bi}:

min maxi=1,...,k−1

{aTi x+ bi} ⇐⇒ min t : t ≥ aTi x+ bi (i = 1, . . . , k − 1).

If f(x) is concave piecewise linear we can represent it as f(x) = mini=1,...,k−1{aTi x+bi}:

max mini=1,...,k−1

{aTi x+ bi} ⇐⇒ max t : t ≤ aTi x+ bi (i = 1, . . . , k − 1).

• Clearly, this does not work for mini-min and maxi-max problems!

8

Page 9: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• General piecewise linear functions are neither convex nor concave, so binary variablesare needed to select the correct segment for a given value of x.

min∑k

i=1 λif(ai)

s.t.∑k

i=1 λi = 1

λ1 ≤ y1

λi ≤ yi−1 + yi (i = 2 . . . k − 1)

λk ≤ yk−1∑k−1i=1 yi = 1

y ∈ {0, 1}k−1, λ ∈ Rk+.

Why making such a fuss of piecewise linear functions? The point is that an arbitrarycontinuous function of one variable can be approximated by a piecewise linear function withthe quality of the approximation being controlled by the size of the linear segments. So, ifwe are given a separable function f(x1, . . . , xp) =

∑pj=1 f(xj), we know a “trick”!

5 Modeling Disjunctive Constraints

• We are given two constraints aTx ≥ b and cTx ≥ d with nonnegative coefficients.Instead of insisting both constraints be satisfied, we want at least one of the twoconstraints to be satisfied. To model this, we define a binary variable y and imposethe following:

aTx ≥ by

cTx ≥ (1− y)d

y ∈ {0, 1}.

• More generally, we can impose that at least k out of m constraints be satisfied withthe following:

(ai)Tx ≥ biyi∑mi=1 yi ≥ k

y ∈ {0, 1}m.

9

Page 10: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• Even more generally, suppose P i = {x ∈ Rp+ : Aix ≤ bi, x ≤ d}, i = 1 . . .m. Then

∃ w : Aix ≤ bi + w, ∀x ≤ d, i = 1 . . .m. So, ∃ x contained in at least k of the P i iffthe following set is nonempty:

Aix ≤ bi + w(1− yi) (i = 1 . . .m)∑mi=1 yi ≥ k

x ≤ d

y ∈ {0, 1}m, x ∈ Rp+.

This follows because yi = 1 yields the constraint Aix ≤ bi, while yi = 0 yields theredundant constraint Aix ≤ bi + w.

• When k = 1 this is an alternative formulation:

Aixi ≤ biyi (i = 1 . . .m)

xi ≤ dyi (i = 1 . . .m)∑mi=1 yi = 1∑mi=1 x

i = x

y ∈ {0, 1}m, x ∈ Rp+, x

i ∈ Rp+ (i = 1 . . .m).

First, given that x ∈ ∪mi=1Pi, suppose w.l.o.g. that x ∈ P 1. Then a solution to the

above model is y1 = 1, yi = 0 otherwise; x1 = x, and xi = 0 otherwise. On the otherhand, suppose the above model has a solution, and, w.l.o.g., suppose y1 = 1, yi = 0otherwise. Then we obtain x = x1, and xi = 0 otherwise. Thus, x ∈ P 1 and x ∈∪mi=1P

i 6= ∅.

Example: A scheduling problem

Disjunctive constraints arise naturally in scheduling problems where several jobs have to beprocessed on a machine and where the order in which they are processed is not specified.Thus we obtain disjunctive constraints of the type “either job k precedes job j on machinei or viceversa”.

Suppose there are n jobs and m machines and each job must be processed on eachmachine. For each job, the machine order is fixed, that is, job j must first be processed onmachine j(1) and then on machine j(2), and so on. A machine can only process one jobat a time, and once a job is started on any machine it must be processed to completion.The objective is to minimize the sum of the completion times of all the jobs. The data thatspecify an instance of the problem are:

10

Page 11: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

1. m, n and pij for i = 1 . . .m and j = 1 . . . n, which is the processing time of job j onmachine i.

2. the machine order j(1), j(2), . . . , j(m) for each job j.

To model this problem we use two types of variables:

• tij is a nonnegative continuous variable representing the start time of job j on machinei.

• xijk is a binary variable taking value 1 if job j precedes job k on machine i (0 otherwise),where j < k.

min∑n

j=1 tj(m),j

s.t. tj(r+1),j ≥ tj(r),j + pj(r),j (r = 1 . . .m− 1; j = 1 . . . n)

tij − tik ≤ −pij +M(1− xijk) (i = 1 . . .m; 1 ≤ j < k ≤ n)

tik − tij ≤ −pik +Mxijk (i = 1 . . .m; 1 ≤ j < k ≤ n)

x ∈ {0, 1}m(n2), t ∈ Rmn

+ .

6 Indicator Variables

We have already seen this trick here and there, but let’s look at the details. An indicatorvariable is a binary variable that indicates whether or not a constraint is satisfied. Given aconstraint

∑j∈N ajxj ≤≥ b, let M and m denote respectively an UB and a LB on the value

of∑

j∈N ajxj − b, and ε the tolerance.

• (δ = 1 =⇒∑

j∈N ajxj ≤ b) ⇐⇒∑

j∈N ajxj ≤ b+M(1− δ)

• (∑

j∈N ajxj ≤ b =⇒ δ = 1) ⇐⇒∑

j∈N ajxj ≥ b+ ε+ δ(m− ε)

• (δ = 1 =⇒∑

j∈N ajxj ≥ b) ⇐⇒∑

j∈N ajxj ≥ b+m(1− δ)

• (∑

j∈N ajxj ≥ b =⇒ δ = 1) ⇐⇒∑

j∈N ajxj ≤ b− ε+ δ(M + ε)

Exercise: Production Planning

An engineering plant can produce 5 types of products : p1, p2, . . . , p5 by using two productionprocesses: grinding and drilling. Each product requires the following number of hours foreach process, and contributes the following (in hundreds of euros) to the net total profit.

• Max the total profit

11

Page 12: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Table 1: Production Planning Data

p1 p2 p3 p4 p5Grinding 12 20 0 25 15Drilling 10 8 16 0 0Profit 55 60 35 40 20

• Each unit of each product takes 20 man-hours for final assembly.

• The factory has 3 grinding machines and 2 drilling machines.

• The factory works a 6 day week with two shifts of 8 hours/day. Eight workers areemployed in assembly, each working one shift per day.

• If we manufacture p1 or p2 (or both), then at least one of p3, p4, p5 must also bemanufactured.

We can model this as a MILP:

max 55x1 + 60x2 + 35x3 + 40x4 + 20x5

s.t. 12x1 + 20x2 + 25x4 + 15x5 ≤ 288

10x1 + 8x2 + 16x3 ≤ 192

20x1 + 20x2 + 20x3 + 20x4 + 20x5 ≤ 384

xi ≤Mzi (i = 1 . . . 5)

z1 + z2 − 2δ ≤ 0

z3 + z4 + z5 − δ ≥ 0

x ≥ 0, z ∈ {0, 1}5, δ ∈ {0, 1}.

“Good” IP Models

In IP formulating a “good” model is of crucial importance to solving the model. A modelconsists of variables, objective function, and constraints. When addressing a model, the firstquestion to ask is: “what are the variables?”. Once we have defined the variables we cangive an implicit representation of the problem:

max{cTx : x ∈ S ⊂ Zn+}

where S is the set of feasible points in Zn+. We say that

max{cTx : Ax ≤ b, x ∈ Zn+}

is a valid formulation if S = {x ∈ Zn+ : Ax ≤ b}. The point is: there are many choices for(A, b)! Which one to choose?

12

Page 13: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Example

S = {(0000), (1000), (0100), (0010), (0001), (0110), (0101), (0011) ⊂ {0, 1}4

.

1. S = {x ∈ B4 : 93x1 + 49x2 + 37x3 + 29x4 ≤ 111}

2. S = {x ∈ B4 : 2x1 + x2 + x3 + x4 ≤ 2}

3.

S = {x ∈ B4 : 2x1 + x2 + x3 + x4 ≤ 2

x1 + x2 ≤ 1

x1 + x3 ≤ 1

x1 + x4 ≤ 1}

Which one is the best?

Most IP algorithms require an UB (assuming max problem) on the value of the objectivefunction, and the efficiency of the algorithm is very dependent on the sharpness of thebound. An UB is obtained, for example, relaxing the integrality constraints (aka continuousrelaxation), so we solve

zLP = max{cTx : Ax ≤ b, x ∈ Rn+}

since S ⊂ P = {x : Ax ≤ b, x ∈ Rn+}. Now, given two valid formulations defined by

(Ai, bi), i = 1, 2 let P i = {x : Aix ≤ bi, x ∈ Rn+} and ziLP = max{cTx : x ∈ P i}. Clearly,

P 1 ⊆ P 2 =⇒ z1LP ≤ z2LP .

Also, it is instinctive to believe that computation time increases as the number of con-straints increases. Yet, trying to find a formulation with a small number of constraints isoften a bad strategy! In fact, one of the main algorithmic approaches involves a systematicaddition of constraints, known as cutting planes or valid inequalities.

To understand how to generate valid inequalities for integer programs, it is first necessaryto understand valid inequalities for polyhedra (or linear programs). So, the first question is:When is the inequality πTx ≤ π0 valid for P = {x ∈ Rn : Ax ≤ b, x ≥ 0}?

• πTx ≤ π0 is valid for P = {x ∈ Rn : Ax ≤ b, x ≥ 0} 6= ∅ iff πTx ≤ π0 is satisfied by allpoints in P .

• More mathy...

• πTx ≤ π0 is valid for P = {x ∈ Rn : Ax ≤ b, x ≥ 0} 6= ∅ iff ∃ u ≥ 0 such that uTA ≥ πand uT b ≤ π0.

13

Page 14: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• Proof: The linear program Π = max{πTx | x ∈ P} is feasible because P 6= ∅ andbounded because Π ≤ π0. Therefore the dual D = min{uT b | u ≥ 0, uTA ≥ π} is alsofeasible and bounded. A basic optimal solution u proves the claim.

• Given two valid inequalities πTx ≤ π0 and µTx ≤ µ0, we say πTx ≤ π0 dominatesµTx ≤ µ0 iff ∃ α > 0 s.t. π ≥ αµ and π0 ≤ αµ0 (if (πT , π0) = (αµT , αµ0) they areequivalent).

• If πTx ≤ π0 dominates µTx ≤ µ0 =⇒ {x ∈ Rn+ | πTx ≤ π0} ⊆ {x ∈ Rn

+ | µTx ≤ µ0}.

• A valid inequality µTx ≤ µ0 is redundant, if there exist k ≥ 1 valid inequalities πiTx ≤πi0, i = 1 . . . k, and weights αi > 0, i = 1 . . . k such that (

∑ki=1 αiπ

i)Tx ≤∑k

i=1 αiπi0

dominates µTx ≤ µ0.

Geometrically, we can see that there must be an infinite number of formulations, so howcan we choose between them? The geometry again helps us to find the answer.

7 Graph Problems

7.1 A(n) (in)Famous Problem: TSP

TSP stands for Traveling Salesman Problem. Here we consider the asymmetric version(ATSP) which is defined on a directed graph. (The so-called symmetric or standard TSPis defined on an undirected graph). We are given a directed graph G = (V,A), whereV = {1, . . . , n} represents the set of cities that a salesman must visit. The arcs A representordered pairs of cities with direct travel possibility, and cij is the travel cost for arc (i, j).The salesman wishes to visit each of n cities exactly once and then return to his startingpoint. Find the order in which he should make his tour so as to do it with minimum cost.

To model this problem we can use a binary variable for each arc xij taking value one ifthe salesman goes directly from town i to town j, and xij = 0 otherwise.

min∑

(ij)∈A cijxij (6)

s.t.∑

(ij)∈δ+(i) xij = 1 (i = 1, . . . , n) (7)∑(ij)∈δ−(j) xij = 1 (j = 1, . . . , n) (8)∑

(ij)∈A(S) xij ≤ |S| − 1 ∀S ⊂ V, 2 ≤ |S| ≤ n− 2 (9)

x ∈ {0, 1}|A|. (10)

Constraints (9) are called subtour elimination constraints. An alternative to (9) are theso-called cut-set constraints:∑

(ij)∈δ+(S)

xij ≥ 1 ∀S ⊂ V, 2 ≤ |S| ≤ n− 2. (11)

14

Page 15: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Cut-set constraints can also be written as follows:∑(ij)∈δ+(S)

xij ≥ 1 ∀S ⊂ V, r ∈ S

for an arbitrary r ∈ V .

The two formulations (6)–(10) and (6)–(8), (11), (10) are equivalent (i.e., they providethe same lower bound), and are due to Dantzig, Fulkerson & Johnson, hence we call themDFJ . A key feature of DFJ is that constraints (9) (as well as (11)) are exponential innumber, which makes cutting-planes methods necessary.

On the other hand, a wide variety of compact formulations exist, i.e., formulations witha polynomial number of both variables and constraints. All of them start by setting V ={1, . . . , n} and viewing node 1 as a “depot”, which the salesman must leave at the start ofthe tour and return at the end of the tour. All of them can be used for the asymmetric TSPas well as for the symmetric TSP.

We start giving the (compact) formulation due to Miller, Tucker & Zemlin (MTZ). Thisformulation is based on the following observation: if the salesman travels from i to j, thenthe position of node j is one more that that of node i. So, for i = 2 . . . n let ui be a continuousvariable representing the position of node i in the tour. (The depot can be thought of asbeing at position 0 and n). The MTZ formulation looks as follows:

min∑

(ij)∈A cijxij

s.t.∑

(ij)∈δ+(i) xij = 1 (i = 1, . . . , n)∑(ij)∈δ−(j) xij = 1 (j = 1, . . . , n)

ui − uj + (n− 1)xij ≤ n− 2 (2 ≤ i, j ≤ n; i 6= j) (12)

1 ≤ ui ≤ n− 1 (2 ≤ i ≤ n) (13)

x ∈ {0, 1}|A|.

The MTZ formulation is compact, having only O(n2) variables and O(n2) constraints.Unfortunately, Padberg & Sung showed that its LP relaxation yields an extremely weaklower bound, much weaker than that of DFJ formulation.

Another compact formulation is due to Gavish & Groves and is called single-commodityflow (SCF ). The idea is that the salesman carries n− 1 units of a (single) commodity whenhe leaves the depot (i.e., node 1), and delivers one unit of this commodity to each othernode:

15

Page 16: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

min∑

(ij)∈A cijxij

s.t.∑

(ij)∈δ+(i) xij = 1 (i = 1, . . . , n)∑(ij)∈δ−(j) xij = 1 (j = 1, . . . , n)∑n

j=1 gji −∑n

j=2 gij = 1 (2 ≤ i ≤ n) (14)

0 ≤ gij ≤ (n− 1)xij (1 ≤ i, j ≤ n; i 6= j) (15)

x ∈ {0, 1}|A|.

where continuous variables gij represent the amount of the commodity (if any) passingdirectly from node i to node j. The constraints (14) ensure that one unit of the commodityis delivered to each non-depot node. The bounds (15) ensure that the commodity can onlyflow along edges that are in the tour. The SCF formulation has O(n2) variables and O(n)constraints. The associated LB is intermediate between the DFJ and MTZ bounds.

Finally, we give a multicommodity flow (MCF ) formulation by Claus. Here the salesmancarries n− 1 commodities, one unit of each for each customer:

min∑

(ij)∈A cijxij

s.t.∑

(ij)∈δ+(i) xij = 1 (i = 1, . . . , n)∑(ij)∈δ−(j) xij = 1 (j = 1, . . . , n)∑n

j=1 fkji −

∑nj=2 f

kij = 0 2 ≤ k ≤ n; (2 ≤ i ≤ n); i 6= k (16)

0 ≤ fkij ≤ xij (1 ≤ i, j ≤ n; i 6= j); 2 ≤ k ≤ n (17)∑ni=2 f

k1i = 1 2 ≤ k ≤ n (18)∑n

i=1 fkik = 1 2 ≤ k ≤ n (19)

x ∈ {0, 1}|A|.

where the continuous variables fkij represent the amount of the k-th commodity (if any)passing directly form node i to node j. The constraints (17) state that a commodity cannotflow along an edge unless that edge belongs to the tour. The constraints (18), (19) imposethat each commodity leaves the depot and arrives at its destination. The constraints (16)ensure that, when a commodity arrives at a node that is not its final destination, then it alsoleaves the node. The MCF formulation has O(n3) variables and O(n3) constraints. Theassociated LB is equal to the DFJ bound.

7.2 Stable Set

In graph theory, stable set or independent set is a (sub)set of vertices in a graph G = (V,E),no two of which are adjacent. That is, it is a (sub)set I ⊆ V of vertices such that for every

16

Page 17: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

two vertices in I, there is no edge in G connecting the two. Equivalently, each edge in thegraph has at most one endpoint in I. The size of the stable set is the number of vertices itcontains. A maximal stable set is either a stable set such that adding any other vertex to theset forces the set to contain an edge (or the set of all vertices of the empty graph). In themaximum stable set problem each vertex i ∈ V is given a weight pi. We wish to find a stableset of maximum weight, clearly if all vertices are given the same weight this correspondsto a stable set of maximum cardinality. The problem is also called vertex packing or nodepacking. The following is a valid formulation for the maximum stable set problem. Let xibe a binary variable associated to a vertex i ∈ V , the variable takes on value 1 if the vertexbelongs to the stables set, 0 otherwise:

max∑

i∈V pixi

s.t. xi + xj ≤ 1 ∀(i, j) ∈ E (20)

x ∈ {0, 1}|V |.

The maximum set packing problem with incidence matrixA ∈ {0, 1}m×n and cost vector c,is equivalent to the stable set problem on the intersection graph G(A) = (V,E) with verticesV = {1 . . . n}, weights pj = cj j ∈ V and edges E = {(i, j) : ahi = ahj for some h ∈{1 . . .m}}.

Also, the maximum stable set problem is equivalent to the maximum clique problemon the complement graph. A clique in an undirected graph G = (V,E) is a subset of thevertex set K ⊆ V , such that for every two vertices in K, there exists an edge connecting thetwo. This is equivalent to saying that the subgraph induced by K is complete. Every cliquecorresponds to a stable set (of the same size) in the complement graph G = (V, E).

Finally, the maximum stable set problem is equivalent to the minimum vertex cover onthe same graph. A vertex cover (aka node cover) of a graph is a (sub)set of vertices C ⊆ Vsuch that each edge of the graph is incident to at least one vertex of the set C. A (sub)setof vertices C is a vertex cover, if and only if its complement I = V \ C is an independentset. Note that the above formulation can be strenthened using clique inequalities.

7.3 Vertex Colouring

We are given an undirected graph G = (V,E), and we want to assign a colour to each vertexin V such that:

• two adjacent vertices get a different colour each

• minimize the number of colours used

Let n = |V |. We use binary variables yj, j = 1 . . . n, taking value 1 if colour j is used, 0otherwise; and binary variables xij = 1 taking value one if colour j is used for vertex i ∈ V .

17

Page 18: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

min∑n

j=1 yj

s.t. xij + xhj ≤ yj ∀(i, h) ∈ E, j = 1, . . . , n (21)∑nj=1 xij = 1 ∀i ∈ V (22)

y ∈ {0, 1}n, x ∈ {0, 1}n2.

7.4 Network Flow Problems

The following are “easy” problems with TU constraint matrices.

7.4.1 Minimum Cost Network Flow

Given a digraph G = (V,A) with arc capacities hij for all (ij) ∈ A, demands bi at each nodei ∈ V , and unit flow costs cij for all (ij) ∈ A, we want to find a feasible flow that satisfiesall the demands at minimum cost:

min∑

(ij)∈A cijxij

s.t.∑

(ij)∈δ+(i) xij −∑

(ji)∈δ−(i) xji = bi (i ∈ V )

0 ≤ xij ≤ hij (i, j) ∈ A.

A generalization of this is the so called Min-Cost Multi-commodity Network Flow problem.Again, we are given a network represented by a digraph G = (V,A), with arc capacities hijfor all (ij) ∈ A, and unit flow costs cij for all (ij) ∈ A. Also, we are given K commodities,each one represented by a triple (sk, tk, bk), i.e., source-sink-demand. We want to find afeasible flow for all K commodities that satisfies all the demands at minimum cost:

min∑K

k=1

∑(ij)∈A cijx

kij

s.t.∑

(ij)∈δ+(i) xkij −

∑(ji)∈δ−(i) x

kji = bki (i ∈ V, k = 1 . . . K)∑K

k=1 xkij ≤ hij (i, j) ∈ A

xkij ≥ 0 (i, j) ∈ A, k = 1 . . . K.

Note that:

• LP is big: km variables, kn + m constraints, km non-negativity constraints. The sizeof constraint matrix is km(kn + m) = k2nm + km2. So, this is a computationallychallenging problem!

18

Page 19: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• Constraint matrix is not TU.

• Optimal solution to a multi-commodity flow LP might be fractional.

• Finding a feasible integer solution is NP-hard.

7.4.2 Shortest Path

Given a digraph G = (V,A), two distinguished nodes s, t ∈ V , and nonnegative arc costscij for all (ij) ∈ A, find a minimum cost s− t path:

min∑

(ij)∈A cijxij

s.t.∑

(ij)∈δ+(i) xij −∑

(ji)∈δ−(i) xji = 1 (i = s)∑(ij)∈δ+(i) xij −

∑(ji)∈δ−(i) xji = 0 (i ∈ V \ {s, t})∑

(ij)∈δ+(i) xij −∑

(ji)∈δ−(i) xji = −1 (i = t)

xij ≥ 0 (i, j) ∈ A.

A NP-hard version is the so called Constrained Shortest Path Problem:

min∑

(ij)∈A cijxij

s.t.∑

(ij)∈δ+(i) xij −∑

(ji)∈δ−(i) xji = 1 (i = s)∑(ij)∈δ+(i) xij −

∑(ji)∈δ−(i) xji = 0 (i ∈ V \ {s, t})∑

(ij)∈δ+(i) xij −∑

(ji)∈δ−(i) xji = −1 (i = t)∑(ij)∈A tijxij ≤ T

xij ∈ {0, 1} (i, j) ∈ A.

7.4.3 Maximum Flow

Given a digraph G = (V,A), two distinguished nodes s, t ∈ V , and nonnegative arccapacities hij for all (ij) ∈ A, find a maximum flow form s to t. Adding a backward arcfrom t to s, the maximum s− t flow problem can be formulated as:

max xts

s.t.∑

(ij)∈δ+(i) xij −∑

(ji)∈δ−(i) xji = 0 (i ∈ V )

0 ≤ xij ≤ hij (i, j) ∈ A.

19

Page 20: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

Taking the dual we get:

min∑

(ij)∈A hijwij

s.t. ui − uj + wij ≥ 0 (i, j) ∈ Aut − us ≥ 1.

which corresponds to the minimum s− t cut problem:

minX{

∑(ij)∈δ+(X)

hij : s ∈ X ⊂ V \ {t} }.

7.4.4 Transportation

Given a digraph G = (V,A), the set of nodes is partitioned into two subsets S = {1, . . . ,m}and D = {1, . . . , n}, respectively the set of node-sources and the set of node-demands. Eachsource i ∈ S has a quantity si to send, and each destination j ∈ D has a quantity dj toreceive. The cost of shipping one unit of material from source i to destination j is cij. Welook for a shipping from sources to destinations with minimum cost:

min∑m

i=1

∑nj=1 cijxij

s.t.∑n

j=1 xij = si (i = 1 . . .m)∑mi=1 xij = dj (j = 1 . . . n)

xij ≥ 0 (i, j) ∈ A.

Note that the problem is feasible iff∑

i∈S si =∑

j∈D dj Also, note that if m = n andsi = dj = 1 for all i, j, the problem corresponds to the Assignment problem, which is indeedanother “easy” problem.

7.5 Minimum Spanning Tree

We are given an undirected graph G = (V,E), a subset of edges T ⊆ E is a spanning treeiff any two of the following conditions hold:

1. connected

2. acyclic

3. n− 1 edges

20

Page 21: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

We use conditions 2 and 3 and look for a minimum cost spanning tree in G:

min∑

e∈E wexe

s.t.∑

e∈E xe = n− 1∑e∈E(S) xe ≤ |S| − 1 ∀S ⊂ V (23)

xe ∈ {0, 1}|E|.

Note that:

• MST is an “easy” problem, but the constraint matrix is not TU and the number ofconstraints is exponential.

• This formulation corresponds to the integral hull of MST incidence vectors.

• Another valid formulation can be obtained by substituing subtour elimination (23)constraints with the following connectivity constraints:∑

e∈δ(S)

xe ≥ 1 ∀S ⊂ V. (24)

For a di-graph G = (A, V ) the problem is known as shortest spanning arborescence withroot r (SSA-r), and has the following formulation:

min∑

(ij)∈Awijxij∑(ij)∈δ−(j) xij = 1 ∀j ∈ V, j 6= r (25)∑(ir)∈δ−(r) xir = 0∑(ij)∈δ+(S) xij ≥ 1 ∀S ⊂ V, r ∈ S (26)

xij ∈ {0, 1}|A|.

Constraints (25) can be substituted by the following cardinality constraints:

s.t.∑

(ij)∈A xij = n− 1 (27)

(SSA-r) is an “easy” problem and can be solved in O(n2) time.

21

Page 22: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

7.6 Maximum Matching

We are given an undirected graph G = (V,E), a subset of edges M ⊆ E is a matching in Giff all edges in M are non-incident. We look for a maximum weight matching in G:

max∑

e∈E wexe

s.t.∑

e∈δ(i) xe ≤ 1 ∀i ∈ V (28)

xe ∈ {0, 1}|E|.

Note that:

• Matching is an “easy” problem, but the formulation above with degree constraints (28),although valid, does not describe the integral hull of matching incidence vectors.

• In fact, we need to add the following odd-set inequalities:

∑e∈E(S)

xe ≤|S| − 1

2∀S ⊆ V, |S| ≥ 3 odd (29)

• The formulation with (28) and (29) describes the integral hull of matching incidencevectors.

• So, matching is another “easy” problem where the constraint matrix is not TU andthe number of constraints is exponential.

Note that:

• Maximum Matching and Minimum Vertex Cover form a weak dual pair.

• Konig Theorem: Strong duality holds if and only if the graph is bipartite, indeed, ifthe graph is bipartite, the constraint matrix is TU.

• The (linear) assignment problem corresponds to a minimum cost perfect matchingproblem on a bipartite graph.

8 Hard feasibility problems

Example: Satisfability Problem (SAT)

This is a NP-complete feasibility problem.We are given:

• a finite set N = {1, . . . , n} (aka the literals)

22

Page 23: Modeling with Integer ProgrammingModeling with Integer Programming Laura Galli December 18, 2014 We can use 0-1 (binary) variables for a variety of purposes, such as: Modeling yes/no

• m pairs of subsets of N , Ci = (C+i , C

−i ) (aka the clauses)

• an instance is feasible iff the set:

{x ∈ Bn |∑j∈C+

i

xj +∑j∈C−

i

(1− xj) ≥ 1 i = 1, . . . ,m}

is nonempty.

Example: Partition Problem

This is a another NP-complete feasibility problem.We are given:

• a finite set N = {1, . . . , n} of items with weights (a1, a2, . . . , an)

• an integer b

• an instance is feasible iff the set:

{x ∈ Bn |n∑j=1

ajxj = b}

is nonempty.

• The problem is still NP-complete if b =∑n

j=1 aj

2

9 The Combinatorial Explosion: Bang!

Assignment, 0-1 Knapsack, Set Covering, TSP, are all combinatorial problems, in the sensethat the optimal solution is some subset of a finite set. Thus, in principle, they could besolved by enumeration:

• Assignment: all possible permutations of {1, . . . , n} =⇒ n!

• 0-1 KP and Set Covering: all possible subsets of {1, . . . , n} =⇒ 2N

• TSP: all possible Hamiltonian tours =⇒ (n− 1)!

Using complete enumeration we can only hope to solve such problems for very smallvalues of n. So we need sth more clever...

23