Chapter 3: Discrete Optimization Integer...

23
Chapter 3: Discrete Optimization – Integer Programming Edoardo Amaldi DEIB – Politecnico di Milano [email protected] Sito web: http://home.deib.polimi.it/amaldi/OTT-13-14.shtml A.A. 2013-14 Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 1 / 23

Transcript of Chapter 3: Discrete Optimization Integer...

Page 1: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Chapter 3: Discrete Optimization – IntegerProgramming

Edoardo Amaldi

DEIB – Politecnico di [email protected]

Sito web: http://home.deib.polimi.it/amaldi/OTT-13-14.shtml

A.A. 2013-14

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 1 / 23

Page 2: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

3.1 Integer Programming models

A huge variety of practical decision-making problems arising in science, engineering andmanagement can be formulated/approximated as linear optimization problems where(some of) the variables must take integer/discrete values.

Generic discrete optimization problem:

minx∈X

c(x)

where X is a discrete set and c : X → R is the objective function.

Example: X ⊆ family of all subsets of a given finite set.

A natural and systematic way to study/investigate such problems is to express them asinteger (programming) optimization problems.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 2 / 23

Page 3: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Definitions:

A Mixed Integer Linear Programming (MILP) problem is an optimization problem like

min c t1x + c t2y

s.t. A1x + A2y ≥ b

x ≥ 0 integer, y ≥ 0

with matrices A1 ∈ Zm×n1 and A2 ∈ Zm×n2 , and vectors c1 ∈ Zn1 , c2 ∈ Zn2 and b ∈ Zm.

If all the variables are restricted to be integer, we have an Integer Linear Programming(ILP) problem:

min c tx

s.t. Ax ≥ b

x ≥ 0 integer.

If all the variables must take binary values, we have a Binary Linear Programming(0-1-ILP) problem.

Without loss of generality: only inequalities and all coefficients are integer.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 3 / 23

Page 4: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Observation: The integrality restriction on x is a nonlinear constraint since it can beformulated as

sin(πx) = 0

Proposition: 0-1-ILP is NP-hard, and ILP/MILP are at least as difficult.

Theory: No algorithm can find, for every instance of 0-1-ILP (ILP/MILP), an optimalsolution in polynomial time (in the instance size), unless P=NP.

Practice: Many medium-size (M)ILPs are extremely challenging!

Examples of feasible regions of an ILP and a MILP:

(Mixed) Integer Linear Programming is a powerful and versatile modeling framework forexpressing and tackling discrete optimization problems.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 4 / 23

Page 5: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Modeling techniques and examples

Binary variables allow to model a choice between two (several) alternatives and theassociation between two (several) entities.

Example 1: Binary Knapsack problem

Given

n objects

profit pi and weight ai for each object i , with 1 ≤ i ≤ n

knapsack maximum total weight b (capacity)

decide which objects to select so as to maximize total profit while respecting thecapacity constraint.

ILP formulation

Decision variables: xi = 1 if the i-th object is selected and xi = 0 otherwise, 1 ≤ i ≤ n

max∑n

i=1 pixi∑ni=1 aixi ≤ b

xi ∈ {0, 1} ∀i

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 5 / 23

Page 6: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

A number of direct applications (projects, investments,...) or indirect applications (assubproblem).

Proposition: Binary Knapsack is NP-hard.

Variants with additional constraints

- at most one object among a given subset of objects

- if i-th object selected then also j-th one

- multiple resource constraints (e.g., on volume, cost,...)

- ...

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 6 / 23

Page 7: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Example 2: Assignment problem

Given

n projects (jobs) and n persons (machines)

cost cij for assigning project i to person j , ∀ i , j ∈ {1, . . . , n}decide which project to assign to each person so as to minimize the total cost tocomplete all the projects.

Assumption: every person can perform any project, and each person (project) must beassigned to a single project (person).

n! feasible solutions (permutations)

ILP formulation

Decision variables: xij = 1 if i-th project is assigned to j-th person and xij = 0 otherwise,

with 1 ≤ i , j ≤ nmin

∑ni=1

∑nj=1 cijxij

s.t.∑n

