Tutorial: Operations Research in Constraint Programming: John Hooker Carnegie Mellon University
Tutorial: Operations Research in Constraint Programming: John Hooker Carnegie Mellon University
Constraint Programming
John Hooker
Carnegie Mellon University
May 2009
Revised June 2009
CPAIOR tutorial
May 2009 Slide 1
CPAIOR tutorial
May 2009 Slide 2
Complementary Strengths
CP:
Inference methods
Modeling
Exploits local structure
OR:
Relaxation methods
Duality theory
Exploits global structure
CPAIOR tutorial
May 2009 Slide 3
Computational Advantage of
Integrating CP and OR
Using CP + relaxation from MILP
Problem
Speedup
Focacci, Lodi,
Milano (1999)
Lesson
timetabling
2 to 50 times faster
than CP
Refalo (1999)
Piecewise linear
costs
2 to 200 times
faster than MILP
Flow shop
scheduling, etc.
4 to 150 times
faster than MILP.
Thorsteinsson &
Ottosson (2001)
Product
configuration
30 to 40 times
faster than CP,
MILP
CPAIOR tutorial
May 2009 Slide 4
Computational Advantage of
Integrating CP and MILP
Using CP + relaxation from MILP
Problem
Speedup
Sellmann &
Fahle (2001)
Automatic
recording
1 to 10 times faster
than CP, MILP
Van Hoeve
(2001)
Stable set
problem
Better than CP in
less time
Bollapragada,
Ghattas &
Hooker (2001)
Structural design
(nonlinear)
Up to 600 times
faster than MILP.
2 problems: <6 min
vs >20 hrs for MILP
Scheduling with
earliness &
tardiness costs
Solved 67 of 90, CP
solved only 12
CPAIOR tutorial
May 2009 Slide 5
Computational Advantage of
Integrating CP and MILP
Using CP-based Branch and Price
Easton,
Nemhauser &
Trick (2002)
CPAIOR tutorial
May 2009 Slide 6
Problem
Speedup
Urban transit
crew scheduling
Optimal schedule
for 210 trips, vs.
120 for traditional
branch and price
Traveling
tournament
scheduling
First to solve
8-team instance
Computational Advantage of
Integrating CP and MILP
Using CP/MILP Benders methods
Problem
Speedup
Jain &
Grossmann
(2001)
Min-cost planning
& scheduing
20 to 1000 times
faster than CP,
MILP
Thorsteinsson
(2001)
Min-cost planning
& scheduling
10 times faster
than Jain &
Grossmann
Timpe (2002)
Polypropylene
batch scheduling
at BASF
Solved previously
insoluble problem
in 10 min
CPAIOR tutorial
May 2009 Slide 7
Computational Advantage of
Integrating CP and MILP
Using CP/MILP Benders methods
Problem
Speedup
Benoist, Gaudin,
Rottembourg
(2002)
Solved twice as
many instances
as traditional
Benders
Hooker (2004)
Min-cost,
min-makespan
planning & cumulative
scheduling
100-1000 times
faster than CP,
MILP
Hooker (2005)
Min tardiness
planning & cumulative
scheduling
10-1000 times
faster than CP,
MILP
CPAIOR tutorial
May 2009 Slide 8
ECLiPSe
Exchanges information between ECLiPSEe solver, Xpress-MP
OPL Studio
Combines CPLEX and ILOG CP Optimizer with script language
Mosel
Combines Xpress-MP, Xpress-Kalis with low-level modeling
BARON
Global optimization with relaxation + domain reduction
SIMPL
Full integration with high-level modeling (prototype)
SCIP
Combines MILP and CP-based propagation
CPAIOR tutorial
May 2009 Slide 9
CPAIOR tutorial
May 2009 Slide 10
Detailed Outline
CPAIOR tutorial
May 2009 Slide 11
Detailed Outline
CP Concepts
Consistency
Hyperarc Consistency
Modeling Examples
CP Filtering Algorithms
Element
Alldiff
Disjunctive Scheduling
Cumulative Scheduling
Linear Relaxation and CP
Why relax?
Algebraic Analysis of LP
Linear Programming Duality
LP-Based Domain Filtering
Example: Single-Vehicle Routing
Disjunctions of Linear Systems
CPAIOR tutorial
May 2009 Slide 12
Detailed Outline
CPAIOR tutorial
May 2009 Slide 13
Detailed Outline
Dynamic Programming in CP
Example: Capital Budgeting
Domain Filtering
Recursive Optimization
CP-based Branch and Price
Basic Idea
Example: Airline Crew Scheduling
CP-based Benders Decomposition
Benders Decomposition in the Abstract
Classical Benders Decomposition
Example: Machine Scheduling
CPAIOR tutorial
May 2009 Slide 14
Background Reading
CPAIOR tutorial
May 2009 Slide 15
CPAIOR tutorial
May 2009 Slide 16
CPAIOR tutorial
May 2009 Slide 17
Real-time control
(Siemens, Xerox)
CPAIOR tutorial
May 2009 Slide 18
Applications
Job shop scheduling
Assembly line smoothing
and balancing
Cellular frequency
assignment
Nurse scheduling
Shift planning
Maintenance planning
Airline crew rostering and scheduling
Airport gate allocation and stand planning
CPAIOR tutorial
May 2009 Slide 19
Applications
Production scheduling
chemicals
aviation
oil refining
steel
lumber
photographic plates
tires
Transport scheduling (food,
nuclear fuel)
Warehouse management
Course timetabling
CPAIOR tutorial
May 2009 Slide 20
CP
Numerical calculation
Logic processing
Relaxation
Inference (filtering,
constraint propagation)
Atomistic modeling
(linear inequalities)
High-level modeling
(global constraints)
Branching
Branching
Independence of model
and algorithm
Constraint-based
processing
CPAIOR tutorial
May 2009 Slide 21
Programming programming
In constraint programming:
programming = a form of computer programming
(constraint-based processing)
In mathematical programming:
programming = logistics planning (historically)
CPAIOR tutorial
May 2009 Slide 22
CP vs. MP
CPAIOR tutorial
May 2009 Slide 23
Advantages of CP
Better at sequencing and scheduling
where MP methods have weak relaxations.
Adding messy constraints makes the problem easier.
The more constraints, the better.
More powerful modeling language.
Global constraints lead to succinct models.
Constraints convey problem structure to the solver.
Better at highly-constrained problems
Misleading better when constraints propagate well, or
when constraints have few variables.
CPAIOR tutorial
May 2009 Slide 24
Disdvantages of CP
Weaker for continuous variables.
Due to lack of numerical techniques
May fail when constraints contain many variables.
These constraints dont propagate well.
Often not good for finding optimal solutions.
Due to lack of relaxation technology.
May not scale up
Discrete combinatorial methods
Software is not robust
Younger field
CPAIOR tutorial
May 2009 Slide 25
Obvious solution
Integrate CP and MP.
CPAIOR tutorial
May 2009 Slide 26
Trends
CP is better known in continental Europe, Asia.
Less known in North America, seen as threat to OR.
CP/MP integration is growing
Eclipse, Mozart, OPL Studio, SIMPL, SCIP, BARON
Heuristic methods increasingly important in CP
Discrete combinatorial methods
MP/CP/heuristics may become a single technology.
CPAIOR tutorial
May 2009 Slide 27
CPAIOR tutorial
May 2009 Slide 28
Truck
size
CPAIOR tutorial
May 2009 Slide 29
Number Capacity
available
(tons)
Cost
per
truck
90
60
50
40
Knapsack
packing
constraint
min 90 x1 + 60 x2 + 50 x3 + 40 x 4
7 x1 + 5 x2 + 4 x3 + 3 x 4 42
x1 + x2 + x3 + x 4 8
xi {0,1,2,3}
Truck
type
CPAIOR tutorial
May 2009 Slide 30
Number Capacity
available
(tons)
Cost
per
truck
90
60
50
40
Knapsack
covering
constraint
Bounds propagation
min 90 x1 + 60 x2 + 50 x3 + 40 x 4
7 x1 + 5 x2 + 4 x3 + 3 x 4 42
x1 + x2 + x3 + x 4 8
xi {0,1,2,3}
42 5 3 4 3 3 3
x1
=1
CPAIOR tutorial
May 2009 Slide 31
Bounds propagation
Reduced
domain
min 90 x1 + 60 x2 + 50 x3 + 40 x 4
7 x1 + 5 x2 + 4 x3 + 3 x 4 42
x1 + x2 + x3 + x 4 8
x1 {1,2,3}, x2 , x3 , x 4 {0,1,2,3}
42 5 3 4 3 3 3
x1
=1
CPAIOR tutorial
May 2009 Slide 32
Bounds consistency
Let {Lj, , Uj} be the domain of xj
A constraint set is bounds consistent if for each j :
xj = Lj in some feasible solution and
xj = Uj in some feasible solution.
Bounds consistency we will not set xj to any infeasible
values during branching.
Bounds propagation achieves bounds consistency for a
single inequality.
7x1 + 5x2 + 4x3 + 3x4 42 is bounds consistent when the
domains are x1 {1,2,3} and x2, x3, x4 {0,1,2,3}.
But not necessarily for a set of inequalities.
CPAIOR tutorial
May 2009 Slide 33
Bounds consistency
Bounds propagation may not achieve bounds consistency
for a set of constraints.
Consider set of inequalities
x1 + x2 1
x1 x2 0
CPAIOR tutorial
May 2009 Slide 34
Cutting Planes
Begin with continuous relaxation
min 90 x1 + 60 x2 + 50 x3 + 40 x 4
7 x1 + 5 x2 + 4 x3 + 3 x 4 42
x1 + x2 + x3 + x 4 8
Replace domains
0 xi 3, x1 1
with bounds
CPAIOR tutorial
May 2009 Slide 35
CPAIOR tutorial
May 2009 Slide 36
Continuous
relaxation
CPAIOR tutorial
May 2009 Slide 38
4 x3 + 3 x 4 42 (7 3 + 5 3)
Knapsack cut
which implies
42 (7 3 + 5 3)
x3 + x 4
=2
max {4,3}
CPAIOR tutorial
May 2009 Slide 39
a x
i P
a0 ai Ui
i P
a0 ai U i
i P
xi
max {ai }
i P
i P
CPAIOR tutorial
May 2009 Slide 40
Knapsack cuts
{1,2}
x3 + x4 2
{1,3}
x2 + x4 2
{1,4}
x2 + x3 3
CPAIOR tutorial
May 2009 Slide 41
Knapsack cuts
CPAIOR tutorial
May 2009 Slide 42
Branchinfer-andrelax tree
Propagate bounds
and solve
relaxation of
original problem.
CPAIOR tutorial
May 2009 Slide 43
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Branch on a
variable with
nonintegral value
in the relaxation.
CPAIOR tutorial
May 2009 Slide 44
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
x1 {1,2}
x1 = 3
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Propagate bounds
and solve
relaxation.
Since relaxation
is infeasible,
backtrack.
CPAIOR tutorial
May 2009 Slide 45
x1 { 12 }
x2 { 23}
x3 { 123}
x4 { 123}
infeasible
relaxation
x1 {1,2}
x1 = 3
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Propagate bounds
and solve
relaxation.
Branch on
nonintegral
variable.
CPAIOR tutorial
May 2009 Slide 46
x1 { 12 }
x2 { 23}
x3 { 123}
x4 { 123}
infeasible
relaxation
x1 {1,2}
x1 = 3
x1 {
3}
x2 {0123}
x3 {0123}
x4 {0123}
x = (3,2.6,2,0)
value = 526
x2 = 3
x2 {0,1,2}
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Branch again.
x1 { 12 }
x2 { 23}
x3 { 123}
x4 { 123}
infeasible
relaxation
x1 {1,2}
x1 = 3
x1 {
3}
x2 {0123}
x3 {0123}
x4 {0123}
x = (3,2.6,2,0)
value = 526
x2 = 3
x1 {
3}
x2 {0,1,2}
x2 {012 }
x3 { 123}
x4 {0123}
x = (3,2,2,0)
value = 527
x3 {1,2}
CPAIOR tutorial
May 2009 Slide 47
x3 = 3
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Solution of
relaxation
is integral and
therefore feasible
in the original
problem.
This becomes the
incumbent
solution.
CPAIOR tutorial
May 2009 Slide 48
x1 { 12 }
x2 { 23}
x3 { 123}
x4 { 123}
infeasible
relaxation
x1 {1,2}
x1 = 3
x1 {
3}
x2 {0123}
x3 {0123}
x4 {0123}
x = (3,2.6,2,0)
value = 526
x2 = 3
x1 {
3}
x2 {0,1,2}
x2 {012 }
x3 { 123}
x4 {0123}
x = (3,2,2,0)
value = 527
x1 {
3} x3 {1,2}
x2 { 12 }
x3 { 12 }
x4 { 123}
x = (3,2,2,1)
value = 530
feasible solution
x3 = 3
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Solution is
nonintegral, but
we can backtrack
because value of
relaxation is
no better than
incumbent solution.
CPAIOR tutorial
May 2009 Slide 49
x1 { 12 }
x2 { 23}
x3 { 123}
x4 { 123}
infeasible
relaxation
x1 {1,2}
x1 = 3
x1 {
3}
x2 {0123}
x3 {0123}
x4 {0123}
x = (3,2.6,2,0)
value = 526
x2 = 3
x1 {
3}
x2 {0,1,2}
x2 {012 }
x3 { 123}
x4 {0123}
x = (3,2,2,0)
value = 527
x1 {
3} x3 {1,2}
x2 { 12 }
x3 { 12 }
x4 { 123}
x = (3,2,2,1)
value = 530
feasible solution
x3 = 3
x1 {
3}
x2 {012 }
x3 {
3}
x4 {012 }
x = (3,1,3,)
value = 530
backtrack
due to bound
x1 { 123}
x2 {0123}
x3 {0123}
x4 {0123}
x = (2,3,2,0)
value = 523
Branch-inferand-relax tree
Another feasible
solution found.
No better than
incumbent solution,
which is optimal
because search
has finished.
CPAIOR tutorial
May 2009 Slide 50
x1 { 12 }
x2 { 23}
x3 { 123}
x4 { 123}
infeasible
relaxation
x1 {1,2}
x1 = 3
x1 {
3}
x2 {0123}
x3 {0123}
x4 {0123}
x = (3,2.6,2,0)
value = 526
x2 = 3
x1 {
3}
x2 {0,1,2}
x2 {012 }
x3 { 123}
x4 {0123}
x = (3,2,2,0)
value = 527
x1 {
3} x3 {1,2}
x2 { 12 }
x3 { 12 }
x4 { 123}
x = (3,2,2,1)
value = 530
feasible solution
x3 = 3
x1 {
3}
x2 {012 }
x3 {
3}
x4 {012 }
x = (3,1,3,)
value = 530
backtrack
due to bound
x1 {
3}
x2 {
3}
x3 {012 }
x4 {012 }
x = (3,3,0,2)
value = 530
feasible solution
x = (3,3,0,2)
CPAIOR tutorial
May 2009 Slide 51
CPAIOR tutorial
May 2009 Slide 52
Consistency
A constraint set is consistent if every partial assignment to the
variables that violates no constraint is feasible.
i.e., can be extended to a feasible solution.
Consistency feasibility
Consistency means that any infeasible partial assignment is
explicitly ruled out by a constraint.
Fully consistent constraint sets can be solved without
backtracking.
CPAIOR tutorial
May 2009 Slide 53
Consistency
Consider the constraint set
x1 + x100 1
x1 x100 0
x j {0,1}
CPAIOR tutorial
May 2009 Slide 54
x1 + x100 1
x1 x100 1
other constraints
x j {0,1}
x1 = 0
x1 = 1
CPAIOR tutorial
May 2009 Slide 55
CPAIOR tutorial
May 2009 Slide 56
CPAIOR tutorial
May 2009 Slide 57
CPAIOR tutorial
May 2009 Slide 58
CPAIOR tutorial
May 2009 Slide 59
CPAIOR tutorial
May 2009 Slide 60
CPAIOR tutorial
May 2009 Slide 61
CPAIOR tutorial
May 2009 Slide 62
CPAIOR tutorial
May 2009 Slide 63
CPAIOR tutorial
May 2009 Slide 64
min
c x
ij
ij
ij
s.t.
x
x
ij
= 1, all j
ij
= 1, all i
x
i V jW
ij
xij {0,1}
Subtour elimination constraints
CPAIOR tutorial
May 2009 Slide 65
A CP model
min
c
k
s.t.
y k y k +1
alldiff( y1,, y n )
y k {1,, n}
CPAIOR tutorial
May 2009 Slide 66
Global constraint
An alternate CP model
min
ky k
s.t.
circuit( y1,, y n )
y k {1,, n}
CPAIOR tutorial
May 2009 Slide 67
Hamiltonian circuit
constraint
Element constraint
z5
element ( y ,(c1,, cn ), z )
z5
element ( y ,( x1,, xn ), z )
(this is a slightly different constraint)
CPAIOR tutorial
May 2009 Slide 68
Add the
constraint
z = xy
Day:
Product
Integer
programming
model
(Wolsey)
zit y it y i ,t 1, all i , t
zit y it , all i , t
zit 1 y i ,t 1, all i , t
ijt y i ,t 1 + y jt 1, all i , j , t
ijt y i ,t 1, all i , j , t
ijt y jt , all i , j , t
xit Cy it , all i , t
y it = 1, all t
i
Many variables
CP model
Minimize holding and setup costs
min qy t 1y t + hi sit
t
i
CPAIOR tutorial
May 2009 Slide 71
Inventory balance
Production capacity
CP model
Minimize holding and setup costs
Variable indices
min qy t 1y t + hi sit
t
i
Inventory balance
Production capacity
CPAIOR tutorial
May 2009 Slide 73
resources
Min makespan = 8
3
time
L
min z
s.t.
z t5 + 2
CPAIOR tutorial
May 2009 Slide 74
Resources used
Processing times
Job start times
CPAIOR tutorial
May 2009 Slide 75
Item
Duration
Labor
Item
Duration
Labor
18
19
20
21
22
23
24
25
26
10
27
11
28
12
29
13
30
14
31
15
32
16
33
17
34
CPAIOR tutorial
May 2009 Slide 76
Problem data
Precedence constraints
1 2,4
2 3
3 5,7
4 5
5 6
6 8
7 8
8 9
9 10
9 14
10 11
10 12
CPAIOR tutorial
May 2009 Slide 77
11 13
12 13
13 15,16
14 15
15 18
16 17
17 18
18 19
18 20,21
19 23
20 23
21 22
22 23
23 24
24 25
25 26,30,31,32
26 27
27 28
28 29
30 28
31 28
32 33
33 34
min z
s.t.
z t1 + 3, z t2 + 4, etc.
cumulative ( (t1,, t34 ),(3,4,,2),(4,4,,3),8 )
t2 t1 + 3, t 4 t1 + 3, etc.
CPAIOR tutorial
May 2009 Slide 78
OPL model
int capacity = 8;
int nbTasks = 34;
range Tasks 1..nbTasks;
int duration[Tasks] = [3,4,4,6,,2];
int totalDuration =
sum(t in Tasks) duration[t];
int demand[Tasks] = [4,4,3,4,,3];
struct Precedences {
int before;
int after;
}
{Precedences} setOfPrecedences = {
<1,2>, <1,4>, , <33,34> };
CPAIOR tutorial
May 2009 Slide 79
scheduleHorizon = totalDuration;
Activity a[t in Tasks](duration[t]);
DiscreteResource res(8);
Activity makespan(0);
minimize
makespan.end
subject to
forall(t in Tasks)
a[t] precedes makespan;
forall(p in setOfPrecedences)
a[p.before] precedes a[p.after];
forall(t in Tasks)
a[t] requires(demand[t]) res;
};
CPAIOR tutorial
May 2009 Slide 80
Capacity
C3
CPAIOR tutorial
May 2009 Slide 81
Packing
Units
t
Filling starts
Packing starts
CPAIOR tutorial
May 2009 Slide 82
Need to enforce
capacity constraint
here only
t + (b/r)
Manufacturing rate
Batch size
Filling ends
u + (b/s)
Packing rate
Packing ends
Makespan
min T
s.t.
T uj +
bj
sj
, all j
Job release time
t j R j , all j
cumulative ( t ,v , e, m )
b
v i = ui + i t i , all i
si
m storage tanks
Job duration
si
bi 1
ri
+ si ui Ci , all i
b1
bn
cumulative u, ,, , e, p
sn
s1
uj tj 0
e = (1,,1)
CPAIOR tutorial
May 2009 Slide 83
Tank capacity
p packing units
CPAIOR tutorial
May 2009 Slide 84
Mon
Tue
Wed
Thu
Fri
Sat
Shift 1
Shift 2
Shift 3
Mon
Tue
Wed
Thu
Fri
Sat
Nurse A
Nurse B
Nurse C
Nurse D
CPAIOR tutorial
May 2009 Slide 85
0 = day off
alldiff(w1d ,w 2d ,w 3d ), all d
CPAIOR tutorial
May 2009 Slide 86
alldiff(w1d ,w 2d ,w 3d ), all d
CPAIOR tutorial
May 2009 Slide 87
w y id d = i , all i , d
y w sd d = s, all s, d
CPAIOR tutorial
May 2009 Slide 92
w y id d = i , all i , d
y w sd d = s, all s, d
CPAIOR tutorial
May 2009 Slide 93
CP Filtering Algorithms
Element
Alldiff
Disjunctive Scheduling
Cumulative Scheduling
CPAIOR tutorial
May 2009 Slide 94
Dz Dz
j Dy
Domain of z
xj
Dz if Dy = { j }
Dx j
D
otherwise
x j
CPAIOR tutorial
May 2009 Slide 95
Dy Dy j | Dz Dx j
element ( y ,( x1, x2 , x3 , x4 ), z )
Dz = {20,30,60,80,90}
Dy = {1,3,4}
Dz = {80,90}
Dy = {3}
Dx2 = {10,20}
Dx2 = {10,20}
Dx1 = {10,50}
Dx3 = {40,50,80,90}
Dx4 = {40,50,70}
CPAIOR tutorial
May 2009 Slide 96
Dx1 = {10,50}
Dx3 = {80,90}
Dx4 = {40,50,70}
CPAIOR tutorial
May 2009 Slide 97
y1 {1}
y 2 {2,3,5}
y 3 {1,2,3,5}
y 4 {1,5}
y 5 {1,2,3,4,5,6}
CPAIOR tutorial
May 2009 Slide 98
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 99
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 100
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 101
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 102
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 103
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 104
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 105
y1
1
2
y2
y3
4
y4
5
y5
CPAIOR tutorial
May 2009 Slide 106
y1 {1}
y 2 {2,3,5}
y 3 {1,2,3,5}
y 4 {1,5}
y 5 {1,2,3,4,5,6}
GAC achieved.
CPAIOR tutorial
May 2009 Slide 107
y1 {1}
y 2 {2,3}
y 3 {2,3}
y 4 {5}
y 5 {4,6}
Disjunctive scheduling
Consider a disjunctive scheduling constraint:
CPAIOR tutorial
May 2009 Slide 108
CPAIOR tutorial
May 2009 Slide 109
CPAIOR tutorial
May 2009 Slide 110
Time window
CPAIOR tutorial
May 2009 Slide 111
CPAIOR tutorial
May 2009 Slide 112
CPAIOR tutorial
May 2009 Slide 113
CPAIOR tutorial
May 2009 Slide 114
E{3,5}
7<3+3+2
L{2,3,5}
CPAIOR tutorial
May 2009 Slide 115
E{3,5}
7<3+3+2
L{2,3,5}
CPAIOR tutorial
May 2009 Slide 116
E{3,5}
7<3+3+2
L{2,3,5}
CPAIOR tutorial
May 2009 Slide 117
E{3,5}
7<3+3+2
L{2,3,5}
L{3} p{3} = 4
L{5} p{5} = 5
L{3,5} p{3,5} = 2
CPAIOR tutorial
May 2009 Slide 118
E{3,5}
7<3+3+2
L{2,3,5}
LJ { k } EJ < pJ { k }
CPAIOR tutorial
May 2009 Slide 119
LJ { k } EJ < pJ { k }
min {LJ pJ }
J J
CPAIOR tutorial
May 2009 Slide 120
L{3,5} p{3,5} = 2
k J
If there is not enough time for all the jobs before the latest
deadline of the jobs in J:
LJ EJ { k } < pJ { k }
Now we can tighten the release date for job k to:
max {EJ + pJ }
J J
CPAIOR tutorial
May 2009 Slide 121
LJ { k } EJ < pJ { k }
and all subsets J of J to tighten the bounds?
min {LJ pJ }
J J
CPAIOR tutorial
May 2009 Slide 122
min {LJ pJ }
J J
e.g., J = {3,5}
CPAIOR tutorial
May 2009 Slide 123
min {LJ pJ }
J J
e.g., J = {3,5}
min {LJ pJ }
J J
e.g., J = {3,5}
CPAIOR tutorial
May 2009 Slide 125
CPAIOR tutorial
May 2009 Slide 126
Not-first/not-last rules
We can deduce that job 4 cannot precede jobs 1 and 2:
( 4 {1,2} )
L{1,2} E 4 < p1 + p2 + p4
E4
CPAIOR tutorial
May 2009 Slide 128
6<1+3+3
L{1,2}
Not-first/not-last rules
We can deduce that job 4 cannot precede jobs 1 and 2:
( 4 {1,2} )
E1 + p1 = 3
E4
CPAIOR tutorial
May 2009 Slide 129
6<1+3+3
E2 + p2 = 4
L{1,2}
Not-first/not-last rules
In general, we can deduce that job k cannot precede all the
jobs in J:
(k J )
if there is too little time after release time of job k to complete
all jobs before the latest deadline in J:
LJ Ek < pJ
Now we can update Ei to
min {E j + p j }
j J
CPAIOR tutorial
May 2009 Slide 130
Not-first/not-last rules
In general, we can deduce that job k cannot precede all the
jobs in J:
(k J )
if there is too little time after release time of job k to complete
all jobs before the latest deadline in J:
LJ Ek < pJ
Now we can update Ei to
min {E j + p j }
j J
CPAIOR tutorial
May 2009 Slide 131
Cumulative scheduling
Consider a cumulative scheduling constraint:
A feasible solution:
CPAIOR tutorial
May 2009 Slide 132
CPAIOR tutorial
May 2009 Slide 133
Total energy
required = 22
9
8
5
CPAIOR tutorial
May 2009 Slide 134
Total energy
required = 22
9
8
Area available
= 20
5
CPAIOR tutorial
May 2009 Slide 135
E{1,2} +
eJ (C c3 )(L{1,2} E{1,2} )
c3
Energy available
for jobs 1,2 if
space is left for job
3 to start anytime
= 10
10
CPAIOR tutorial
May 2009 Slide 136
E{1,2} +
eJ (C c3 )(L{1,2} E{1,2} )
Energy available
for jobs 1,2 if
space is left for job
3 to start anytime
= 10
Excess energy
required by jobs
1,2 = 4
CPAIOR tutorial
May 2009 Slide 137
c3
10
E{1,2} +
eJ (C c3 )(L{1,2} E{1,2} )
Energy available
for jobs 1,2 if
space is left for job
3 to start anytime
= 10
Excess energy
required by jobs
1,2 = 4
CPAIOR tutorial
May 2009 Slide 138
c3
10
E3
Move up job 3
release time
4/2 = 2 units
beyond E{1,2}
eJ {k } > C LJ EJ { k }
eJ (C ck )(LJ EJ )
max
E J +
J J
c
e (C c )( L E )>0
J
In general, if
eJ {k } > C LJ { k } EJ
eJ (C ck )(LJ EJ )
min
LJ
J J
c
eJ (C ck )( LJ EJ )>0
CPAIOR tutorial
May 2009 Slide 139
CPAIOR tutorial
May 2009 Slide 140
CPAIOR tutorial
May 2009 Slide 141
Linear Relaxation
Why Relax?
Algebraic Analysis of LP
Linear Programming Duality
LP-Based Domain Filtering
Example: Single-Vehicle Routing
Disjunctions of Linear Systems
CPAIOR tutorial
May 2009 Slide 142
Why Relax?
Solving a relaxation of a problem can:
CPAIOR tutorial
May 2009 Slide 143
CPAIOR tutorial
May 2009 Slide 144
Motivation
Linear programming is remarkably versatile for representing
real-world problems.
LP is by far the most widely used tool for relaxation.
LP relaxations can be strengthened by cutting planes.
- Based on polyhedral analysis.
LP has an elegant and powerful duality theory.
- Useful for domain filtering, and much else.
The LP problem is extremely well solved.
CPAIOR tutorial
May 2009 Slide 145
Algebraic Analysis of LP
An example
min 4 x1 + 7 x2
2 x1 + 3 x2 6
2 x1 + x2 4
2x1 + x2 4
Optimal solution
x = (3,0)
x1, x2 0
4x1 + 7x2 = 12
2x1 + 3x2 6
CPAIOR tutorial
May 2009 Slide 146
Algebraic Analysis of LP
Rewrite
min 4 x1 + 7 x2
as
2 x1 + 3 x2 6
2 x1 + x2 4
x1, x2 0
In general an LP has the form
min 4 x1 + 7 x2
2 x1 + 3 x2 x3 = 6
2 x1 + x2 x4 = 4
x1, x2 , x3 , x4 0
min cx
Ax = b
x0
CPAIOR tutorial
May 2009 Slide 147
Algebraic analysis of LP
Write
min cx
as
BxB + NxN = b
xB , xN 0
Ax = b
x0
m n matrix
min cB xB + cN xN
Basic
variables
Nonbasic
variables
where
A = [B N ]
Any set of
m linearly
independent
columns of A.
These form a
basis for the
space spanned
by the columns.
CPAIOR tutorial
May 2009 Slide 148
Algebraic analysis of LP
Write
min cx
as
Ax = b
x0
min cB xB + cN xN
where
BxB + NxN = b
xB , xN 0
xB = B 1b B 1NxN
CPAIOR tutorial
May 2009 Slide 149
A = [B N ]
Example
x2
min 4 x1 + 7 x2
2 x1 + 3 x2 x3 = 6
= basic feasible
solution
x2, x3 basic
2x1 + x2 4
2 x1 + x2 x4 = 4
x1, x2 , x3 , x4 0
x2, x4 basic
x1, x2 basic
2x1 + 3x2 6
x3, x4 basic
CPAIOR tutorial
May 2009 Slide 150
x1, x4 basic
x1, x3 basic
x1
Algebraic analysis of LP
Write
min cx
as
Ax = b
x0
min cB xB + cN xN
where
A = [B N ]
BxB + NxN = b
xB , xN 0
xB = B 1b B 1NxN
cB B 1b + (cN cB B 1N )xN
Vector of reduced costs
CPAIOR tutorial
May 2009 Slide 151
Since xN 0,
basic solution (xB,0)
is optimal if
reduced costs are
nonnegative.
Example
x2
min 4 x1 + 7 x2
2x1 + 3 x2 x3 = 6
2x1 + x2 x4 = 4
x1, x2 , x3 , x4 0
Consider this
basic feasible
solution
x1, x4 basic
x1
CPAIOR tutorial
May 2009 Slide 152
Example
Write
min 4 x1 + 7 x2
2x1 + 3 x2 x3 = 6
2x1 + x2 x4 = 4
x1, x2 , x3 , x4 0
CPAIOR tutorial
May 2009 Slide 153
as
cBxB
c Nx N
x2
x1
min [ 4 0 ] + [7 0]
x4
x3
2 0 x1 3 1 x1 6
+
=
BxB
2 1 x 4 1 0 x 4 4
NxN
b
x1 x1 0
x , x 0
4 4
Example
cBxB
c Nx N
x2
x1
min [ 4 0 ] + [7 0]
x4
x3
2 0 x1 3 1 x1 6
+
=
BxB
2 1 x 4 1 0 x 4 4
b
NxN
x1 x1 0
x , x 0
4 4
CPAIOR tutorial
May 2009 Slide 154
Example
Basic solution is
xB = B 1b B 1NxN = B 1b
cBxB
c Nx N
x2
x1
min [ 4 0 ] + [7 0]
x4
x3
2 0 x1 3 1 x1 6
+
=
BxB
2 1 x 4 1 0 x 4 4
b
NxN
x1 x1 0
x , x 0
4 4
x1 1/ 2 0 6 3
= =
=
x4 1 1 4 2
x2
x1, x4 basic
CPAIOR tutorial
May 2009 Slide 155
x1
Example
Basic solution is
xB = B 1b B 1NxN = B 1b
cBxB
c Nx N
x2
x1
min [ 4 0 ] + [7 0]
x4
x3
2 0 x1 3 1 x1 6
+
=
BxB
2 1 x 4 1 0 x 4 4
NxN
x1 x1 0
x , x 0
4 4
CPAIOR tutorial
May 2009 Slide 156
x1 1/ 2 0 6 3
= =
=
x4 1 1 4 2
cN cB B 1N
1/ 2 0 3 1
= [7 0] [ 4 0]
1 1 1 0
= [1 2] [0 0]
Solution is
optimal
min cx
Ax b
x0
max v
x 0
Ax b cx v
implies
CPAIOR tutorial
May 2009 Slide 157
min cx
max v
Ax b
x0
x 0
Ax b cx v
Ax b cx v
iff
Ax b dominates cx v
for some 0
A c and b v
CPAIOR tutorial
May 2009 Slide 158
min cx
max v
Ax b
x0
x 0
Ax b cx v
max b
A c
0
This is the
classical
LP dual
Ax b cx v
iff
Ax b dominates cx v
for some 0
A c and b v
CPAIOR tutorial
May 2009 Slide 159
min cx
Ax b
x0
max b
A c
0
This is the
classical
LP dual
If Ax b, x 0 is feasible
CPAIOR tutorial
May 2009 Slide 160
Example
Primal
min 4 x1 + 7 x2
Dual
2 x1 + 3 x2 6
(1 )
2 x1 + x2 4
x1, x2 0
(1 )
max 61 + 42
= 12
21 + 22 4
( x1 )
31 + 2 7
( x2 )
1, 2 0
2 x1 + 3 x2 6 (1 = 2)
2 x1 + x2 4 (2 = 0)
Dual multipliers
4 x1 + 6 x2 12
Surrogate
dominates
CPAIOR tutorial
May 2009 Slide 161
4 x1 + 7 x2 12
Weak Duality
If x* is feasible in the
primal problem
min cx
max b
Ax b
x0
A c
0
This is because
cx* *Ax* *b
* is dual
feasible
and x* 0
CPAIOR tutorial
May 2009 Slide 162
x* is primal
feasible
and * 0
min cx
Ax b + b
x0
max ( b + b )
A c
0
CPAIOR tutorial
May 2009 Slide 163
min cx
Ax b + b
x0
Dual
min cB xB + cN xN
max b
B cB
( xB )
( xB )
N cN
unrestricted
BxB + NxN = b
xB , xN 0
CPAIOR tutorial
May 2009 Slide 165
( )
Dual
min cB xB + cN xN
max b
B cB
( xB )
( xB )
N cN
unrestricted
BxB + NxN = b
xB , xN 0
( )
cN cB B 1N = cN N
CPAIOR tutorial
May 2009 Slide 166
Dual
max b
B cB
( xB )
( xB )
N cN
unrestricted
( )
B = cB B B = cB
N = cB B 1N cN
1
cN cB B 1N = cN N
CPAIOR tutorial
May 2009 Slide 167
Dual
( )
max b
B cB
( xB )
( xB )
N cN
unrestricted
cN cB B 1N = cN N
1/ 2 0
= cB B = [ 4 0 ]
= [ 2 0]
1 1
1
CPAIOR tutorial
May 2009 Slide 168
Dual
( )
max b
B cB
( xB )
( xB )
N cN
unrestricted
cN cB B 1N = cN N
r j = c j Aj
Column j of A
CPAIOR tutorial
May 2009 Slide 169
Let
Ax b
be an LP relaxation of a CP problem.
x0
Suppose:
min cx
Ax b
x0
CPAIOR tutorial
May 2009 Slide 171
min cx
Supposing
Ax b
x0
If x were to change to a value other than x*, the LHS of i-th constraint
Aix bi would change by some amount bi.
Since the constraint is tight, this would increase the optimal value
as much as changing the constraint to Aix bi + bi.
So it would increase the optimal value at least i*bi.
CPAIOR tutorial
May 2009 Slide 172
min cx
Supposing
Ax b
x0
bi
CPAIOR tutorial
May 2009 Slide 173
i*
min cx
Supposing
Ax b
x0
bi
i*
Ai x bi +
CPAIOR tutorial
May 2009 Slide 174
U v*
i*
Example
min 4 x1 + 7 x2
2 x1 + 3 x2 6 (1 = 2)
2 x1 + x2 4
(1 = 0)
x1, x2 0
A1x b1 +
or
CPAIOR tutorial
May 2009 Slide 175
2 x1 + 3 x2 6 +
U v*
1*
13 12
= 6.5
2
The inequality
Ai x bi +
U v*
*
i
becomes
U v*
xj
rj
Example
min 4 x1 + 7 x2
2 x1 + 3 x2 6 (1 = 2)
2 x1 + x2 4
(1 = 0)
x1, x2 0
U v*
Since x2* = 0, we have x2
r2
13 12
or x2
= 0.5
2
If x2 is required to be integer, we can fix it to zero.
This is reduced-cost variable fixing.
CPAIOR tutorial
May 2009 Slide 177
CPAIOR tutorial
May 2009 Slide 178
Assignment Relaxation
min
c x
ij
ij
xij = x ji = 1, all i
j
CPAIOR tutorial
May 2009 Slide 179
Assignment Relaxation
min
c x
ij
ij
xij = x ji = 1, all i
j
0 xij 1, all i , j
Because this problem is totally unimodular, it can be solved as an LP.
The relaxation provides a very weak lower bound on the optimal value.
But reduced-cost variable fixing can be very useful in a CP context.
CPAIOR tutorial
May 2009 Slide 180
min cx
(A x b )
k
CPAIOR tutorial
May 2009 Slide 181
CPAIOR tutorial
May 2009 Slide 182
min cx
(A x b )
k
min cx
(A x b )
k
is described by
min cx
Ak x k b k y k , all k
y =1
x = x
k
CPAIOR tutorial
May 2009 Slide 183
0 yk 1
Why?
To derive convex hull
relaxation of a disjunction
Write each
solution as a
convex
combination
of points in
the
polyhedron
min cx
Ak x k b k , all k
y =1
x = y x
k
0 yk 1
x2
Why?
To derive convex hull
relaxation of a disjunction
Write each
solution as a
convex
combination
of points in
the
polyhedron
min cx
Ak x k b k , all k
y =1
x = y x
min cx
Ak x k b k y k , all k
y =1
x = x
Change of
variable
x = yk x k
0 yk 1
0 yk 1
x2
CPAIOR tutorial
May 2009 Slide 186
Motivation
A mixed integer/linear programming
(MILP) problem has the form
min cx + dy
Ax + by b
x, y 0
y integer
CPAIOR tutorial
May 2009 Slide 187
MILP Representability
A subset S of R n is MILP representable if it is the projection onto x
of some MILP constraint set of the form
Ax + Bu + Dy b
x, y 0
x R n , u R m , y k {0,1}
CPAIOR tutorial
May 2009 Slide 188
MILP Representability
A subset S of R n is MILP representable if it is the projection onto x
of some MILP constraint set of the form
Ax + Bu + Dy b
x, y 0
x R n , u R m , y k {0,1}
Theorem. S R is MILP
representable if and only if
S is the union of finitely
many polyhedra having the
same recession cone.
Recession cone
of polyhedron
CPAIOR tutorial
May 2009 Slide 189
Polyhedron
min x2
if x1 = 0
0
x2
f + cx1 if x1 > 0
x1 0
x2
x1
CPAIOR tutorial
May 2009 Slide 190
Example
Minimize a fixed charge function:
min x2
if x1 = 0
0
x2
f + cx1 if x1 > 0
x1 0
x2
Feasible set
x1
CPAIOR tutorial
May 2009 Slide 191
Example
Minimize a fixed charge function:
min x2
if x1 = 0
0
x2
f + cx1 if x1 > 0
x1 0
x2
Union of two
polyhedra
P1, P2
P1
x1
CPAIOR tutorial
May 2009 Slide 192
Example
Minimize a fixed charge function:
min x2
if x1 = 0
0
x2
f + cx1 if x1 > 0
x1 0
x2
Union of two
polyhedra
P1, P2
P2
P1
x1
CPAIOR tutorial
May 2009 Slide 193
Example
Minimize a fixed charge function:
min x2
if x1 = 0
0
x2
f + cx1 if x1 > 0
x1 0
x2
The
polyhedra
have
different
recession
cones.
P2
P1
x1
CPAIOR tutorial
May 2009 Slide 194
P1
recession
cone
P2
recession
cone
Example
Minimize a fixed charge function:
Add an upper bound on x1
min x2
if x1 = 0
0
x2
f + cx1 if x1 > 0
0 x1 M
x2
The
polyhedra
have the
same
recession
cone.
P2
P1
x1
CPAIOR tutorial
May 2009 Slide 195
P1
recession
cone
P2
recession
cone
Akx
b}
min cx
(A
k
x bk )
min cx
Ak x k b k y k , all k
yk = 1
k
x = xk
k
y k {0,1}
CPAIOR tutorial
May 2009 Slide 196
Example
Start with a disjunction of
linear systems to represent
the union of polyhedra
min x2
x1 = 0 0 x1 M
x 0 x f + cx
2
2
1
x2
P2
P1
x1
CPAIOR tutorial
May 2009 Slide 197
Example
Start with a disjunction of
linear systems to represent
the union of polyhedra
CPAIOR tutorial
May 2009 Slide 198
min x2
x1 = 0 0 x1 M
x 0 x f + cx
2
2
1
min cx
x11 = 0, x21 0
0 x12 My 2 , cx12 + x22 fy 2
y1 + y 2 = 1, y k {0,1}
x = x1 + x 2
Example
To simplify:
Replace x12 with x1.
Replace x22 with x2.
Replace y2 with y.
This yields
min x2
0 x1 My
x2 fy + cx1
y {0,1}
CPAIOR tutorial
May 2009 Slide 199
min x2
x11 = 0, x21 0
0 x12 My 2 , cx12 + x22 fy 2
y1 + y 2 = 1, y k {0,1}
x = x1 + x 2
or
min fy + cx
0 x My
y {0,1}
Big M
Disjunctive Modeling
Disjunctions often occur naturally in problems and can be given
an MILP model.
Recall that a disjunction of linear
systems (representing polyhedra
with the same recession cone)
has the MILP model
min cx
(A x b )
k
min cx
Ak x k b k y k , all k
yk = 1
k
x = xk
k
CPAIOR tutorial
May 2009 Slide 200
y k {0,1}
n markets
fi
cij
i
Fixed
cost
CPAIOR tutorial
May 2009 Slide 201
j
Transport
cost
Fraction of
market js demand
satisfied from
location i
n markets
Disjunctive model:
min
z + c x
i
ij
ij
ij
i
i
i
xij = 1, all j
i
fi
cij
i
Fixed
cost
j
Transport
cost
CPAIOR tutorial
May 2009 Slide 202
No factory
at location i
Factory
at location i
fi y i + cij xij
i
ij
0 xij y i , all i , j
y i {0,1}
Disjunctive model:
min
z + c x
i
ij
ij
ij
i
i
i
xij = 1, all j
i
No factory
at location i
CPAIOR tutorial
May 2009 Slide 203
Factory
at location i
Beginners model:
f y + c x
i
ij
ij
f y + c x
min
ij
0 xij y i , all i , j
y i {0,1}
Maximum output
from location i
ij
ij
ij
ij
ny i , all i , j
y i {0,1}
Knapsack Modeling
Knapsack models consist of knapsack covering and
knapsack packing constraints.
The freight transfer model presented earlier is an example.
We will consider a similar example that combines disjunctive
and knapsack modeling.
Most OR professionals are unlikely to write a model as good
as the one presented here.
CPAIOR tutorial
May 2009 Slide 205
CPAIOR tutorial
May 2009 Slide 206
Disjunctive model
Each package j
has size aj
Knapsack
constraints
min
Q y a ; x
i
CPAIOR tutorial
May 2009 Slide 207
1 if truck i carries
package j
ij
= 1, all j
yi = 1
yi = 0
zi = ci
z
=
0
a j xij Qi i
, all i
j
x = 0
0 x 1, all j ij
ij
MILP model
Disjunctive model
c y
Q y a ; x
min
a x
j
ij
Qi y i , all i
xij y i , all i , j
xij , y i {0,1}
CPAIOR tutorial
May 2009 Slide 208
min
ij
= 1, all j
Q y a ; x
i
ij
= 1, all j
yi = 1
yi = 0
zi = ci
z
=
0
a j xij Qi i
, all i
j
x = 0
0 x 1, all j ij
ij
xij , y i {0,1}
MILP model
c y
Q y a ; x
min
a x
j
ij
xij y i , all i , j
xij , y i {0,1}
CPAIOR tutorial
May 2009 Slide 209
= 1, all j
Qi y i , all i
ij
Modeling trick;
unobvious without
disjunctive approach
Cutting Planes
0-1 Knapsack Cuts
Gomory Cuts
Mixed Integer Rounding Cuts
Example: Product Configuration
CPAIOR tutorial
May 2009 Slide 210
To review
A cutting plane (cut, valid inequality) for
an MILP model:
is valid
Cutting
plane
Continuous
relaxation
Feasible solutions
CPAIOR tutorial
May 2009 Slide 211
Motivation
Cutting planes (cuts) tighten the continuous relaxation of an
MILP model.
Knapsack cuts
- Generated for individual knapsack constraints.
- We saw general integer knapsack cuts earlier.
- 0-1 knapsack cuts and lifting techniques are well studied
and widely used.
Rounding cuts
- Generated for the entire MILP, they are widely used.
- Gomory cuts for integer variables only.
- Mixed integer rounding cuts for any MILP.
CPAIOR tutorial
May 2009 Slide 212
CPAIOR tutorial
May 2009 Slide 213
0-1 knapsack cuts are designed for knapsack constraints with 0-1
variables.
The analysis is different from that of general knapsack constraints,
to exploit the special structure of 0-1 inequalities.
Consider a 0-1 knapsack packing constraint ax a0. (Knapsack
covering constraints are similarly analyzed.)
Index set J is a cover if
a
j J
ax a0
CPAIOR tutorial
May 2009 Slide 214
x
j J
> a0
Example
J = {1,2,3,4} is a cover for
6 x1 + 5 x2 + 5 x3 + 5 x4 + 8 x5 + 3 x6 17
This gives rise to the cover inequality
x1 + x2 + x3 + x 4 3
a
j J
ax a0
CPAIOR tutorial
May 2009 Slide 215
x
j J
> a0
Sequential lifting
A cover inequality can often be strengthened by lifting it into a
higher dimensional space.
That is, by adding variables.
Sequential lifting adds one variable at a time.
Sequence-independent lifting adds several variables at once.
CPAIOR tutorial
May 2009 Slide 216
Sequential lifting
To lift a cover inequality
x
j J
J 1
x
j J
+ k xk J 1
where k is the largest coefficient for which the inequality is still valid.
So, k = J 1 max x j
x j {0,1}
jJ
for j J
a j x j a0 ak
j J
CPAIOR tutorial
May 2009 Slide 217
Example
Given
6 x1 + 5 x2 + 5 x3 + 5 x4 + 8 x5 + 3 x6 17
To lift
x1 + x2 + x3 + x 4 3
5 = 3 max
x j {0,1}
x1 + x2 + x3 + x 4 + 5 x5 3
{x1 + x2 + x3 + x4 6 x1 + 5 x2 + 5 x3 + 5 x4 17 8}
for j{1,2,3,4}
This yields
x1 + x2 + x3 + x 4 + 2 x5 3
x1 + x2 + x3 + x 4 + x5 + x6 3
CPAIOR tutorial
May 2009 Slide 218
Sequence-independent lifting
Sequence-independent lifting usually yields a weaker cut than
sequential lifting.
But it adds all the variables at once and is much faster.
Commonly used in commercial MILP solvers.
CPAIOR tutorial
May 2009 Slide 219
Sequence-independent lifting
To lift a cover inequality
x
j J
J 1
x + (a ) x
j J
j J
J 1
j
if Aj u A j +1 and j {0,, p 1}
with
= a j a0
A j = ak
J = {1,, p}
A0 = 0
j J
CPAIOR tutorial
May 2009 Slide 220
k =1
Example
Given
6 x1 + 5 x2 + 5 x3 + 5 x4 + 8 x5 + 3 x6 17
x1 + x2 + x3 + x 4 3
Add terms x1 + x2 + x3 + x 4 + (8) x5 + (3) x6 3
To lift
Gomory Cuts
When an integer programming
problem has a nonintegral solution,
we can generate at least one Gomory
cut to cut off that solution.
Separating
cut
Solution of
continuous
relaxation
CPAIOR tutorial
May 2009 Slide 222
Gomory cuts
Given an integer programming
problem
min cx
Ax = b
x 0 and integral
N
xB = b Nx
b = B 1b, N = B 1N
xi + N i xN bi
CPAIOR tutorial
May 2009 Slide 223
Example
min 2 x1 + 3 x2
or
min 2 x1 + 3 x2
x1 + 3 x2 3
x1 + 3 x2 x3 = 3
4 x1 + 3 x2 6
x1, x2 0 and integral
4 x1 + 3 x2 x 4 = 6
x j 0 and integral
Optimal solution of
the continuous
relaxation has
x 1
xB = 1 =
x2 2 / 3
1/ 3 1/ 3
N =
4 / 9 1/ 9
1
b =
2 / 3
CPAIOR tutorial
May 2009 Slide 224
Example
min 2 x1 + 3 x2
or
min 2 x1 + 3 x2
x1 + 3 x2 3
x1 + 3 x2 x3 = 3
4 x1 + 3 x2 6
x1, x2 0 and integral
4 x1 + 3 x2 x 4 = 6
x j 0 and integral
Optimal solution of
the continuous
relaxation has
x 1
xB = 1 =
x2 2 / 3
1/ 3 1/ 3
N =
4 / 9 1/ 9
x3
is x2 + [ 4 / 9 1/ 9] 2 / 3
x4
1
b =
2 / 3
or
x 2 x3 0
CPAIOR tutorial
May 2009 Slide 225
x1 + 2 x2 3
Example
min 2 x1 + 3 x2
or
min 2 x1 + 3 x2
x1 + 3 x2 3
x1 + 3 x2 x3 = 3
4 x1 + 3 x2 6
x1, x2 0 and integral
4 x1 + 3 x2 x 4 = 6
x j 0 and integral
Optimal solution of
the continuous
relaxation has
x 1
xB = 1 =
x2 2 / 3
1/ 3 1/ 3
N =
4 / 9 1/ 9
1
b =
2 / 3
1
b =
2 / 3
CPAIOR tutorial
May 2009 Slide 226
CPAIOR tutorial
May 2009 Slide 227
MIR cuts
Given an MILP problem
min cx + dy
Ax + Dy = b
K = { j | xj is nonbasic}
x, y 0 and y integral
N = nonbasic cols of [A D]
frac(N ij )
1
y i + N ij y j + N ij +
+
N ij+ x j N ij bi
frac( bi ) frac(bi ) jK
j J1
j J 2
where
J1 = j J frac(N ij ) frac(b j )
CPAIOR tutorial
May 2009 Slide 228
J 2 = J \ J1
Example
3 x1 + 4 x2 6 y1 4 y 2 = 1
x1 + 2 x2 y1 y 2 = 3
x j , y j 0, y j integer
1/ 3 2 / 3
N =
2 / 3 8 / 3
1/ 3
1
y
+
(2 / 3)+ x2 8 / 3
2
2/3
2/3
or y1 + (1/ 2)y 2 + x2 3
CPAIOR tutorial
May 2009 Slide 229
8/3
b =
17 / 3
CPAIOR tutorial
May 2009 Slide 230
The problem
Choose what type of each component, and how many
Personal computer
Memory
Memory
Memory
Memory
Disk
drive
Power
supply
Memory
Power
supply
CPAIOR tutorial
May 2009 Slide 231
Disk
drive
Memory
Power
supply
Disk
drive
Disk
drive
Disk
drive
Power
supply
Amount of attribute j
produced
(< 0 if consumed):
memory, heat, power,
weight, etc.
min
Amount of attribute j
produced by type ti
of component i
c v
j
v j = qi Aijti , all j
ik
L j v j U j , all j
Quantity of
component i
installed
CPAIOR tutorial
May 2009 Slide 232
ti is a variable
index
To solve it:
CPAIOR tutorial
May 2009 Slide 233
Propagation
min
c v
j
v j = qi Aijti , all j
ik
L j v j U j , all j
CPAIOR tutorial
May 2009 Slide 234
This is propagated
in the usual way
Propagation
v j = zi , all j
i
c v
j
v j = qi Aijti , all j
This is rewritten as
ik
L j v j U j , all j
CPAIOR tutorial
May 2009 Slide 235
This is propagated
in the usual way
Propagation
v j = zi , all j
i
CPAIOR tutorial
May 2009 Slide 236
Propagation
v j = zi , all j
i
max {A } q v , all j
min{A } q v , all j
i
k Dti
k Dti
ijk
ijk
[v j ,v j ] is current
domain of vj
CPAIOR tutorial
May 2009 Slide 237
Relaxation
min
c v
j
v j = qi Aijti , all j
ik
L j v j U j , all j
CPAIOR tutorial
May 2009 Slide 238
This is relaxed as
v j vj vj
Relaxation
v j = zi , all j
i
c v
j
v j = qi Aijti , all j
ik
L j v j U j , all j
CPAIOR tutorial
May 2009 Slide 239
v j vj vj
Relaxation
v j = zi , all j
i
zi =
CPAIOR tutorial
May 2009 Slide 240
kDti
ijk
qik , qi =
kDti
ik
Relaxation
So the following LP relaxation is solved at each node
of the search tree to obtain a lower bound:
min
c v
j
vj =
i
qj =
k Dti
kDti
ik
ijk
qik , all j
, all i
v j v j v j , all j
qi qi qi , all i
max {A } q v , all j
knapsack cuts for min{ A } q v , all j
knapsack cuts for
qik 0, all i , k
CPAIOR tutorial
May 2009 Slide 241
kDti
k Dti
ijk
ijk
Computational Results
1000
Seconds
100
10
CPLEX
CLP
Hybrid
1
8x10
16x20
20x24
0.1
0.01
Problem
CPAIOR tutorial
May 2009 Slide 242
20x30
Lagrangean Relaxation
Lagrangean Duality
Properties of the Lagrangean Dual
Example: Fast Linear Programming
Domain Filtering
Example: Continuous Global Optimization
CPAIOR tutorial
May 2009 Slide 243
Motivation
Lagrangean relaxation can provide better bounds than LP
relaxation.
The Lagrangean dual generalizes LP duality.
It provides domain filtering analogous to that based on LP
duality.
- This is a key technique in continuous global optimization.
Lagrangean relaxation gets rid of troublesome constraints by
dualizing them.
- That is, moving them into the objective function.
- The Lagrangean relaxation may decouple.
CPAIOR tutorial
May 2009 Slide 244
Lagrangean Duality
Consider an
inequality-constrained
problem
min f ( x )
g(x ) 0
Hard constraints
x S
Easy constraints
The object is to get rid of (dualize) the hard constraints
by moving them into the objective function.
CPAIOR tutorial
May 2009 Slide 245
Lagrangean Duality
Consider an
inequality-constrained
problem
It is related to an
inference problem
min f ( x )
max v
g(x ) 0
x S
sS
g( x ) b f (x ) v
implies
Primal
Dual
min f ( x )
g( x ) 0
max v
sS
g( x ) b f (x ) v
x S
Surrogate
Let us say that
xS
g( x ) 0 f ( x ) v
iff
g ( x ) 0 dominates f (x ) v 0
for some 0
g(x) f(x) v for all x S
That is, v f(x) g(x) for all x S
CPAIOR tutorial
May 2009 Slide 247
Primal
Dual
min f ( x )
g( x ) 0
max v
sS
g( x ) b f (x ) v
x S
Surrogate
Let us say that
xS
g( x ) 0 f ( x ) v
iff
g ( x ) 0 dominates f (x ) v 0
for some 0
g(x) f(x) v for all x S
That is, v f(x) g(x) for all x S
Or v min {f ( x ) g ( x )}
xS
CPAIOR tutorial
May 2009 Slide 248
Primal
Dual
min f ( x )
g( x ) 0
max v
sS
g( x ) b f (x ) v
x S
Surrogate
Let us say that
xS
g( x ) 0 f ( x ) v
iff
g ( x ) 0 dominates f (x ) v 0
for some 0
g(x) f(x) v for all x S
That is, v f(x) g(x) for all x S
Or v min {f ( x ) g ( x )}
xS
Now we have
Primal
Dual
min f ( x )
g( x ) 0
max v
v min {f ( x ) g ( x )} for some 0
xS
x S
These constraints
are dualized
or
where
max ( )
( ) = min {f ( x ) g ( x )}
Lagrangean
relaxation
CPAIOR tutorial
May 2009 Slide 250
xS
Vector of
Lagrange
multipliers
Example
min 3 x1 + 4 x2
x1 + 3 x2 0
2 x1 + x2 5 0
x1, x2 {0,1,2,3}
= min
x j {0,,3}
Strongest
surrogate
0 if 4 31 2 0
x2 =
3 otherwise
Optimal solution (2,1)
CPAIOR tutorial
May 2009 Slide 251
Example
min 3 x1 + 4 x2
x1 + 3 x2 0
2 x1 + x2 5 0
x1, x2 {0,1,2,3}
()=5
()=9 2/7
()=0
1
()=0
()=7.5
Slide 252
Example
x1 + 3 x2 0
2 x1 + x2 5 0
x1, x2 {0,1,2,3}
min 3 x1 + 4 x2
CPAIOR tutorial
May 2009 Slide 253
g( x ) 0
x S
max ( )
0
CPAIOR tutorial
May 2009 Slide 254
k +1 = k + k k
Subgradient of () at = k
CPAIOR tutorial
May 2009 Slide 255
CPAIOR tutorial
May 2009 Slide 256
Ax b
( )
Dx d
x 0
( ) = min
{cx ( Ax b )}
Dx d
x 0
CPAIOR tutorial
May 2009 Slide 257
Ax b
( )
Dx d
x 0
( ) = min
{cx ( Ax b )}
Dx d
x 0
min cx
Ax b
At another node, the LP is Dx d
Hx h
x 0
( )
Branching
constraints,
etc.
Domain Filtering
Suppose:
min f ( x )
g(x ) 0
x S
CPAIOR tutorial
May 2009 Slide 259
min f ( x )
Supposing g ( x ) 0
x S
If x were to change to a value other than x*, the LHS of i-th constraint
gi(x) 0 would change by some amount i.
Since the constraint is tight, this would increase the optimal value
as much as changing the constraint to gi(x) i 0.
So it would increase the optimal value at least i*i.
(It is easily shown that Lagrange multipliers are marginal costs. Dual
multipliers for LP are a special case of Lagrange multipliers.)
CPAIOR tutorial
May 2009 Slide 260
min f ( x )
Supposing g ( x ) 0
x S
CPAIOR tutorial
May 2009 Slide 261
i*
min f ( x )
Supposing g ( x ) 0
x S
i*
gi ( x )
CPAIOR tutorial
May 2009 Slide 262
U v*
i*
CPAIOR tutorial
May 2009 Slide 263
x2
max x1 + x2
4 x1x2 = 1
2 x1 + x2 2
Global optimum
x1 [0,1], x2 [0,2]
Local optimum
Feasible set
x1
CPAIOR tutorial
May 2009 Slide 264
To solve it:
CPAIOR tutorial
May 2009 Slide 265
Interval propagation
x2
Propagate intervals
[0,1], [0,2]
through constraints
to obtain
[1/8,7/8], [1/4,7/4]
x1
CPAIOR tutorial
May 2009 Slide 266
CPAIOR tutorial
May 2009 Slide 267
CPAIOR tutorial
May 2009 Slide 268
min x1 + x2
4y = 1
2 x1 + x2 2
x2 x1 + x1x2 x1x2 y x2 x1 + x1x2 x1x2
x2 x1 + x1x2 x1x2 y x2 x1 + x1x2 x1x2
x j x j x j , j = 1,2
CPAIOR tutorial
May 2009 Slide 269
x2
x1
CPAIOR tutorial
May 2009 Slide 270
x2
x2 [1,1.75]
Solve linear relaxation.
x2 [0.25,1]
CPAIOR tutorial
May 2009 Slide 271
x1
x2 [0.25,1]
x2 [1,1.75]
x2
x2
x1
CPAIOR tutorial
May 2009 Slide 272
x1
x2 [0.25,1]
x2 [1,1.75]
x2
Solution of
relaxation is
feasible,
value = 1.25
x2
This becomes
incumbent
solution
x1
CPAIOR tutorial
May 2009 Slide 273
x1
x2 [0.25,1]
x2 [1,1.75]
x2
Solution of
relaxation is
feasible,
value = 1.25
This becomes
incumbent
solution
x1
CPAIOR tutorial
May 2009 Slide 274
x2
Solution of
relaxation is
not quite
feasible,
value = 1.854
Also use
Lagrange
multipliers for
domain
filtering
x1
Associated Lagrange
multiplier in solution of
relaxation is 2 = 1.1
2 x1 + x2 2
x2 x1 + x1x2 x1x2 y x2 x1 + x1x2 x1x2
x2 x1 + x1x2 x1x2 y x2 x1 + x1x2 x1x2
x j x j x j , j = 1,2
CPAIOR tutorial
May 2009 Slide 275
Associated Lagrange
multiplier in solution of
relaxation is 2 = 1.1
4y = 1
2 x1 + x2 2
x2 x1 + x1x2 x1x2 y x2 x1 + x1x2 x1x2
x2 x1 + x1x2 x1x2 y x2 x1 + x1x2 x1x2
x j x j x j , j = 1,2
2 x1 + x2 2
Value of
relaxation
CPAIOR tutorial
May 2009 Slide 276
1.854 1.25
= 1.451
1.1
Lagrange multiplier
Value of incumbent
solution
Dynamic Programming in CP
Example: Capital Budgeting
Domain Filtering
Recursive Optimization
CPAIOR tutorial
May 2009 Slide 277
Motivation
Dynamic programming (DP) is a highly versatile technique that
can exploit recursive structure in a problem.
Domain filtering is straightforward for problems modeled as a
DP.
DP is also important in designing filters for some global
constraints, such as the stretch constraint (employee scheduling).
Nonserial DP is related to bucket elimination in CP and exploits
the structure of the primal graph.
DP modeling is the art of keeping the state space small while
maintaining a Markovian property.
We will examine only one simple example of serial DP.
CPAIOR tutorial
May 2009 Slide 278
Number of
factories of type j
CPAIOR tutorial
May 2009 Slide 279
4 x1 + 2 x2 + 3 x3 12
x j {1,2}
State sk
Stage k
x3=2
xk Dxk
= 1 if there is
a path from
state sk to a
feasible
solution,
0 otherwise
CPAIOR tutorial
May 2009 Slide 280
State is sum
of first k terms
of ax
x3=1
4 x1 + 2 x2 + 3 x3 12
x j {1,2}
0
0
0
1
1
1
1 if sn +1 b
fn +1(sn +1 ) =
0 otherwise
1
1
CPAIOR tutorial
May 2009 Slide 281
0
0
xk Dxk
Boundary condition:
4 x1 + 2 x2 + 3 x3 12
x j {1,2}
0
0
0
1
1
1
1
1
Path 3: x = (1,1,1)
CPAIOR tutorial
May 2009 Slide 282
0
0
Path 2: x = (1,1,2)
Domain Filtering
4 x1 + 2 x2 + 3 x3 12
x j {1,2}
To filter domains: observe what
values of xk occur on feasible
paths.
Dx3 = {1,2}
Dx2 = {1,2}
Dx1 = {1}
CPAIOR tutorial
May 2009 Slide 283
x1=1
x2=2
x3=1
x3=2
x2=1
x3=1
Recursive Optimization
max 15 x1 + 10 x2 + 12 x3
4 x1 + 2 x2 + 3 x3 12
Maximize
revenue
x j {1,2}
= value on max
value path from
sk to final stage
(value to go)
CPAIOR tutorial
May 2009 Slide 284
122
121
Arc value
Recursive optimization
max 15 x1 + 10 x2 + 12 x3
x j {1,2}
Boundary condition:
12
34
24
0
0
if sn +1 b
0
fn +1(sn +1 ) =
otherwise
fk(sk) for each state sk
CPAIOR tutorial
May 2009 Slide 285
49
4 x1 + 2 x2 + 3 x3 12
Recursive optimization
max 15 x1 + 10 x2 + 12 x3
x j {1,2}
12
34
24
0
0
(x1,x2,x3) = (1,1,2)
CPAIOR tutorial
May 2009 Slide 286
49
4 x1 + 2 x2 + 3 x3 12
CPAIOR tutorial
May 2009 Slide 287
Motivation
Branch and price allows solution of integer programming
problems with a huge number of variables.
The problem is solved by a branch-and-relax method. The
difference lies in how the LP relaxation is solved.
Variables are added to the LP relaxation only as needed.
Variables are priced to find which ones should be added.
CP is useful for solving the pricing problem, particularly when
constraints are complex.
CP-based branch and price has been successfully applied
to airline crew scheduling, transit scheduling, and other
transportation-related problems.
CPAIOR tutorial
May 2009 Slide 288
Basic Idea
Suppose the LP relaxation of an integer
programming problem has a huge number of
variables:
We will solve a restricted master problem,
which has a small subset of the variables:
Column j of A
min cx
Ax = b
x0
c x
min
j J
A x
jJ
=b
xj 0
rk = ck Ak < 0
CPAIOR tutorial
May 2009 Slide 289
( )
Basic Idea
Adding xk to the problem would improve the solution if xk has a
negative reduced cost:
rk = ck Ak < 0
min c y y
y is a column of A
CPAIOR tutorial
May 2009 Slide 290
Basic Idea
The pricing problem
max y
y is a column of A
CPAIOR tutorial
May 2009 Slide 291
Start
time
Finish
time
CPAIOR tutorial
May 2009 Slide 292
CPAIOR tutorial
May 2009 Slide 293
u1
u2
v1
v2
v3
v4
v5
v6
CPAIOR tutorial
May 2009 Slide 301
CPAIOR tutorial
May 2009 Slide 302
CPAIOR tutorial
May 2009 Slide 303
cik ui
vj
j in roster k
Pricing problem
Crew
member 1
Crew
member 2
CPAIOR tutorial
May 2009 Slide 304
Pricing problem
Crew
member 1
Crew
member 2
CPAIOR tutorial
May 2009 Slide 305
Pricing problem
Crew
member 1
Crew
member 2
CPAIOR tutorial
May 2009 Slide 306
Pricing problem
Crew
member 1
Dual multiplier
omitted to break
symmetry
Crew
member 2
CPAIOR tutorial
May 2009 Slide 307
Pricing problem
Crew
member 1
Crew
member 2
CPAIOR tutorial
May 2009 Slide 308
Pricing problem
10
2
2
Crew
member 1
0
Crew
member 2
2
3
4
-9
5
CPAIOR tutorial
May 2009 Slide 309
1
6
Pricing problem
Solution of shortest path problems
5
10
2
2
Crew
member 1
Reduced cost = 1
Add x12 to problem.
0
Crew
member 2
Reduced cost = 2
Add x23 to problem.
CPAIOR tutorial
May 2009 Slide 310
2
3
4
-9
5
1
6
Pricing problem
The shortest path problem cannot be solved by traditional shortest
path algorithms, due to the bounds on total duration of flights.
It can be solved by CP:
Set of flights
assigned to crew
member i
Path global constraint
Setsum global constraint
Path
length
Graph
CPAIOR tutorial
May 2009 Slide 312
Motivation
Benders decomposition allows us to apply CP and OR to
different parts of the problem.
It searches over values of certain variables that, when fixed,
result in a much simpler subproblem.
The search learns from past experience by accumulating
Benders cuts (a form of nogood).
The technique can be generalized far beyond the original OR
conception.
Generalized Benders methods have resulted in the greatest
speedups achieved by combining CP and OR.
CPAIOR tutorial
May 2009 Slide 313
min f ( x, y )
S( x, y )
x Dx , y Dy
min f ( x , y )
S( x , y )
y Dy
perhaps
because it
decouples into
smaller problems.
Benders Decomposition
We will search over assignments to x. This is the master problem.
In iteration k we assume x = xk
and solve the subproblem
min f ( x k , y )
S( x k , y )
y Dy
v Bk +1( x )
The Benders cut says that if we set x = xk again, the resulting cost v
will be at least vk. To do better than vk, we must try something else.
It also says that any other x will result in a cost of at least Bk+1(x),
perhaps due to some similarity between x and xk.
CPAIOR tutorial
May 2009 Slide 315
Benders Decomposition
We will search over assignments to x. This is the master problem.
In iteration k we assume x = xk
and solve the subproblem
min f ( x k , y )
S( x k , y )
y Dy
v Bk +1( x )
min v
v Bi ( x ), i = 1,, k + 1
x Dx
CPAIOR tutorial
May 2009 Slide 316
Benders cuts
generated so far
Benders Decomposition
min v
We now solve the v B ( x ), i = 1,, k + 1
i
master problem
x Dx
min f ( x ) + cy
g ( x ) + Ay b
x Dx , y 0
min f ( x ) + cy
Ay b g ( x k ) ( )
y 0
k
whose dual is
max f ( x k ) + ( b g ( x k ) )
A c
0
Classical Benders
So the master problem
becomes
min v
v Bi ( x ), i = 1,, k + 1
x Dx
min v
v f ( x ) + i (b g ( x )), i = 1,, k + 1
x Dx
CPAIOR tutorial
May 2009 Slide 319
CPAIOR tutorial
May 2009 Slide 320
Machine Scheduling
Job Data
Machine A
Machine B
CPAIOR tutorial
May 2009 Slide 321
Machine Scheduling
Job Data
Minimum makespan
schedule for jobs 1, 2, 3, 5
on machine A
CPAIOR tutorial
May 2009 Slide 322
Machine Scheduling
The problem is
min M
M s j + px j j , all j
r j s j d j px j j , all j
Time windows
Jobs cannot overlap
CPAIOR tutorial
May 2009 Slide 323
Machine Scheduling
The problem is
min M
M s j + px j j , all j
r j s j d j px j j , all j
Time windows
Jobs cannot overlap
min M
M s j + px j j , all j with x j = i
r j s j d j px j j , all j with x j = i
CPAIOR tutorial
May 2009 Slide 324
Benders cuts
Suppose we assign jobs 1,2,3,5 to machine A in iteration k.
We can prove that 10 is the optimal makespan by proving that the
schedule is infeasible with makespan 9.
10 if x2 = x3 = x4 = A
v Bk +1( x ) =
0 otherwise
CPAIOR tutorial
May 2009 Slide 325
Benders cuts
We want the master problem to be an MILP, which is good for
assignment problems.
So we write the Benders cut
10 if x2 = x3 = x4 = A
v Bk +1( x ) =
0 otherwise
v 10 ( x A 2 + x A3 + x A5 2 )
= 1 if job 5 is
v 0
assigned to
machine A
CPAIOR tutorial
May 2009 Slide 326
Master problem
The master problem is an MILP:
min v
5
p
j =1
Aj
x Aj 10, etc.
Constraints derived from release times
p
j =1
Bj
j =1
j =3
v Mik xij J ik + 1
jJik
Min makespan
on machine i
in iteration k
Set of jobs
assigned to
machine i in
iteration k
A stronger cut provides a useful bound even if only some of the jobs in
Jik are assigned to machine i:
v Mik
(1 x
j Jik
ij
)pij
CPAIOR tutorial
May 2009 Slide 329