ThanhLX_VJU_OR_IP
ThanhLX_VJU_OR_IP
Lê Xuân Thanh
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Formulation
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Formulation
In words:
Optimize a linear function
subject to linear constraints on integer variables
max | min c1 x1 + c2 x2 + . . . + cn xn
subject to ai1 x1 + ai2 x2 + . . . + ain xn ≤ bi (i = 1, . . . , m1 )
ai1 x1 + ai2 x2 + . . . + ain xn ≥ bi (i = m1 + 1, . . . , m2 )
ai1 x1 + ai2 x2 + . . . + ain xn = bi (i = m2 + 1, . . . , m)
xj ∈ Z (j = 1, . . . , n)
Formulation
In words:
Optimize a linear function
subject to linear constraints of ≤-type
on non-negative integer variables
Explicit standard formulation:
maximize c1 x1 + c2 x2 + . . . + cn xn
subject to a11 x1 + a12 x2 + . . . + a1n xn ≤ b1
a21 x1 + a22 x2 + . . . + a2n xn ≤ b2
...
am1 x1 + am2 x2 + . . . + amn xn ≤ bm
x1 , x2 , . . . , xn ∈ Z+
Matrix form:
max ct x
s.t. Ax ≤ b
x ∈ Zn+
Formulation
Variants
max ct x + dt y
s.t. Ax + Dy ≤ b
x≥0
y ≥ 0 and integer
max ct x
s.t. Ax ≤ b
x ∈ {0, 1}n
Modeling General framework
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Modeling General framework
If difficulties arise:
Define additional or alternative variables and iterate
Modeling General framework
Problem description:
n people, n jobs, each person is assigned to exactly one job
Cost cij if person i is assigned to job j
Aim: find a minimum cost assignment
Define variables: xij = 1 if person i does job j, otherwise xij = 0
Define constraints:
Each person does exactly one job
∑
n
xij = 1 ∀i = 1, . . . , n
j=1
Define objective:
∑
n ∑
n
min cij xij
i=1 j=1
Modeling General framework
Problem description:
Budget amount b for investments in n projects
Each project j has outlay aj and expected return cj
Aim: Find a portfolio of maximum expected return
Define variables: xj = 1 if project j is selected, otherwise xj = 0
Define constraints:
The budget cannot be exceeded
∑
n
aj xj ≤ b
j=1
Define objective:
∑
n
max c j xj
i=1
Modeling General framework
Problem description:
m regions, n potential positions for emergency service centers
Given A = (aij )m×n , in which
aij = 1 if center j can service region i, otherwise aij = 0
Center j costs cj to install
Aim: Choose a minimum set of centers to cover all regions
Define variables: xj = 1 if center j is selected, otherwise xj = 0
Define constraints:
Each region must be serviced by at least one center
∑
n
aij xj ≥ 1 ∀i = 1, . . . , m
j=1
Define objective:
∑
n
min cj xj
i=1
Modeling Basic modeling techniques
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Modeling Basic modeling techniques
Outline
Constraint Expressed by
∑
At most one xi may be 1 xi ≤ 1
∑
i∈I
Exactly one xi equals 1 xi = 1
∑
i∈I
At least one xi may be 1 xi ≥ 1
i∈I
Modeling Basic modeling techniques
Application: Sudoku
Given a 9 × 9 grid (as a composition of nine 3 × 3 subgrids).
Rules:
Only digits from 1 to 9 can be filled in the grid
Each cell of the grid must be filled by exactly one digit
Each digit appears exactly once in each column, row, and 3 × 3 subgrid
Input: a partially complete grid
Objective: completely fill the grid
8 9
1 3 9
5 2 4
2 6 8
9 7 6 5
3 6 5
1 3 5
8 7 1
4 5
Modeling Basic modeling techniques
Application: Sudoku
Given a 9 × 9 grid (as a composition of nine 3 × 3 subgrids).
Rules:
Only digits from 1 to 9 can be filled in the grid
Each cell of the grid must be filled by exactly one digit
Each digit appears exactly once in each column, row, and 3 × 3 subgrid
Input: a partially complete grid
Objective: completely fill the grid
3 6 7 4 2 5 8 9 1
4 2 1 3 8 9 5 7 6
8 5 9 6 7 1 2 3 4
5 7 4 1 3 2 6 8 9
9 1 8 7 4 6 3 2 5
2 3 6 5 9 8 4 1 7
1 8 3 9 6 4 7 5 2
6 9 2 8 5 7 1 4 3
7 4 5 2 1 3 9 6 8
Modeling Basic modeling techniques
(1, 1)
(9, 9)
{
1 if k is filled into cell (i, j)
xijk =
0 otherwise
Modeling Basic modeling techniques
8 9 xijk = 1 ∀(i, j, k) ∈ G
1 3 9
in which
5 2 4
2 6 8 G = {(i, j, k) | k is clue
9 7 6 5 in cell (i, j)}
3 6 5
For example:
1 3 5
8 7 1 x178 = 1
4 5
x189 = 1
{ ...
1 if k is filled into cell (i, j)
xijk = x935 = 1
0 otherwise
Modeling Basic modeling techniques
8 9
1 3 9
Cell (1, 2) for instance:
5 2 4
2 6 8 ∑
9
6
x12k = 1
9 7 5
k=1
3 6 5
1 3 5 In general:
8 7 1
∑
9
4 5 xijk = 1 ∀i, j = 1, . . . , 9
k=1
{
1 if k is filled into cell (i, j)
xijk =
0 otherwise
Modeling Basic modeling techniques
8 9
1 3 9 Row 1 for instance:
5 2 4
For each k = 1, . . . , 9 we have
2 6 8 ∑
9
9 7 6 5 x1jk = 1
3 6 5 j=1
1 3 5 In general:
8 7 1
4 5 ∑
9
xijk = 1 ∀i, k = 1, . . . , 9
{ j=1
1 if k is filled into cell (i, j)
xijk =
0 otherwise
Modeling Basic modeling techniques
8 9
1 3 9 Column 1 for instance:
5 2 4 For each k = 1, . . . , 9 we have
2 6 8
∑
9
9 7 6 5 xi1k = 1
3 6 5 i=1
1 3 5 In general:
8 7 1
4 5 ∑
9
xijk = 1 ∀j, k = 1, . . . , 9
{ i=1
1 if k is filled into cell (i, j)
xijk =
0 otherwise
Modeling Basic modeling techniques
{ ∀k = 1, . . . , 9, ∀(p, q) ∈ B
1 if k is filled into cell (i, j)
xijk = (B = {top left cell of each block})
0 otherwise
Modeling Basic modeling techniques
Formulation:
xijk = 1 ∀(i, j, k) ∈ G
∑
xijk = 1 ∀i, j ∈ S
k∈S
∑
xijk = 1 ∀j, k ∈ S
i∈S
∑
xijk = 1 ∀i, k ∈ S
j∈S
∑
p+2 ∑
q+2
xijk = 1 ∀k ∈ S, (p, q) ∈ B
i=p j=q
Outline
Corollary
Setting:
xi is a binary variable for all i ∈ I finite index set
I = I0 ⊔ I 1
y is a variable satisfying 0 ≤ y ≤ 1
Logical implication
“if xi = 0 ∀i ∈ I0 and xi = 1 ∀i ∈ I1 then y = 0
can be exactly expressed by
∑ ∑
y≤ xi + (1 − xi )
i∈I0 i∈I1
(1, 1)
(n, n)
{
1 if a queen is placed at cell (i, j),
xij =
0 otherwise.
Modeling Basic modeling techniques
i.e., ∑
If xij = 1, then xhk = 0
(h,k)∈T(i,j)
Formulation: ∑
xhk ≤ |T(i, j)|(1 − xij )
(h,k)∈T(i,j)
Modeling Basic modeling techniques
Outline
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Modeling Advanced modeling techniques
Outline
Disjunctive constraints
Modeling Advanced modeling techniques
x1
0
1
x2
Modeling Advanced modeling techniques
Outline
Disjunctive constraints
Modeling Advanced modeling techniques
.
Definition
.
Let x = (x1 , . . . , xn ) ∈ {0, 1}n .
Component xi is an idle slot if xi = 0 and
Examples:
x = (1, 0, 1, 0, 1): x2 and x4 are idle slots
x = (0, 1, 0, 0, 1): x3 and x4 are idle slots, x1 is not
Modeling Advanced modeling techniques
f : {0, 1}n → Z+
x 7→ number of idle slots in x
is
. called idle-slot counting function
Examples:
x Value f(x) x Value f(x)
x1 (0, 0, 0, 0) 0 x9 (1, 0, 0, 0) 0
x2 (0, 0, 0, 1) 0 x10 (1, 0, 0, 1) 2
x3 (0, 0, 1, 0) 0 x11 (1, 0, 1, 0) 1
x4 (0, 0, 1, 1) 0 x12 (1, 0, 1, 1) 1
x5 (0, 1, 0, 0) 0 x13 (1, 1, 0, 0) 0
x6 (0, 1, 0, 1) 1 x14 (1, 1, 0, 1) 1
x7 (0, 1, 1, 0) 0 x15 (1, 1, 1, 0) 0
x8 (0, 1, 1, 1) 0 x16 (1, 1, 1, 1) 0
Modeling Advanced modeling techniques
Example
x Value f(x) x Value f(x)
x1 (0, 0, 0, 0) 0 x9 (1, 0, 0, 0) 0
x2 (0, 0, 0, 1) 0 x10 (1, 0, 0, 1) 2
x3 (0, 0, 1, 0) 0 x11 (1, 0, 1, 0) 1
x4 (0, 0, 1, 1) 0 x12 (1, 0, 1, 1) 1
x5 (0, 1, 0, 0) 0 x13 (1, 1, 0, 0) 0
x6 (0, 1, 0, 1) 1 x14 (1, 1, 0, 1) 1
x7 (0, 1, 1, 0) 0 x15 (1, 1, 1, 0) 0
x8 (0, 1, 1, 1) 0 x16 (1, 1, 1, 1) 0
f(x) = χ6 (x) + 2χ10 (x) + χ11 (x) + χ12 (x) + χ14 (x)
in which
χ6 (x) = (1 − x1 )x2 (1 − x3 )x4
χ10 (x) = x1 (1 − x2 )(1 − x3 )x4
χ11 (x) = x1 (1 − x2 )x3 (1 − x4 )
χ12 (x) = x1 (1 − x2 )x3 x4
χ14 (x) = x1 x2 (1 − x3 )x4
Modeling Advanced modeling techniques
Example: Representation 1
Example: Representation 2
Example: Representation 3
Outline
Disjunctive constraints
Modeling Advanced modeling techniques
Disjunctive constraints
at x − b ≤ My1
ct x − d ≤ My2
y1 + y2 = 1
y1 , y2 ∈ {0, 1}
0≤x≤u
1 ≤ |z| ≤ 8
in which z ∈ R
Modeling Advanced modeling techniques
1 ≤ |z| ≤ 8, y ∈ R
can be linearized by
z+ − z− = z
z+ + z− ≥ 1
a+ ≤ z+ ≤ 8a+
a− ≤ z− ≤ 8a−
a+ + a− = 1
z+ , z− ∈ R
a+ , a− ∈ {0, 1}
Modeling Advanced modeling techniques
Setting:
(1, 1)
(9, 9)
xij = value filled into cell (i, j) |xij −xik | ≥ 1 ∀i, j, k = 1, . . . , 9, j < k
Modeling Advanced modeling techniques
8 9
1 3 9
5 2 4
2 6 8
9 7 6 5
|xij − xkj | ≥ 1
3 6 5
∀i, j, k = 1, . . . , 9, i < k
1 3 5
8 7 1
4 5
8 9
1 3 9
5 2 4
|xp+i,q+j − xp+k,q+ℓ | ≥ 1
2 6 8
∀(p, q) ∈ B
6
9 7 5
∀i, j, k, ℓ ∈ {0, 1, 2} :
3 6 5 3i + j < 3k + ℓ
1 3 5
7 1
in which
8
B = {top left cell of each block}
4 5
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Solution method Total unimodularity
Outline
Motivation
Applications
Solution method Total unimodularity
Motivation
Linear relaxation:
.
Observation
.
If P is integral, then the optimal solution of (LP) is integral,
and
. hence the solution also solves (IP)
Question:
When P is integral?
Solution method Total unimodularity
Outline
Motivation
Applications
Solution method Total unimodularity
.
Definition
.
A matrix A is called totally unimodular
. every square submatrix of it has determinant 1, −1, or 0
if
Examples:
1 −1 0
0 1 −1 is totally unimodular
−1 0 1
1 1 0
0 1 1is not totally unimodular
1 0 1
Solution method Total unimodularity
.
Proposition
.
A matrix A = (aij )m×n is totally unimodular if the following three
conditions hold together.
(i) aij ∈ {0, 1, −1} for all i = 1, . . . , m and j = 1, . . . , n.
(ii) At
∑mmost two nonzero entries exist on each column, i.e.,
i=1 |aij | ≤ 2 for all j = 1, . . . , n.
(iii) The set R = {1, . . . , m} of rows can be partitioned into two
subsets R1 , R2 such that each column j ∈ {1, . . . , n}
containing two nonzero entries satisfies
∑ ∑
aij − aij = 0.
. i∈R 1 i∈R2
Solution method Total unimodularity
Corollaries
.
Theorem
.
The node-edge incidence matrices of bipartite graphs
are
. totally unimodular
1 1 0 0 0 0 1 4
0 0 1 1 0 0
0 0 0 0 1 1
0 0 1 0 0 0
2 5
1 0 0 1 1 0
0 1 0 0 0 1
3 6
Solution method Total unimodularity
Corollaries
.
Theorem
.
The node-arc incidence matrix of every simple directed graph
is
. totally unimodular
−1 −1 0 0 1 0 1 2
1 0 −1 −1 0 0
0 0 1 0 −1 1
0 1 0 1 0 −1
3 4
Solution method Total unimodularity
Main theorem
Question (recall):
When P := {x ∈ Rn | Ax ≤ b, x ≥ 0} is integral?
.
Theorem
.
A matrix A ∈ Zm×n is totally unimodular if and only if the polyhedron
.{x ∈ R | Ax ≤ b, x ≥ 0} is integral for each vector b ∈ Z
n m
Solution method Total unimodularity
Outline
Motivation
Applications
Solution method Total unimodularity
600
2 30 4
100
70 400
800 60
10
50 30
600 300 600
10
60
3 400 5
.
Proposition
.
Let Mx ≤ b, x ≥ 0 be the matrix form of the constraints of (MNCF).
Then
. the matrix M is totally unimodular.
.
Theorem
.
If bi ∈ Z for all i ∈ V and hij ∈ Z for all (i, j) ∈ A, the optimal solutions of
(MCNF)
. are integral.
Solution method Total unimodularity
3
2 4
2 6
s 1 5 1 4 6 t
8 2
5
3 5
Variables:
{
1 if arc (i, j) is in the shortest path from s to t
xij =
0 otherwise
IP formulation:
∑
(SPIP ) min cij xij (4)
(i,j)∈A
∑ ∑
s.t. xsj − xjs = 1 (5)
j∈δ + (s) j∈δ − (s)
∑ ∑
xtj − xjt = −1 (6)
j∈δ + (t) j∈δ − (t)
∑ ∑
xij − xji = 0 ∀i ∈ N\{s, t} (7)
j∈δ + (i) j∈δ − (i)
LP relaxation:
∑
(SPLP ) min cij xij
(i,j)∈A
∑ ∑
s.t. xsj − xjs = 1
j∈δ + (s) j∈δ − (s)
∑ ∑
xtj − xjt = −1
j∈δ + (t) j∈δ − (t)
∑ ∑
xij − xji = 0 ∀i ∈ N\{s, t}
j∈δ + (i) j∈δ − (i)
.
Theorem
.
The optimal solutions of the linear program (SPLP ) are integral, hence
.any optimal solution of (SPLP ) is also an optimal solution of (SPIP ).
Solution method Branch-and-bound
Contents
1. Formulation
2. Modeling
General framework
Basic modeling techniques
Advanced modeling techniques
3. Solution method
Total unimodularity
Branch-and-bound
Solution method Branch-and-bound
Weight Value
Type 1 3 kg 3$
Type 2 5 kg 4$
Constraints:
at most 4 items
at most 15 kg
Objective: bring
maximum value
Solution method Branch-and-bound
Weight Value
max 3x1 + 4x2 Type 1 3 kg 3$
subject to Type 2 5 kg 4$
x1 + x2 ≤ 4
Constraints:
3x1 + 5x2 ≤ 15
at most 4 items
x1 , x2 ∈ Z+ at most 15 kg
Objective: bring
maximum value
Solution method Branch-and-bound
4
max 3x1 + 4x2
3
subject to
2
x1 + x2 ≤ 4
3x1 + 5x2 ≤ 15 1
x1 , x2 ∈ Z+
0 1 2 3 4 5 x1
Solution method Branch-and-bound
LP relaxation x2
4
max 3x1 + 4x2
3
subject to
x1 + x2 ≤ 4 2 (2.5, 1.5)
3x1 + 5x2 ≤ 15 1
Z
Z
x1 , x2 ∈ + R
Z
0 1 2 3 4 5 x1
Solution method Branch-and-bound
(P2 ) max = 13
0 1 2 3 4 5 x1
at (x1 , x2 ) = (3, 1) ∈ Z2
Solution method Branch-and-bound
(P2 ) max = 13
at (x1 , x2 ) = (3, 1) ∈ Z2
Solution method Branch-and-bound
x2
(P2 ) max = 13
0 1 2 3 4 5 x1
at (x1 , x2 ) = (3, 1) ∈ Z2
Solution method Branch-and-bound
x2
(P1.2.1.1 ) max = 12
4
at (x1 , x2 ) = (0, 3) ∈ Z2 (0, 3)
3 opt = 12
(P1.2.1.1 ) max = 11
2
at (x1 , x2 ) = (1, 2) ∈ Z2 (1, 2)
(3, 1)
opt = 11
1 opt = 13
(P2 ) max = 13
at (x1 , x2 ) = (3, 1) ∈ Z2 0 1 2 3 4 5 x1
Solution method Branch-and-bound
x2
4
max = 13 3
2
at (x1 , x2 ) = (3, 1) ∈ Z 2
(3, 1)
1 opt = 13
0 1 2 3 4 5 x1
Solution method Branch-and-bound
Branch-and-bound method