i=1 xij = 1 ∀j∑nj=1 xij = 1 ∀i

xij ∈ {0, 1} ∀i , ∀j

Variants with: bipartite graph representing competences, different number of projectsand persons, resource constraints,...

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 7 / 23

Page 8: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Example 3: Set Covering problem (SC)

Given

finite groundset M = {1, 2, . . . ,m}collection {M1, . . . ,Mn} of n subsets of M ( Mj ⊆ M for j = 1, . . . , n)

cost cj of Mj for each j , with 1 ≤ j ≤ n

decide which subsets to select so as to minimize the total cost while covering all theelements of M.

Example:

ILP formulation

Decision variables: xj = 1 if subset Mj is selected and xj = 0 otherwise, with 1 ≤ j ≤ n

min∑n

j=1 cjxj

s.t.∑

j :i∈Mjxj ≥ 1 ∀i (1)

xj ∈ {0, 1} ∀j

where the inequalities (1) are the so-called covering constraints.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 8 / 23

Page 9: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Set Covering problem:

min

{n∑

j=1

cjxj : Ax ≥ 1, x ∈ {0, 1}n}

where A = [aij ] with aij = 1 if i ∈ Mj and aij = 0 otherwise, and 1 = (1, 1, . . . , 1)t

Example: emergency service location (ambulances or fire stations)

M = { areas to be covered }, Mj = { areas reachable in at most 10 minutes fromcandidate site j }

Proposition: Set Covering is NP-hard.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 9 / 23

Page 10: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Set Packing problem:

max

{n∑

j=1

cjxj : Ax ≤ 1, x ∈ {0, 1}n}

where the parameters cj represent ”profits”

Example: location of facilities with large environmental impact (rubbish dump orincinerators)

M = { cities }, Mj = { cities with environmental impact level for candidate site j abovethreshold }

Proposition: Set Packing is NP-hard.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 10 / 23

Page 11: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Set Partitioning problem:

min or max

{n∑

j=1

cjxj : Ax = 1, x ∈ {0, 1}n}

where the parameters cj may represent ”costs” or ”profits”

Example: aircrew scheduling (assign flights to pilots)

Consider a predefined planning horizon

M = { flights } where ”flight” = single flight leg (takeoff-landing) to be carried outwithin a predefined time window

Mj = { feasible subsets of flights } where ”feasible subset of flights” = a subset that canbe combined and carried out by a single pilot while respecting different constraints (e.g.,compatible flights, rest periods, total flight time,...)

N.B.: Possibly huge number of feasible subsets of flights

Other example: distribution planning (assign customers to routes)

Proposition: Set Partitioning is NP-hard.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 11 / 23

Page 12: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Example 4: Asymmetric Traveling Salesman Problem (ATSP)

Given

a complete directed graph G = (V ,A) with n = |V | nodes

a cost cij ∈ R for each arc (i , j) ∈ A (in case cij =∞)

determine a Hamiltonian circuit (tour), i.e., a circuit that visits exactly once each nodeand comes back to the starting node, of minimum total cost.

Example:

Since G is complete, there are (n − 1)! Hamiltonian circuits.

Proposition: ATSP is NP-hard.

Variety of applications: planning, logistics, microchip manufacturing, (DNA)sequencing,...

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 12 / 23

Page 13: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Also symmetric TSP version with undirected graph G .

Website devoted to TSP: http://www.math.uwaterloo.ca/tsp/

Many variants with

- time windows (earliest and latest arrival time)

- precedence constraints

- capacity constraint

- several vehicles (”Vehicle Routing Problem”)

- ...

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 13 / 23

Page 14: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

An ILP formulation

Decision variables: xij = 1 if arc (i , j) is included in the Hamiltonian circuit and xij = 0otherwise, with (i , j) ∈ A

min∑

(i,j)∈A cijxij

s.t.∑

j∈V :j 6=i xij = 1 ∀i (2)∑i∈V :i 6=j xij = 1 ∀j (3)∑

(i,j)∈δ+(S) xij ≥ 1 ∀ S ⊂ V ,S 6= ∅ (4)

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

where

