general principles of constraint programming

103
1 General Principles of Constraint Programming Jean-Charles REGIN Director of Constraint Programming ILOG, Sophia Antipolis, France [email protected]

Upload: bena

Post on 30-Jan-2016

66 views

Category:

Documents


0 download

DESCRIPTION

General Principles of Constraint Programming. Jean-Charles REGIN Director of Constraint Programming ILOG, Sophia Antipolis, France [email protected]. Plan. General Principles CP vs other techniques Filtering algorithms An example: sports scheduling Strength of CP Weakness of CP - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: General Principles of Constraint Programming

1

General Principles of Constraint Programming

Jean-Charles REGINDirector of Constraint Programming

ILOG, Sophia Antipolis, [email protected]

Page 2: General Principles of Constraint Programming

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

Page 3: General Principles of Constraint Programming

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

Page 4: General Principles of Constraint Programming

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

Page 5: General Principles of Constraint Programming

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

Page 6: General Principles of Constraint Programming

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

Page 7: General Principles of Constraint Programming

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]

Page 8: General Principles of Constraint Programming

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.

Page 9: General Principles of Constraint Programming

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 ...

Page 10: General Principles of Constraint Programming

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

Page 11: General Principles of Constraint Programming

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

Page 12: General Principles of Constraint Programming

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

Page 13: General Principles of Constraint Programming

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

Page 14: General Principles of Constraint Programming

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

Page 15: General Principles of Constraint Programming

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

Page 16: General Principles of Constraint Programming

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

Page 17: General Principles of Constraint Programming

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

Page 18: General Principles of Constraint Programming

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

Page 19: General Principles of Constraint Programming

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

Page 20: General Principles of Constraint Programming

20

CP vs other techniques

CP vs greedy algorithms CP vs local search CP vs inference engines CP vs MIP

Page 21: General Principles of Constraint Programming

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

Page 22: General Principles of Constraint Programming

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.

Page 23: General Principles of Constraint Programming

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

Page 24: General Principles of Constraint Programming

24

CP vs MIPMIP approach CP approach

Page 25: General Principles of Constraint Programming

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

Page 26: General Principles of Constraint Programming

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

Page 27: General Principles of Constraint Programming

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

Page 28: General Principles of Constraint Programming

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

Page 29: General Principles of Constraint Programming

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

Page 30: General Principles of Constraint Programming

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)

Page 31: General Principles of Constraint Programming

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}

Page 32: General Principles of Constraint Programming

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

Page 33: General Principles of Constraint Programming

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

Page 34: General Principles of Constraint Programming

34

Residual graph

x1

x2

x3

x4

x5

x6

1

2

3

4

5

6

7

s

orientation

Page 35: General Principles of Constraint Programming

35

Residual graph

x1

x2

x3

x4

x5

x6

1

2

3

4

5

6

7

s

orientation

Page 36: General Principles of Constraint Programming

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}

Page 37: General Principles of Constraint Programming

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

Page 38: General Principles of Constraint Programming

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

Page 39: General Principles of Constraint Programming

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

Page 40: General Principles of Constraint Programming

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

Page 41: General Principles of Constraint Programming

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.

Page 42: General Principles of Constraint Programming

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

Page 43: General Principles of Constraint Programming

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

Page 44: General Principles of Constraint Programming

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]

Page 45: General Principles of Constraint Programming

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

Page 46: General Principles of Constraint Programming

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

Page 47: General Principles of Constraint Programming

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

Page 48: General Principles of Constraint Programming

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}

Page 49: General Principles of Constraint Programming

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

Page 50: General Principles of Constraint Programming

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

Page 51: General Principles of Constraint Programming

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

Page 52: General Principles of Constraint Programming

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}

Page 53: General Principles of Constraint Programming

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

Page 54: General Principles of Constraint Programming

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

Page 55: General Principles of Constraint Programming

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

Page 56: General Principles of Constraint Programming

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

Page 57: General Principles of Constraint Programming

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

Page 58: General Principles of Constraint Programming

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

Page 59: General Principles of Constraint Programming

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

Page 60: General Principles of Constraint Programming

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

Page 61: General Principles of Constraint Programming

61

First model: strategies

Break symmetries: 0 vs w appears in week w

Page 62: General Principles of Constraint Programming

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

Page 63: General Principles of Constraint Programming

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

Page 64: General Principles of Constraint Programming

64

Second model

Break symmetry: 0 vs 1 is the first game of the dummy column

Page 65: General Principles of Constraint Programming

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

Page 66: General Principles of Constraint Programming

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)

Page 67: General Principles of Constraint Programming

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

Page 68: General Principles of Constraint Programming

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

Page 69: General Principles of Constraint Programming

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

Page 70: General Principles of Constraint Programming

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

Page 71: General Principles of Constraint Programming

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

Page 72: General Principles of Constraint Programming

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

Page 73: General Principles of Constraint Programming

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

Page 74: General Principles of Constraint Programming

74

Shifting the exponential

0100200300400500600700800900

0 10 20 30 40 50

pb

Page 75: General Principles of Constraint Programming

75

Shifting the exponential

0

200

400

600

800

1000

1200

1400

0 10 20 30 40 50 60 70 80

pb

Page 76: General Principles of Constraint Programming

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

Page 77: General Principles of Constraint Programming

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

Page 78: General Principles of Constraint Programming

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

Page 79: General Principles of Constraint Programming

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

Page 80: General Principles of Constraint Programming

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

Page 81: General Principles of Constraint Programming

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!

Page 82: General Principles of Constraint Programming

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

Page 83: General Principles of Constraint Programming

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).

Page 84: General Principles of Constraint Programming

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

Page 85: General Principles of Constraint Programming

85

New research areas

The very same algorithm is called thousand times (million sometimes)

The incremental aspect of the algorithm becomes really important.

Page 86: General Principles of Constraint Programming

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

Page 87: General Principles of Constraint Programming

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

Page 88: General Principles of Constraint Programming

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

Page 89: General Principles of Constraint Programming

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

Page 90: General Principles of Constraint Programming

90

The ROCOCO Problem (3)

Cost minimization principle Traffic demands share link capacities

S1 S2

S3

512Kb/s128Kb/s

115Kb/s

256Kb/s

Page 91: General Principles of Constraint Programming

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

Page 92: General Principles of Constraint Programming

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

Page 93: General Principles of Constraint Programming

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

Page 94: General Principles of Constraint Programming

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

Page 95: General Principles of Constraint Programming

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

Page 96: General Principles of Constraint Programming

96

The key idea: path variable!

Page 97: General Principles of Constraint Programming

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 %

Page 98: General Principles of Constraint Programming

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 %

Page 99: General Principles of Constraint Programming

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

Page 100: General Principles of Constraint Programming

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

Page 101: General Principles of Constraint Programming

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

Page 102: General Principles of Constraint Programming

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

Page 103: General Principles of Constraint Programming

103

More information

Go to www.ilog.com Go to my webpage:

www.constraint-programming.com/people/reginor google my name: Jean Charles Regin