General Principles of Constraint Programming
description
Transcript of General Principles of Constraint Programming
1
General Principles of Constraint Programming
Jean-Charles REGINDirector of Constraint Programming
ILOG, Sophia Antipolis, [email protected]
2
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
3
History
General Problem Solvers in 70’s ALICE [J-F Lauriere, AIJ 78], phD in Paris VI, 76
Prolog: CHIP, ECRC Munich 86 (Alice in Prolog) Colmerauer, Gallaire, Van Hentenryck
Constraint Satisfaction Problems Waltz 72, Mackworth 74, Freuder 76
Industry: Bull (Charme), ILOG (Solver) 92
4
Constraint Programming
In CP a problem is defined from:- variables with possible values (domain)- constraints
Domain can be discrete or continuous, symbolic values or numerical values
Constraints express properties that have to be satisfied
5
Problem = conjunction of sub-problems
In CP a problem can be viewed as a conjunction of sub-problems that we are able to solve
A sub-problem can be trivial: x < y or complex: search for a feasible flow
A sub-problem = a constraint
6
Constraints
Predefined constraints: arithmetic (x < y, x = y +z, |x-y| > k, alldiff, cardinality, sequence …
Constraints given in extension by the list of allowed (or forbidden) combinations of values
user-defined constraints: any algorithm can be encapsulated Logical combination of constraints using OR, AND, NOT, XOR
operators. Sometimes called meta-constraints
7
Filtering
We are able to solve a sub-problem: a method is available
CP uses this method to remove values from domain that do not belong to a solution of this sub-problem: filtering or domain-reduction
E.g: x < y and D(x)=[10,20], D(y)=[5,15]=> D(x)=[10,14], D(y)=[11,15]
8
Filtering
A filtering algorithm is associated with each constraint (sub-problem).
Can be simple (x < y) or complex (alldiff) Theoretical basics: arc consistency, remove all the
values that do not belong to a solution of the underlined sub-problem.
9
Propagation
Domain Reduction due to one constraint can lead to new domain reduction of other variables
When a domain is modified all the constraints involving this variable are studied and so on ...
10
Propagation
D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6}
Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6
11
Propagation
D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6}
Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6• Alldiff({x,y,z}): FA=> z=2
12
Propagation
D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6}
Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6• Alldiff({x,y,z}): FA=> z=2 u=z+3: FA=> u=5
13
Propagation
D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6}
Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6• Alldiff({x,y,z}): FA=> z=2 u=z+3: FA=> u=5 v>u: FA=> v=6
14
Propagation
D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6}
Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6• Alldiff({x,y,z}): FA=> z=2 u=z+3: FA=> u=5 v>u: FA=> v=6 |z-v|<6: FA => y=1
15
Propagation
D(x)=D(y)={0,1}, D(z)={0,1,2}, D(u)={3,4,5}, D(v)={4,5,6}
Alldiff({x,y,z}), u=z+3, v>u, |z-v|<6• Alldiff({x,y,z}): FA=> z=2 u=z+3: FA=> u=5 v>u: FA=> v=6 |z-v|<6: FA => y=1 Alldiff({x,y,z}): FA=> x=0 Solution: x=0, y=1, z=2, u=5, v=6
16
Why Propagation?
Idea: problem = conjunction of easy sub-problems. Sub-problems: local point of view. Problem: global
point of view. Propagation tries to obtain a global point of view from independent local point of view
The conjunction is stronger that the union of independent resolution
17
Search
Backtrack algorithm with strategies:try to successively assign variables with values. If a dead-end occurs then backtrack and try another value for the variable
Strategy: define which variable and which value will be chosen.
After each domain reduction (I.e assignement include) filtering and propagation are triggered
18
Constraint Programming
3 notions:- constraint network: variables, domains constraints + filtering (domain reduction)- propagation- search procedure (assignments + backtrack)
The structure of every constraint is exploited
19
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
20
CP vs other techniques
CP vs greedy algorithms CP vs local search CP vs inference engines CP vs MIP
21
CP vs greedy algorithm
Greedy algorithm = a search strategy which guarantees that there is no backtrack
CP is a generalization: your strategy can be non necessarily greedy. Solver manages for you the “errors” of your strategy
Some problems are solved with few backtracks
22
CP vs local search
Local search: it is hard to respect hard constraints. With CP no problem
Combination of CP and local search is used quite often to solve problems: find a first solution with CP then re-optimize it iteratively.
23
CP vs Inference engines
(A implies B) represented by (NOT A OR B) (x < 5 implies z > 4) Propagation from Left to Right: if x < 5 then z > 4 Propagation from Right to Left: if z < 5 then
necessarily x >4
24
CP vs MIPMIP approach CP approach
25
CP vs MIP
Relax the problem: floats instead of integers
1) Use the Simplex algorithm (“polynomial”)
2) Set float to integer value. Go to 1) and backtrack if necessary
MIP approach CP approach
26
CP vs MIP
Relax the problem: floats instead of integers
1) Use the Simplex algorithm (“polynomial”)
2) Set float to integer value. Go to 1) and backtrack if necessary
Identify sub-problems that are easy (called constraints)
1) Use specific algorithm for solving these sub-problems and for performing domain-reduction
2) Instantiate variable. Go to 1) and backtrack if necessary
MIP approach CP approach
27
CP vs MIP
Relax the problem: floats instead of integers
1) Use the Simplex algorithm (“polynomial”)
2) Set float to integer value. Go to 1) and backtrack if necessary
Global point of view on a relaxation of the problem
Identify sub-problems that are easy (called constraints)
1) Use specific algorithm for solving these sub-problems and for performing domain-reduction
2) Instantiate variable. Go to 1) and backtrack if necessary
Local point of view on sub-problems. “Global” point of view by propagation of domain reductions
MIP approach CP approach
28
CP vs MIP
In CP constraints can be non-linear Structure of the problem is used in CP Semantic of the constraints are used: much easier to
add a global constraint with a filtering algorithm than defining a new cut
First solution given by CP is generally good
29
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
30
Arc consistency
All the values which do not belong to any solution of the constraint are deleted.
Example: Alldiff({x,y,z}) with D(x)=D(y)={0,1}, D(z)={0,1,2}the two variables x and y take the values 0 and 1, thus z cannot take these values.FA by AC => 0 and 1 are removed from D(z)
31
Alldiff constraint
x1
x2
x3
x4
x5
x6
1
2
3
4
5
6
7
The value graph:
D(x1)={1,2}D(x2)={2,3}D(x3)={1,3}D(x4)={3,4}D(x5)={2,4,5,6}D(x6)={5,6,7}
32
Value network
x1
x2
x3
x4
x5
x6
1
2
3
4
5
6
7
t s
(6,6)
(0,1)
(0,1)
(1,1)
Default orientation
33
A feasible flow
x1
x2
x3
x4
x5
x6
1
2
3
4
5
6
7
t s
(6,6)
(0,1)
(0,1)
(1,1)
Default orientation
34
Residual graph
x1
x2
x3
x4
x5
x6
1
2
3
4
5
6
7
s
orientation
35
Residual graph
x1
x2
x3
x4
x5
x6
1
2
3
4
5
6
7
s
orientation
36
Arc consistency
x1
x2
x3
x4
x5
x6
1
2
3
4
5
6
7
The value graph:
D(x1)={1,2}D(x2)={2,3}D(x3)={1,3}D(x4)={4}D(x5)={5,6}D(x6)={5,6,7}
37
Alldiff constraint
Compute a feasible flow Compute the strongly connected components Remove every arc of flow value 0 for which the ends
belong to two different components Linear algorithm achieving arc consistency Idem for global cardinality constraints work well due to (0,1) arcs
38
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
39
The problem
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
40
The problem
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
• Problem 10teams of the MIPLIB (n=10 and the objective function is dummy)• MIP is not able to find a solution for n=14• CP finds a solution for n=10 in 0.06s, n=14 in 0.2, n=40 in 6h
41
The problem
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
For 40 teams: 800 variables with 39 possible values foreach variable.
42
CP model: variables
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3
For each slot: 2 variables represent the teams and 1 variable represents the match are defined
1 vs 6
T33a variable (T33a=6)T33h variable (T33h=1)
M33 variable (M33=12) Mij=1 <=> 0 vs 1 or 1 vs 0Mij=12 <=> 1 vs 6 or 6 vs1
43
CP model: T variables
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 T11h vsT11a
T12h vsT12a
T13h vsT13a
T14h vsT14a
T15h vsT15a
T16h vsT16a
T17h vsT17a
Period 2 T21h vsT21a
T22h vsT22a
T23h vsT23a
T24h vsT24a
T25h vsT25a
T26h vsT26a
T27h vsT27a
Period 3 T31h vsT31a
T32h vsT32a
T33h vsT33a
T34h vsT34a
T35h vsT35a
T36h vsT36a
T37h vsT37a
Period 4 T41h vsT41a
T42h vsT42a
T43h vsT43a
T44h vsT44a
T45h vsT45a
T46h vsT46a
T47h vsT47a
D(Tija)=[1,n-1]D(Tijh)=[0,n-2]
Tijh < Tija
44
CP model: M variables
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
D(Mij)=[1,n(n-1)/2]
45
CP model: constraints
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
• n teams and n-1 weeks and n/2 periodsn teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each weekevery team plays one game in each week• no team plays more than twice in the same periodno team plays more than twice in the same period
46
CP model: constraints
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
• n teams and n-1 weeks and n/2 periodsn teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each weekevery team plays one game in each week• no team plays more than twice in the same periodno team plays more than twice in the same period
Alldiff constraints defined on M variables
47
CP model: constraints
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 T11h vsT11a
T12h vsT12a
T13h vsT13a
T14h vsT14a
T15h vsT15a
T16h vsT16a
T17h vsT17a
Period 2 T21h vsT21a
T22h vsT22a
T23h vsT23a
T24h vsT24a
T25h vsT25a
T26h vsT26a
T27h vsT27a
Period 3 T31h vsT31a
T32h vsT32a
T33h vsT33a
T34h vsT34a
T35h vsT35a
T36h vsT36a
T37h vsT37a
Period 4 T41h vsT41a
T42h vsT42a
T43h vsT43a
T44h vsT44a
T45h vsT45a
T46h vsT46a
T47h vsT47a
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
48
CP model: constraints
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 T11h vsT11a
T12h vsT12a
T13h vsT13a
T14h vsT14a
T15h vsT15a
T16h vsT16a
T17h vsT17a
Period 2 T21h vsT21a
T22h vsT22a
T23h vsT23a
T24h vsT24a
T25h vsT25a
T26h vsT26a
T27h vsT27a
Period 3 T31h vsT31a
T32h vsT32a
T33h vsT33a
T34h vsT34a
T35h vsT35a
T36h vsT36a
T37h vsT37a
Period 4 T41h vsT41a
T42h vsT42a
T43h vsT43a
T44h vsT44a
T45h vsT45a
T46h vsT46a
T47h vsT47a
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
For each week w:Alldiff constraint definedon {Tpwh, p=1..4} U {Tpwa, p=1..4}
49
CP model: constraints
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 T11h vsT11a
T12h vsT12a
T13h vsT13a
T14h vsT14a
T15h vsT15a
T16h vsT16a
T17h vsT17a
Period 2 T21h vsT21a
T22h vsT22a
T23h vsT23a
T24h vsT24a
T25h vsT25a
T26h vsT26a
T27h vsT27a
Period 3 T31h vsT31a
T32h vsT32a
T33h vsT33a
T34h vsT34a
T35h vsT35a
T36h vsT36a
T37h vsT37a
Period 4 T41h vsT41a
T42h vsT42a
T43h vsT43a
T44h vsT44a
T45h vsT45a
T46h vsT46a
T47h vsT47a
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
50
CP model: constraints
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 T11h vsT11a
T12h vsT12a
T13h vsT13a
T14h vsT14a
T15h vsT15a
T16h vsT16a
T17h vsT17a
Period 2 T21h vsT21a
T22h vsT22a
T23h vsT23a
T24h vsT24a
T25h vsT25a
T26h vsT26a
T27h vsT27a
Period 3 T31h vsT31a
T32h vsT32a
T33h vsT33a
T34h vsT34a
T35h vsT35a
T36h vsT36a
T37h vsT37a
Period 4 T41h vsT41a
T42h vsT42a
T43h vsT43a
T44h vsT44a
T45h vsT45a
T46h vsT46a
T47h vsT47a
• n teams and n-1 weeks and n/2 periods• every two teams play each other exactly once• every team plays one game in each week• no team plays more than twice in the same period
For each period p:Global cardinality constraint defined on{Tpwh, w=1..7} U {Tpwa, w=1..7}every team t is taken at most 2
51
CP model: constraints
For each slot the two T variables and the M variable must be linked together; example:M12 = game T12h vs T12a
52
CP model: constraints
For each slot the two T variables and the M variable must be linked together; example:M12 = game T12h vs T12a
For each slot we add Cij a ternary constraint defined on the two T variables and the M variable; example:C12 defined on {T12h,T12a,M12}
53
CP model: constraints
For each slot the two T variables and the M variable must be linked together; example:M12 = game T12h vs T12a
For each slot we add Cij a ternary constraint defined on the two T variables and the M variable; example:C12 defined on {T12h,T12a,M12}
Cij are defined by the list of allowed tuples: for n=4: {(0,1,1),(0,2,2),(0,3,3),(1,2,4),(1,3,5),(2,3,6)}(1,2,4) means game 1 vs 2 is the game number 4
54
CP model: constraints
For each slot the two T variables and the M variable must be linked together; example:M12 = game T12h vs T12a
For each slot we add Cij a ternary constraint defined on the two T variables and the M variable; example:C12 defined on {T12h,T12a,M12}
Cij are defined by the list of allowed tuples: for n=4: {(0,1,1),(0,2,2),(0,3,3),(1,2,4),(1,3,5),(2,3,6)}(1,2,4) means game 1 vs 2 is the game number 4
All these constraints have the same list of allowed tuples Efficient arc consistency algorithm for this kind of constraint is known
55
First model
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Dummy
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 . vs .
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 . vs .
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 . vs .
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 . vs .
Introduction of a dummy column
56
First model
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Dummy
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 . vs .
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 . vs .
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 . vs .
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 . vs .
Introduction of a dummy column
We can prove that:• each team occurs exactly twice for each period
57
First model
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Dummy
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 5 vs 6
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 . vs .
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 . vs .
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 . vs .
Introduction of a dummy column
We can prove that:• each team occurs exactly twice for each period
58
First model
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Dummy
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 5 vs 6
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 2 vs 4
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 1 vs 3
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 0 vs 7
Introduction of a dummy column
We can prove that:• each team occurs exactly twice for each period
59
First model
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Dummy
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 5 vs 6
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 2 vs 4
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 1 vs 3
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 0 vs 7
Introduction of a dummy column
We can prove that:• each team occurs exactly twice for each period• each team occurs exactly once in the dummy column
60
First model
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Dummy
Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 5 vs 6
Period 2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 2 vs 4
Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 1 vs 3
Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 0 vs 7
Introduction of a dummy column
• The problem is exactly the same• The solver is helped by such constraint. It can deduce someinconsistencies more quickly
61
First model: strategies
Break symmetries: 0 vs w appears in week w
62
First model: strategies
Break symmetries: 0 vs w appears in week w Teams are instantiated:
- the most instantiated team is chosen- the slots that has the less remaining possibilities (Tijh or Tija is minimal) is instantiated with that team
63
First model: results
# teams # fails Time (in s)
4 2 0.01
6 12 0.03
8 32 0.08
10 417 0.8
12 41 0.214 3,514 9.2
16 1,112 4.2
18 8,756 36
20 72,095 338
22 6,172,672 10h
24 6,391,470 12h
MIPLIB
MIP solver limit
64
Second model
Break symmetry: 0 vs 1 is the first game of the dummy column
65
Second model
Break symmetry: 0 vs 1 is the first game of the dummy column
1) Find a round-robin. Define all the games for each column (except for the dummy)- Alldiff constraint on M is satisfied- Alldiff constraint for each week is satisfied
66
Second model
Break symmetry: 0 vs 1 is the first game of the dummy column
1) Find a round-robin. Define all the games for each column (except for the dummy)- Alldiff constraint on M is satisfied- Alldiff constraint for each week is satisfied
2) set the games in order to satisfy constraints on periods. If no solution go to 1)
67
Second model: strategy
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
M variables are instantiated
68
Second model: strategy
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
M variables are instantiated
69
Second model: strategy
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
M variables are instantiated
70
Second model: strategy
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
M variables are instantiated
71
Second model: strategy
Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7
Period 1 M11 M12 M13 M14 M15 M16 M17
Period 2 M21 M22 M23 M24 M25 M26 M27
Period 3 M31 M32 M33 M34 M35 M36 M37
Period 4 M41 M42 M43 M44 M45 M46 M47
M variables are instantiated
72
Second model: results
# teams # fails Time (in s)
8 10 0.01
10 24 0.06
12 58 0.2
14 21 0.2
16 182 0.618 263 0.9
20 226 1.2
24 2702 10.5
26 5,683 26.4
30 11,895 138
40 2,834,754 6h
MIPLIB
MIP limit
First model limit
73
Assume P ≠ NP
Ok, we cannot avoid an exponential behavior For some instances, an NP Complete Problem will
required an exponential time to be solved So, our only hope is to shift the exponential such
that the problem is solvable for a size and a time that are acceptable
74
Shifting the exponential
0100200300400500600700800900
0 10 20 30 40 50
pb
75
Shifting the exponential
0
200
400
600
800
1000
1200
1400
0 10 20 30 40 50 60 70 80
pb
76
Why does CP perform well?
Pure discrete problem. You can give any number to the teams
This is a feasibility problem (no objective function). No arithmetic symbol: +, -, = is used A global point of view on the global cardinality
constraints (i.e. group these constraints into only one) does not help
77
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
78
Strength of CP
Very flexible (easy to take into account new constraints)
The system is open: you can define you own constraints, your own search mechanism.
CP allows the use of sophisticated strategies, you can use the knowledge of the domain of application.
You just have to respect a protocol given by a solver. The solver manages the propagation and provides you with a lot of predefined things
79
Strength of CP
CP is exact: no solution is lost even for float variables
Any existing algorithm can be integrated in CP as a filtering algorithm of a constraints
Concepts are simple A first model can be defined and tested quickly For optimization problems: the first solution is a good
one Easy to introduce your new “idea” in the system Cooperation is easy thanks to constraints
80
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
81
Weakness of CP
Must be improved for optimization problems: spend too much time in proving sub-optimality
First step: integration of cost in the constraints Sometimes lack of global point of view Dark zones: press Enter key then ? Relaxation is not good for CP. We learn relaxation at
school!
82
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
83
New research areas New point of view: CP is based on filtering algorithm, i.e. : Given a
property P defining a necessary condition for an element to be in a solutionFind as quickly as possible ALL elements that do not satisfy P
Ex: alldiff constraint and matching, cardinality constraint and flows etc…
Close to sensitivity analysis, but also different (for instance we only have monotonic modifications).
84
New research areas
Consider a Minimization problem, and OBJ the objective. Suppose that we found a “solution” with OBJ=25.
We will reject any “solution” with OBJ > 24. So if x=a leads to an OBJ > 24 then value a must be removed from D(x).
If we have a lower bound of OBJ then we can use it:if lb(OBJ,x=a) > 24 then remove a from D(x)
Problem: literature mainly gives upper bound for minimization problems and lower bound for maximization problems.
Not always easy to get lb of good quality
85
New research areas
The very same algorithm is called thousand times (million sometimes)
The incremental aspect of the algorithm becomes really important.
86
Plan
General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP New research Area Recent advances in CP at ILOG Conclusion
87
Recent advances in CP at ILOG
Let’s start with a real world example that involved a lot of people in ILOG:
The ROCOCO project From this project we learnt a lot of things
88
The ROCOCO Problem (1)
Routing of Communications Mono-routing: each demand from a point p to a point q
must follow a unique path Dimensioning of Links
The capacity of each link must exceed the sums of the demands going through the link
Additional Constraints Depend on the customer for whom the network is
designed
89
The ROCOCO Problem (2)
Data:• Customer traffic
demands• Possible links,
capacities and costs
S1 S2
S3
S4
S1S2
S3
S4
Result: Minimal cost
network able to simultaneously respond to all the demands
Route for each demand
27Kb/s
115Kb/s
Rented capacity 256Kb/s
90
The ROCOCO Problem (3)
Cost minimization principle Traffic demands share link capacities
S1 S2
S3
512Kb/s128Kb/s
115Kb/s
256Kb/s
91
The Problem (4)
Demands share links
demandsij capacityij
Technological constraints
256Kb/s
64Kb/s64Kb/s64Kb/s64Kb/s
128Kb/s
128Kb/s
64Kb/s64Kb/s
128Kb/s
92
The Problem (5)
Side constraints Quality of service Reuse of existing equipment (limit on the number of ports,
maximal traffic at a node)
Commercial and legal constraints Possible future network evolution Network management (e.g., traffic concentration)
64Kb/s64Kb/s64Kb/s64Kb/s
93
Optional Constraints
Security: some commodities to be secured cannot go through unsecured nodes and links
No line multiplication: at most one line per arc. Symmetric routing: demands from node p to node q and demands from node q
to node p are routed on symmetric paths. Number of bounds (hops): the number of arcs of the path used to route a
given demand is limited. Number of ports: the number of links entering into or leaving from a node is
limited.
Maximal traffic: the total traffic managed by a given node is limited.
64Kb/s64Kb/s64Kb/s64Kb/s
94
Numerical Characteristics (1)A10
05000
100001500020000250003000035000
0 100 200 300 400 500 600
Capacity
Co
st
B10
0
1000
2000
3000
4000
0 500 1000 1500 2000 2500
Capacity
Co
st
C10
0
500
1000
1500
2000
2500
0 10000 20000 30000 40000
Capacity
Co
st
B10-MULT
0
5000
10000
15000
20000
0 2000 4000 6000 8000 10000 12000
Capacity
Co
st
95
We worked a lot!
Average deviation from best-known solutions
0.00%
5.00%
10.00%
15.00%
20.00%
25.00%
30.00%
35.00%
A04 A06 A08 A10 B10 B12 B16 B25 C10 C12 C16 C25
CP-LS
CP-LNS02
CP-LNS03
CP-LNS04
CP-LNS04//
CP-LNS04//-8P
CP-LNS//-MOD1
CP-LNS//-MOD2
CP//
MIP
COLGEN
BPC02
96
The key idea: path variable!
97
General considerations
When solving a problem in CP: Potential performance gain:
data structure optimization (code): x 10 search strategies: x 1 000 model : x 1 000 000
Repartition of effort for ROCOCO data structure optimization (code): 65 % search strategies: 25 % model: 10 %
98
General considerations
When solving a problem in CP: Potential performance gain:
data structure optimization (code): x 10 search strategies: x 1 000 model : x 1 000 000
Repartition of effort for ROCOCO data structure optimization (code): 65 % search strategies: 25 % model: 10 %
Objective of CP Optimizer data structure optimization (code): 0 % search strategies: 10 % model: 90 %
99
Our current focus is on simplifying the solving process for the user
The user can then concentrate on modeling Why?
Huge ROI: a good model may lead to x1000000 improvement
The goal of CP is to be close to the natural description of the problem
Usability of our product will be improved
Focus CP at ILOG
100
Our current focus is on simplifying the solving process for the user
The user can then concentrate on modeling How?
Introduce a built-in intelligent search strategy Control the strategy only through higher-level
mechanisms Increase speed of the search
Increase inference strength (constraint propagation) Increase efficiency of the engine
Focus CP at ILOG
101
ILOG Solver is a mature product which has been on the market for fifteen years
We are embarking on a new product with a redesigned engine which we call ILOG CP
ILOG CP
102
Conclusion
CP is a general technique: can encapsulate a lot of work
CP is an efficient method for solving some combinatorial problems: small or large
Filtering algorithms are quite important for non binary constraints
CP allows the use of sophisticated strategies If you want to use CP: think CP (avoid Boolean (0-1)
variables). CP allows the use of symbolic representation
103
More information
Go to www.ilog.com Go to my webpage:
www.constraint-programming.com/people/reginor google my name: Jean Charles Regin