equations (2) and (3) are the assignment constraints,

δ+(S) = {(i , j) ∈ A : i ∈ S , j ∈ V \ S},

constraints (4) are the so-called cut-set inequalities.

Observation: The number of constraints (4) grows exponentially with the number ofnodes n.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 14 / 23

Page 15: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Alternative ILP formulation

Substitute the cut-set inequalities∑(i,j)∈δ+(S)

xij ≥ 1 ∀ S ⊂ V ,S 6= ∅

with the so-called subtour elimination inequalities:∑(i,j)∈E(S)

xij ≤ |S | − 1 ∀ S ⊆ V , 2 ≤ |S | ≤ n − 1 (5)

where E(S) = {(i , j) ∈ A : i ∈ S , j ∈ S} for S ⊆ V .

Example:

Observation: The number of constraints (5) grows exponentially with the number ofnodes n.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 15 / 23

Page 16: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

MILP models

A pair of continuous and binary variables allow to model a typical nonlinear fixedcharge cost function.

Example 5: Uncapacitated Facility Location (UFL)

Given

M = {1, 2, . . . ,m} set of clients

N = {1, 2, . . . , n} set of candidate sites where a depot can be located

fixed cost fj for opening a depot in candidate site j , ∀j ∈ N

cij transportation cost if the whole demand of client i is served from depot j ,∀i ∈ M and ∀j ∈ N

decide where to locate the depots and how to serve the clients so as to minimize thetotal (transportation and fixed) costs while satisfying all demands.

Example:

Proposition: UFL is NP-hard.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 16 / 23

Page 17: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

MILP formulation

Decision variables:

xij = fraction of demand of client i served by depot j , with 1 ≤ i ≤ m and 1 ≤ j ≤ n

yj = 1 if depot j is opened and yj = 0 otherwise, with 1 ≤ j ≤ n

min∑

i∈M∑

j∈N cijxij +∑

j∈N fjyj

s.t.∑

j∈N xij = 1 ∀i ∈ M∑i∈M xij ≤ myj ∀j ∈ N (6)

yj ∈ {0, 1} ∀j ∈ N

0 ≤ xij ≤ 1 ∀i ∈ M, j ∈ N

where the n constraints (6) link the corresponding variables xij and yj .

Capacitated FL variant: If di is the demand of client i and kj the capacity of depot j ,capacity constraints: ∑

i∈M

dixij ≤ kjyj ∀j ∈ N

N.B.: The solution with, for all i and a given j , xij = 0 and yj = 1 is feasible for MILP,but it cannot be optimal (minimization with fj > 0).

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 17 / 23

Page 18: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Example 6: Uncapacitated Lot-Sizing (ULS)

A company has to plan the production of a single type of product for the next n periods.

Suppose that the stock is empty at the beginning of the planning horizon and that 50units must be in stock at the end.

Given

ft fixed cost for producing during period t

pt unit production cost in period t

ht unit storage cost in period t

dt demand in period t

determine a production plan for the next n periods that minimizes the total (productionand storage) costs, while satisfying the demand in each period.

MILP formulation

Decision variables:

xt = amount produced in period t, with 1 ≤ t ≤ n

st = amount in stock at the end of period t, with 0 ≤ t ≤ n

yt = 1 if production occurs in period t and yt = 0 otherwise, with 1 ≤ t ≤ n

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 18 / 23

Page 19: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

MILP formulation

Decision variables:

xt = amount produced in period t, with 1 ≤ t ≤ n

st = amount in stock at the end of period t, with 0 ≤ t ≤ n

yt = 1 if production occurs in period t and yt = 0 otherwise, with 1 ≤ t ≤ n

min∑n

t=1 ptxt +∑n

t=1 htst +∑n

t=1 ftyt

s.t. st = st−1 + xt − dt ∀txt ≤ Myt ∀t

s0 = 0, sn = 50 ∀tst , xt ≥ 0 ∀tyt ∈ {0, 1} ∀t

where M > 0 is large enough (upper bound on the maximum amount produced duringany period).

For instance: xt ≤ (∑n

t=1 dt + sn − s0)yt

N.B.: Since st =∑t

i=1 xi + s0 −∑t

i=1 di , it is possible to delete the storage variables st

How can we account for a minimum lot size?

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 19 / 23

Page 20: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

An appropriate combination of continuous and binary variables allows to model arbitrarypiecewise linear cost functions.

Example 7: Minimization of piecewise linear cost functions

Consider an arbitrary (not necessarily convex) piecewise linear function f (x), withf : [x1, xk ]→ R.

Suppose that x1 < x2 < . . . < xk and that f (x) is specified by the points (x i , f (x i )), fori = 1, . . . , k.

Example of minx∈[x1,xk ] f (x):

Any x ∈ [x1, xk ] and the corresponding value f (x) can be expressed as

x =k∑

i=1

λixi and f (x) =

k∑i=1

λi f (x i ) withk∑

i=1

λi = 1 and λ1, . . . , λk ≥ 0,

Clearly, the choice of the coefficients λi is not unique.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 20 / 23

Page 21: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

It becomes unique if we require that at most two consecutive λi can be nonzero.

Any x ∈ [x i , x i+1] is then represented as

x = λixi + λi+1x

i+1 with λi + λi+1 = 1 and λi ≥ 0, λi+1 ≥ 0.

By defining

yi = 1 if x i ≤ x ≤ x i+1 and yi = 0 otherwise, for i = 1, . . . , k − 1

the problem minx∈[x1,xk ] f (x) can be formulated as follows:

min∑k

i=1 λi f (x i )

s.t. λ1 ≤ y1, λk ≤ yk−1

λi ≤ yi−1 + yi i = 2, . . . , k − 1∑ki=1 λi = 1

∑k−1i=1 yi = 1

λi ≥ 0, yi ∈ {0, 1} i = 1, . . . , k

N.B.: If yj = 1 then λi = 0 for all i , 1 ≤ i ≤ n, different from j or j + 1.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 21 / 23

Page 22: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

Binary variables also allow to impose disjunctive constraints:

either a1x ≤ b1 or a2x ≤ b2

with x ∈ R and 0 ≤ x ≤ u, where u is the upper bound vector.

Example 8: Scheduling problem

Given

m machines and n products

for each product j , we know the deadline dj and the time pjk needed to processproduct j on machine k, for ≤ k ≤ m

determine an optimal schedule so as to minimize the time needed to complete allproducts, while satisfying all deadlines.

Assumptions:

- Each product must be processed on all the machines according to the order of themachine indices.

- Products cannot be processed simultaneously (on the same machine) and, whenprocessed, they cannot be stopped.

Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 22 / 23

Page 23: Chapter 3: Discrete Optimization Integer Programminghome.deib.polimi.it/amaldi/LucidiOTT-13-14/IP-models-14.pdfChapter 3: Discrete Optimization { Integer Programming Edoardo Amaldi

MILP formulation

Decision variables:

tjk = time when product j is started on machine k, with 1 ≤ j ≤ n and 1 ≤ k ≤ m

t time in when all the products are completed

yijk = 1 if product i is processed before product j on machine k, and yijk = 0otherwise, with 1 ≤ i , j ≤ n and 1 ≤ k ≤ m

min t

s.t. tjm + pjm ≤ t ∀jtjm + pjm ≤ dj ∀j

tjk + pjk ≤ tj,k+1 ∀j , ∀k ∈ {1, . . . ,m − 1}tik + pik ≤ tjk + M(1− yijk) ∀k, ∀i ,∀j with i < j (7)

tjk + pjk ≤ tik + Myijk ∀k, ∀i ,∀j with i < j (8)

t ≥ 0, tjk ≥ 0 ∀j , ∀kyijk ∈ {0, 1} ∀i ,∀j ,∀k

where M is a large enough parameter (e.g., M =∑n

j=1 dj)

Constraints (7) and (8) ensure that no pair i , j of products are processed simultaneouslyon the same machine (either i preceds j or j preceds i).

Extension: each product must be processed on (a subset) of machines in a possiblydifferent order.Edoardo Amaldi (PoliMI) Ottimizzazione A.A. 2013-14 23 / 23