235
The Thousand Faces of Constraint Propagation Emmanuel Hebrard Toulouse 1 / 54

The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Thousand Faces of Constraint Propagation

Emmanuel Hebrard

Toulouse

1 / 54

Page 2: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Outline

1 Propagation and Constraint Programming

2 An Example of PropagatorThe Switch constraint

3 Complexity of Propagating vs. Complexity of SolvingThe AtMostSeqCard constraint

4 NP-hard ConstraintsThe SoftAllEqual constraint

5 Assessing the TradeoffThe NValue constraint

6 Conclusion

2 / 54

Page 3: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:I Constraint ⇔ “easy” SubproblemI Propagation to link the reasoning done

on each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 4: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:I Constraint ⇔ “easy” SubproblemI Propagation to link the reasoning done

on each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 5: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:I Constraint ⇔ “easy” SubproblemI Propagation to link the reasoning done

on each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 6: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:

I Constraint ⇔ “easy” SubproblemI Propagation to link the reasoning done

on each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 7: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:I Constraint ⇔ “easy” Subproblem

I Propagation to link the reasoning doneon each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 8: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:I Constraint ⇔ “easy” SubproblemI Propagation to link the reasoning done

on each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 9: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Programming

Solving hard combinatorial problems byDecomposition

I Good news: We can always decomposeF into known/easy/small subproblems

I Bad news: Solving each subproblem isnot enough

Constraint Progamming:I Constraint ⇔ “easy” SubproblemI Propagation to link the reasoning done

on each constraint

23 30 27 12 16

17

15

12

7 7

11 10

16

17

35

21

6

7

16

29

24

8

5

3

3 / 54

Page 10: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Satisfaction Problem

Variables: x1, . . . , xnConstraints: C1, . . . ,Ck

I Relations = set of solutions

Domains: D1, . . . ,DnI Domain representation ' relaxation of the problem’s solutions

F D1 × D2 × . . .× Dn is a super set of the solutions

4 / 54

Page 11: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Satisfaction Problem

Variables: x1, . . . , xn

Constraints: C1, . . . ,Ck

I Relations = set of solutions

Domains: D1, . . . ,DnI Domain representation ' relaxation of the problem’s solutions

F D1 × D2 × . . .× Dn is a super set of the solutions

4 / 54

Page 12: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Satisfaction Problem

Variables: x1, . . . , xnConstraints: C1, . . . ,Ck

I Relations = set of solutions

Domains: D1, . . . ,DnI Domain representation ' relaxation of the problem’s solutions

F D1 × D2 × . . .× Dn is a super set of the solutions

4 / 54

Page 13: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Satisfaction Problem

Variables: x1, . . . , xnConstraints: C1, . . . ,Ck

I Relations = set of solutions

Domains: D1, . . . ,DnI Domain representation ' relaxation of the problem’s solutions

F D1 × D2 × . . .× Dn is a super set of the solutions

4 / 54

Page 14: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Domain Representation (discrete domains)

4 Letters Palindrome City ProblemI Con. 1: It is a cityI Con. 2: It is a palindromeI Domain: any 2 letters (676 sol.)

L1 L2 L2 L1

A K K AA N N AI L L I

M A A MO T T O

{A,I,M,O} {A,K,L,N,T}

Minimal Relaxation (discrete domain)

A A A AA K K AA L L AA N N AA T T AI A A II K K II L L II N N II T T I

M A A MM K K MM L L MM N N MM T T MO A A OO K K OO L L OO N N OO T T O

5 / 54

Page 15: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Domain Representation (discrete domains)

4 Letters Palindrome City ProblemI Con. 1: It is a cityI Con. 2: It is a palindromeI Domain: any 2 letters (676 sol.)

L1 L2 L2 L1

A K K AA N N AI L L I

M A A MO T T O

{A,I,M,O} {A,K,L,N,T}

Minimal Relaxation (discrete domain)

A A A AA K K AA L L AA N N AA T T AI A A II K K II L L II N N II T T I

M A A MM K K MM L L MM N N MM T T MO A A OO K K OO L L OO N N OO T T O

5 / 54

Page 16: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Domain Representation (discrete domains)

4 Letters Palindrome City ProblemI Con. 1: It is a cityI Con. 2: It is a palindromeI Domain: any 2 letters (676 sol.)

L1 L2 L2 L1

A K K AA N N AI L L I

M A A MO T T O

{A,I,M,O} {A,K,L,N,T}

Minimal Relaxation (discrete domain)

A A A AA K K AA L L AA N N AA T T AI A A II K K II L L II N N II T T I

M A A MM K K MM L L MM N N MM T T MO A A OO K K OO L L OO N N OO T T O

5 / 54

Page 17: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Domain Representation (discrete domains)

4 Letters Palindrome City ProblemI Con. 1: It is a cityI Con. 2: It is a palindromeI Domain: any 2 letters (676 sol.)

L1 L2 L2 L1

A K K AA N N AI L L I

M A A MO T T O

{A,I,M,O} {A,K,L,N,T}

Minimal Relaxation (discrete domain)

A A A AA K K AA L L AA N N AA T T AI A A II K K II L L II N N II T T I

M A A MM K K MM L L MM N N MM T T MO A A OO K K OO L L OO N N OO T T O

5 / 54

Page 18: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Domain Representation (bounds)

4 Letters Palindrome City ProblemI Con. 1: It is a cityI Con. 2: It is a palindromeI Domain: any 2 letters (676 sol.)

L1 L2 L2 L1

A K K AA N N AI L L I

M A A MO T T O

[A,. . . ,O] [A,. . . ,T]

Minimal Relaxation (discrete bounds)

A A A AA B B AA C C AA D D AA E E AA F F AA G G AA H H AA I I AA J J AA K K AA L L AA M M AA N N AA O O AA P P AA Q Q AA R R AA S S A. . . .

6 / 54

Page 19: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Given a constraint C and a domain representation D

I Compute the intersection C ∩ DI Find the minimal relaxation D ′ of C ∩ D

F Find all solutions of C ∩ D (support)F Project on the domain representation (filtering)

Consistency: a domain is consistent iff it is a minimal relaxationI Discrete domain: Arc Consistency (ac)I Bounds: Bounds Consistency (bc)I Also:

F Multi-valued Decision Diagram MDD Consistency [Hooker, Hadzic, vanHoeve 2007]

F Set variables [Puget 1992, Gervet 1997], Length-Lex representation[Gervet and Van Hentenryck 2006]

F Graph variables, Function variables, ...

7 / 54

Page 20: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Given a constraint C and a domain representation DI Compute the intersection C ∩ D

I Find the minimal relaxation D ′ of C ∩ DF Find all solutions of C ∩ D (support)F Project on the domain representation (filtering)

Consistency: a domain is consistent iff it is a minimal relaxationI Discrete domain: Arc Consistency (ac)I Bounds: Bounds Consistency (bc)I Also:

F Multi-valued Decision Diagram MDD Consistency [Hooker, Hadzic, vanHoeve 2007]

F Set variables [Puget 1992, Gervet 1997], Length-Lex representation[Gervet and Van Hentenryck 2006]

F Graph variables, Function variables, ...

7 / 54

Page 21: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Given a constraint C and a domain representation DI Compute the intersection C ∩ DI Find the minimal relaxation D ′ of C ∩ D

F Find all solutions of C ∩ D (support)F Project on the domain representation (filtering)

Consistency: a domain is consistent iff it is a minimal relaxationI Discrete domain: Arc Consistency (ac)I Bounds: Bounds Consistency (bc)I Also:

F Multi-valued Decision Diagram MDD Consistency [Hooker, Hadzic, vanHoeve 2007]

F Set variables [Puget 1992, Gervet 1997], Length-Lex representation[Gervet and Van Hentenryck 2006]

F Graph variables, Function variables, ...

7 / 54

Page 22: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Given a constraint C and a domain representation DI Compute the intersection C ∩ DI Find the minimal relaxation D ′ of C ∩ D

F Find all solutions of C ∩ D (support)F Project on the domain representation (filtering)

Consistency: a domain is consistent iff it is a minimal relaxation

I Discrete domain: Arc Consistency (ac)I Bounds: Bounds Consistency (bc)I Also:

F Multi-valued Decision Diagram MDD Consistency [Hooker, Hadzic, vanHoeve 2007]

F Set variables [Puget 1992, Gervet 1997], Length-Lex representation[Gervet and Van Hentenryck 2006]

F Graph variables, Function variables, ...

7 / 54

Page 23: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Given a constraint C and a domain representation DI Compute the intersection C ∩ DI Find the minimal relaxation D ′ of C ∩ D

F Find all solutions of C ∩ D (support)F Project on the domain representation (filtering)

Consistency: a domain is consistent iff it is a minimal relaxationI Discrete domain: Arc Consistency (ac)I Bounds: Bounds Consistency (bc)

I Also:F Multi-valued Decision Diagram MDD Consistency [Hooker, Hadzic, van

Hoeve 2007]F Set variables [Puget 1992, Gervet 1997], Length-Lex representation

[Gervet and Van Hentenryck 2006]F Graph variables, Function variables, ...

7 / 54

Page 24: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Given a constraint C and a domain representation DI Compute the intersection C ∩ DI Find the minimal relaxation D ′ of C ∩ D

F Find all solutions of C ∩ D (support)F Project on the domain representation (filtering)

Consistency: a domain is consistent iff it is a minimal relaxationI Discrete domain: Arc Consistency (ac)I Bounds: Bounds Consistency (bc)I Also:

F Multi-valued Decision Diagram MDD Consistency [Hooker, Hadzic, vanHoeve 2007]

F Set variables [Puget 1992, Gervet 1997], Length-Lex representation[Gervet and Van Hentenryck 2006]

F Graph variables, Function variables, ...

7 / 54

Page 25: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {1 2 6 7 8 9}x3 : {

9

8 9}x4 : {1 5 6 8 9}x5 : {1 2 6 7 8 9}x6 : {

9

4 5 8 9}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 26: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {1 2 6 7 8 9}x3 : {

9

8 9}x4 : {1 5 6 8 9}x5 : {1 2 6 7 8 9}x6 : {

9

4 5 8 9}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 27: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {1 2 6 7 8 9}x3 : {

9

8 9}x4 : {1 5 6 8 9}x5 : {1 2 6 7 8 9}x6 : {

9

4 5 8 9}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 28: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {1 2 6 7

8

8

9

}x3 : {

9

8 9}x4 : {1 5 6

8 9

}x5 : {1 2 6 7

8 9

}x6 : {

9

4 5

8 9

}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999 {8, 9}111111122222222222666666677777777777111111122222222222666666677777777777 {1, 2, 6, 7}999999999999999999999999999999999999888888888888888888888888888888888888 {8, 9}555666611115556666111155511115556666555666611115556666111155511115556666 {1, 5, 6}267227766771671177227712722661261122267227766771671177227712722661261122 {1, 2, 6, 7}444454545454444545454544445454444545444454545454444545454544445454444545 {4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 29: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {1 2 6 7

8

8

9

}x3 : {

9

8 9}x4 : {1 5 6

8 9

}x5 : {1 2 6 7

8 9

}x6 : {

9

4 5

8 9

}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 30: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {

1 2

6 7

8

8

9

}x3 : {

9

8 9}x4 : {

1

5 6

8 9

}x5 : {

1 2

6 7

8 9

}x6 : {

9

4 5

8 9

}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9 {8, 9}6 6 6 6 6 6 7 7 7 7 6 6 6 6 7 {6, 7}8 8 8 9 9 9 8 8 8 9 8 8 8 9 8 {8, 9}5 6 6 5 5 6 5 5 6 5 5 5 6 5 5 {5, 6}7 6 7 6 7 6 6 7 6 6 6 7 6 6 6 {6, 7}5 5 4 5 4 4 5 4 4 4 5 4 4 4 4 {4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 31: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {

1 2

6 7

8

8

9

}x3 : {

9

8 9}x4 : {

1

5 6

8 9

}x5 : {

1 2

6 7

8 9

}x6 : {

9

4 5

8 9

}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 32: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: Kakuro

23 30 27 12 16

17

12

7 7

11 10

3916

17

35

21

6

7

16

24

8

5

3

39

∑6i=1 xi = 39

AllDifferent({x1, . . . , x6})

x1 : {

9

8 9}x2 : {

1 2

6 7

8

8

9

}x3 : {

9

8 9}x4 : {

1

5

6 8 9

}x5 : {

1 2

6 7

8 9

}x6 : {

9

4

5 8 9

}

AllDifferent({x1, . . . , x6}) ∩ D888888888888888888888888888888888888999999999999999999999999999999999999

{8, 9}

111111122222222222666666677777777777111111122222222222666666677777777777

{1, 2, 6, 7}

999999999999999999999999999999999999888888888888888888888888888888888888

{8, 9}

555666611115556666111155511115556666555666611115556666111155511115556666

{1, 5, 6}

267227766771671177227712722661261122267227766771671177227712722661261122

{1, 2, 6, 7}

444454545454444545454544445454444545444454545454444545454544445454444545

{4, 5}

∑6i=1 xi = 39 ∩ D

8 8 8 8 8 8 8 8 8 8 9 9 9 9 9

{8, 9}

6 6 6 6 6 6 7 7 7 7 6 6 6 6 7

{6, 7}

8 8 8 9 9 9 8 8 8 9 8 8 8 9 8

{8, 9}

5 6 6 5 5 6 5 5 6 5 5 5 6 5 5

{5, 6}

7 6 7 6 7 6 6 7 6 6 6 7 6 6 6

{6, 7}

5 5 4 5 4 4 5 4 4 4 5 4 4 4 4

{4, 5}

AllDifferent({x1, . . . , x6}) ∩ D8 8 9 9 {8, 9}6 7 6 7 {6, 7}9 9 8 8 {8, 9}5 5 5 5 {5}7 6 7 6 {6, 7}4 4 4 4 {4}

8 / 54

Page 33: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Of course we do not want to enumerate solutions!

I Propagating is not necessarily harder than solvingF ac on AllDifferent in O(n1.5d), same as Matching

I In general:F Solving in O(K), then propagating in O(ndK)F Propagating in O(K), then solving in O(nK)

I In practice:F Same complexity class, but different algorithmsF Propagating is harder

9 / 54

Page 34: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Of course we do not want to enumerate solutions!I Propagating is not necessarily harder than solving

F ac on AllDifferent in O(n1.5d), same as Matching

I In general:F Solving in O(K), then propagating in O(ndK)F Propagating in O(K), then solving in O(nK)

I In practice:F Same complexity class, but different algorithmsF Propagating is harder

9 / 54

Page 35: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Of course we do not want to enumerate solutions!I Propagating is not necessarily harder than solving

F ac on AllDifferent in O(n1.5d), same as Matching

I In general:F Solving in O(K), then propagating in O(ndK)F Propagating in O(K), then solving in O(nK)

I In practice:F Same complexity class, but different algorithmsF Propagating is harder

9 / 54

Page 36: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Constraint Propagation

Of course we do not want to enumerate solutions!I Propagating is not necessarily harder than solving

F ac on AllDifferent in O(n1.5d), same as Matching

I In general:F Solving in O(K), then propagating in O(ndK)F Propagating in O(K), then solving in O(nK)

I In practice:F Same complexity class, but different algorithmsF Propagating is harder

9 / 54

Page 37: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

An Example of Propagator: the Switch Constraint

10 / 54

Page 38: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A set of n garments to embroidI Each garment require a subset of m available colors

A machine with k reels of thread

Replacing a reel costs time

What is the best sequence of garments?

11 / 54

Page 39: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A set of n garments to embroidI Each garment require a subset of m available colors

A machine with k reels of thread

Replacing a reel costs time

What is the best sequence of garments?

11 / 54

Page 40: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A set of n garments to embroidI Each garment require a subset of m available colors

A machine with k reels of thread

Replacing a reel costs time

What is the best sequence of garments?

11 / 54

Page 41: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 42: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 43: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 44: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 45: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 46: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 47: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 48: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 49: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 50: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Embroidery Scheduling

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

A B C D E F G

switch switch switch switch

switch switch switch switch switch

AB CDEF G

switch switch

switch switch

switch

A,B,C,D,E,F,G: 9 switches

B,F,A,E,D,C,G: 5 switches

12 / 54

Page 51: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

One Boolean variable per color j and position iI x ji = 1 iff the j-th color is on the buffer at time i

A variable M equal to the number of changes x ji < x ji+1

Not only useful for embroideryI Instruction scheduling (compilation)I Test sequencingI File transfer (observation satellites)

Switch turned up in 3/4 of the industrial projects I was involved in!

13 / 54

Page 52: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

One Boolean variable per color j and position iI x ji = 1 iff the j-th color is on the buffer at time i

A variable M equal to the number of changes x ji < x ji+1

Not only useful for embroideryI Instruction scheduling (compilation)I Test sequencingI File transfer (observation satellites)

Switch turned up in 3/4 of the industrial projects I was involved in!

13 / 54

Page 53: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

One Boolean variable per color j and position iI x ji = 1 iff the j-th color is on the buffer at time i

A variable M equal to the number of changes x ji < x ji+1

Not only useful for embroideryI Instruction scheduling (compilation)I Test sequencingI File transfer (observation satellites)

Switch turned up in 3/4 of the industrial projects I was involved in!

13 / 54

Page 54: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

One Boolean variable per color j and position iI x ji = 1 iff the j-th color is on the buffer at time i

A variable M equal to the number of changes x ji < x ji+1

Not only useful for embroideryI Instruction scheduling (compilation)I Test sequencingI File transfer (observation satellites)

Switch turned up in 3/4 of the industrial projects I was involved in!

13 / 54

Page 55: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

One Boolean variable per color j and position iI x ji = 1 iff the j-th color is on the buffer at time i

A variable M equal to the number of changes x ji < x ji+1

Not only useful for embroideryI Instruction scheduling (compilation)I Test sequencingI File transfer (observation satellites)

Switch turned up in 3/4 of the industrial projects I was involved in!

13 / 54

Page 56: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating the Switch Constraint

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

{B,F} {A} {B.F} {C ,D,E} {C ,D,E} {G} {C ,D,E}

?

?

?

? ?

? ?

?

?

How many switches at least? (compute a lower bound for M)

What are the possible colors (given the upper bound on M)

14 / 54

Page 57: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating the Switch Constraint

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

{B,F} {A} {B.F} {C ,D,E} {C ,D,E} {G} {C ,D,E}

?

?

?

? ?

? ?

?

?

How many switches at least? (compute a lower bound for M)

What are the possible colors (given the upper bound on M)

14 / 54

Page 58: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating the Switch Constraint

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

{B,F} {A} {B.F} {C ,D,E} {C ,D,E} {G} {C ,D,E}

?

?

?

? ?

? ?

?

?

How many switches at least? (compute a lower bound for M)

What are the possible colors (given the upper bound on M)

14 / 54

Page 59: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating the Switch Constraint

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

{B,F} {A} {B.F} {C ,D,E} {C ,D,E} {G} {C ,D,E}

?

?

?

? ?

? ?

?

?

How many switches at least? (compute a lower bound for M)

What are the possible colors (given the upper bound on M)

14 / 54

Page 60: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating the Switch Constraint

A B C D E F G

Reel 1

Reel 2

Reel 3

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

{B,F} {A} {B.F} {C ,D,E} {C ,D,E} {G} {C ,D,E}

?

?

?

? ?

? ?

?

?

How many switches at least? (compute a lower bound for M)

What are the possible colors (given the upper bound on M)

14 / 54

Page 61: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating the Switch Constraint

15 / 54

Page 62: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3capacity of the buffer

An edge for each color and each position

16 / 54

Page 63: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

capacity of the buffer

An edge for each color and each position

16 / 54

Page 64: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

capacity of the buffer

An edge for each color and each position

16 / 54

Page 65: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

capacity of the buffer

An edge for each color and each position

16 / 54

Page 66: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

capacity of the buffer

An edge for each color and each position

16 / 54

Page 67: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S

1-st 2-nd

c1

1

1

1

1

1

1

1

17 / 54

Page 68: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S

1-st 2-nd

c1

1

1

1

1

1

1

1

17 / 54

Page 69: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S

1-st 2-nd

c1

1

1

1

1

1

1

1

17 / 54

Page 70: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S

1-st 2-nd

c1

1

1

1

1

1

1

1

17 / 54

Page 71: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

c3 c5 c6

−11

OK OK

inc.

inc.

inc.

inc.

18 / 54

Page 72: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

c3 c5 c6

−11

OK OK

inc.

inc.

inc.

inc.

18 / 54

Page 73: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

c3 c5 c6

−11

OK OK

inc.

inc.

inc.

inc.

18 / 54

Page 74: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

c3 c5

c6

−11

OK OK

inc.

inc.

inc.

inc.

18 / 54

Page 75: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

c3 c5

c6

−11

OK OK

inc.

inc.

inc.

inc.

18 / 54

Page 76: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The Switch Constraint

S T

1-st 2-nd 3-rd 4-th 5-th 6-th 7-th

3

c3 c5

c6

−11

OK OK

inc.

inc.

inc.

inc.

18 / 54

Page 77: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagation Algorithm (details at CP-AI-OR)

Find a maximum flow of minimum cost: O(nd)

Eliminate negative costs of the residual graph: O((nd)1.5)

Find all cycles of costs 0 and 1 (but not 2 or greater): O(n2d)

Total time complexity: O(n2d + nd1.5)

experiments

19 / 54

Page 78: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagation Algorithm (details at CP-AI-OR)

Find a maximum flow of minimum cost: O(nd)

Eliminate negative costs of the residual graph: O((nd)1.5)

Find all cycles of costs 0 and 1 (but not 2 or greater): O(n2d)

Total time complexity: O(n2d + nd1.5)

experiments

19 / 54

Page 79: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagation Algorithm (details at CP-AI-OR)

Find a maximum flow of minimum cost: O(nd)

Eliminate negative costs of the residual graph: O((nd)1.5)

Find all cycles of costs 0 and 1 (but not 2 or greater): O(n2d)

Total time complexity: O(n2d + nd1.5)

experiments

19 / 54

Page 80: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagation Algorithm (details at CP-AI-OR)

Find a maximum flow of minimum cost: O(nd)

Eliminate negative costs of the residual graph: O((nd)1.5)

Find all cycles of costs 0 and 1 (but not 2 or greater): O(n2d)

Total time complexity: O(n2d + nd1.5)

experiments

19 / 54

Page 81: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagation Algorithm (details at CP-AI-OR)

Find a maximum flow of minimum cost: O(nd)

Eliminate negative costs of the residual graph: O((nd)1.5)

Find all cycles of costs 0 and 1 (but not 2 or greater): O(n2d)

Total time complexity: O(n2d + nd1.5)

experiments

19 / 54

Page 82: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Complexity of Propagating vs. Complexity of Solving

Propagating is often harderI E.g. Switch: solving in O(nd), propagating in O(n2d + nd1.5)

Sometimes, we can propagate “for free”, i.e., with the same timecomplexity as for solving

20 / 54

Page 83: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Complexity of Propagating vs. Complexity of Solving

Propagating is often harderI E.g. Switch: solving in O(nd), propagating in O(n2d + nd1.5)

Sometimes, we can propagate “for free”, i.e., with the same timecomplexity as for solving

20 / 54

Page 84: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Propagating for “Free”: the AtMostSeqCard Constraint

21 / 54

Page 85: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d) ∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 86: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d)

∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 87: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d) ∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 88: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d) ∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 89: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d) ∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 90: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d) ∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 91: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AtMostSeqCard Constraint

A sequence of variables [x1, . . . , xn]I xi = 1 iff the bolt is of the type that Charlot cares about

There is a given demand for bolts of this type

They should not occur alltogether (capacity constraints)I On each subsequence of size q, at most u are of this type

Example: u = 2, q = 4, d = 10, [x1, . . . , x22]

Definition: AtMostSeqCard(u, q, d , [x1, . . . , xn]) ⇐⇒

(n∑

i=1

xi = d) ∧n−q∧i=0

(

q∑l=1

xi+l ≤ u)

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

22 / 54

Page 92: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Solving the AtMostSeqCard Constraint

Finding a support (solving)

I We can be greedy and assign 1 whenever possible ⇒ leftmost

23 / 54

Page 93: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Solving the AtMostSeqCard Constraint

Finding a support (solving)I We can be greedy and assign 1 whenever possible ⇒ leftmost

23 / 54

Page 94: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1

−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 95: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ]

1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 96: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ]

1

0

0

1

1 0 0

0

1

0 1

0 0

1

1 0 0 1 1 0 0

1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 97: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ]

1

0

0

1

1 0 0

0

1

0 1 0 0 1

1 0 0 1 1 0 0

1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 98: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0

0

1

1 0 0

0

1

0 1 0 0 1

1 0 0 1 1 0 0

1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 99: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1

1 0 0

0

1

0 1 0 0 1

1 0 0 1 1 0 0

1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 100: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1

0 0

0

1

0 1 0 0 1

1 0 0 1 1 0 0

1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 101: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0

1

0 1 0 0 1

1 0 0 1 1 0 0

1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 102: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraints

I Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 103: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraintsI Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 104: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

Support: maximizing the cardinality while respecting capacitiesI Changing the value 1 to 0 has no impact on capacity constraintsI Greedily inserting 1 works

We can find a support in O(nq)

We can achieve ac in O(n2q)

24 / 54

Page 105: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Filtering the AtMostSeqCard Constraint

Can we propagate in the same time complexity?

I There is nothing to propagate unless |−→w | = dI Two runs of leftmost are enough

25 / 54

Page 106: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Filtering the AtMostSeqCard Constraint

Can we propagate in the same time complexity?I There is nothing to propagate unless |−→w | = d

I Two runs of leftmost are enough

25 / 54

Page 107: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Filtering the AtMostSeqCard Constraint

Can we propagate in the same time complexity?I There is nothing to propagate unless |−→w | = dI Two runs of leftmost are enough

25 / 54

Page 108: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 109: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1

←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 d

R[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 110: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 d

R[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 111: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 112: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 113: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 . 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 114: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 1 0 1 . . 1 . . . . . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 115: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 1 0 1 . . 1 . . . 1 . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 116: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 1 0 1 . . 1 . . . 1 . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 117: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Example: −→w = leftmost (u = 2, q = 4, d = 10)

D(xi ) . 0 . 1 . . . 0 1 0 1 . . 1 . . . 1 . . . 1−→w [i ] 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 0 0 1 1 0 0 1←−w [i ] 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 0 1 1 0 0 1 1

L[i ] 0 1 1 1 2 3 3 3 3 4 4 5 5 5 6 7 7 7 8 9 9 9 dR[i ] d d d 9 8 8 8 7 7 6 6 5 5 5 4 4 4 3 2 2 2 1 0

We can achieve ac in O(nq), that is, O(n2)

We can do better: leftmost can run in O(n) details

Total complexity of O(n), optimal!

26 / 54

Page 118: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

NP-hard Constraints

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

27 / 54

Page 119: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

NP-hard Constraints

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

27 / 54

Page 120: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

NP-hard Constraints: the SoftAllEqual Constraints

28 / 54

Page 121: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AllDifferent Constraint

Each variable should take a distinct value (Matching)I Propagation algorithm [Regin 1994, Costa 1994]

What about an “AllEqual” constraint?I Trivial to solve and propagateI However, the soft version is far from trivialI Try to make the variables as equal as possible

Two versionsI Maximise the number of equalitiesI Minimise the number of value skip

29 / 54

Page 122: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AllDifferent Constraint

Each variable should take a distinct value (Matching)I Propagation algorithm [Regin 1994, Costa 1994]

What about an “AllEqual” constraint?

I Trivial to solve and propagateI However, the soft version is far from trivialI Try to make the variables as equal as possible

Two versionsI Maximise the number of equalitiesI Minimise the number of value skip

29 / 54

Page 123: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AllDifferent Constraint

Each variable should take a distinct value (Matching)I Propagation algorithm [Regin 1994, Costa 1994]

What about an “AllEqual” constraint?I Trivial to solve and propagate

I However, the soft version is far from trivialI Try to make the variables as equal as possible

Two versionsI Maximise the number of equalitiesI Minimise the number of value skip

29 / 54

Page 124: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AllDifferent Constraint

Each variable should take a distinct value (Matching)I Propagation algorithm [Regin 1994, Costa 1994]

What about an “AllEqual” constraint?I Trivial to solve and propagateI However, the soft version is far from trivial

I Try to make the variables as equal as possible

Two versionsI Maximise the number of equalitiesI Minimise the number of value skip

29 / 54

Page 125: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AllDifferent Constraint

Each variable should take a distinct value (Matching)I Propagation algorithm [Regin 1994, Costa 1994]

What about an “AllEqual” constraint?I Trivial to solve and propagateI However, the soft version is far from trivialI Try to make the variables as equal as possible

Two versionsI Maximise the number of equalitiesI Minimise the number of value skip

29 / 54

Page 126: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The AllDifferent Constraint

Each variable should take a distinct value (Matching)I Propagation algorithm [Regin 1994, Costa 1994]

What about an “AllEqual” constraint?I Trivial to solve and propagateI However, the soft version is far from trivialI Try to make the variables as equal as possible

Two versionsI Maximise the number of equalitiesI Minimise the number of value skip

29 / 54

Page 127: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Definition: SoftAllEqual(k , [x1, . . . , xn]) ⇐⇒

At least k pairs of equal variables in the set {x1, . . . , xn}

Meeting SchedulingI Each researcher states his/her availabilitiesI Each researcher goes to at most one meetingI Schedule meetings so that:

F The number of interactions is maximumF Interaction: a pair of researchers attend the same meeting

30 / 54

Page 128: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Definition: SoftAllEqual(k , [x1, . . . , xn]) ⇐⇒

At least k pairs of equal variables in the set {x1, . . . , xn}

Meeting Scheduling

I Each researcher states his/her availabilitiesI Each researcher goes to at most one meetingI Schedule meetings so that:

F The number of interactions is maximumF Interaction: a pair of researchers attend the same meeting

30 / 54

Page 129: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Definition: SoftAllEqual(k , [x1, . . . , xn]) ⇐⇒

At least k pairs of equal variables in the set {x1, . . . , xn}

Meeting SchedulingI Each researcher states his/her availabilities

I Each researcher goes to at most one meetingI Schedule meetings so that:

F The number of interactions is maximumF Interaction: a pair of researchers attend the same meeting

30 / 54

Page 130: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Definition: SoftAllEqual(k , [x1, . . . , xn]) ⇐⇒

At least k pairs of equal variables in the set {x1, . . . , xn}

Meeting SchedulingI Each researcher states his/her availabilitiesI Each researcher goes to at most one meeting

I Schedule meetings so that:F The number of interactions is maximumF Interaction: a pair of researchers attend the same meeting

30 / 54

Page 131: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Definition: SoftAllEqual(k , [x1, . . . , xn]) ⇐⇒

At least k pairs of equal variables in the set {x1, . . . , xn}

Meeting SchedulingI Each researcher states his/her availabilitiesI Each researcher goes to at most one meetingI Schedule meetings so that:

F The number of interactions is maximum

F Interaction: a pair of researchers attend the same meeting

30 / 54

Page 132: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Definition: SoftAllEqual(k , [x1, . . . , xn]) ⇐⇒

At least k pairs of equal variables in the set {x1, . . . , xn}

Meeting SchedulingI Each researcher states his/her availabilitiesI Each researcher goes to at most one meetingI Schedule meetings so that:

F The number of interactions is maximumF Interaction: a pair of researchers attend the same meeting

30 / 54

Page 133: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Alice

Bob

Charlie

Dave

Eve

Frank

Guy

Hugo

Ian

Joe

Tue.am

Tue.pm

Wed.am

Wed.pm

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

Alice

Charlie

Frank

Guy

Ian

Bob

Dave

Eve

Hugo

Joe

Alice Hugo

Bob

Charlie

DaveJoe

EveIan

Guy

31 / 54

Page 134: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Alice

Bob

Charlie

Dave

Eve

Frank

Guy

Hugo

Ian

Joe

Tue.am

Tue.pm

Wed.am

Wed.pm

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

Alice

Charlie

Frank

Guy

Ian

Bob

Dave

Eve

Hugo

Joe

Alice Hugo

Bob

Charlie

DaveJoe

EveIan

Guy

31 / 54

Page 135: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Alice

Bob

Charlie

Dave

Eve

Frank

Guy

Hugo

Ian

Joe

Tue.am

Tue.pm

Wed.am

Wed.pm

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

X

Alice

Charlie

Frank

Guy

Ian

Bob

Dave

Eve

Hugo

Joe

Alice Hugo

Bob

Charlie

DaveJoe

EveIan

Guy

31 / 54

Page 136: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Finding an optimal solution is NP-hard (and so is Achieving ac)

Given an ordering (red, blue, green, ...), we can define a greedy algo:I Assign X to the first value whenever possible, then the second, etc.

If values are ordered by occurrences: 2-approximation

There exists such an ordering that gives an optimal solution

There is an algorithm exponential only in the number of values (V )

Exponential in something that is potentially smaller than the data ndI Fixed Parameter Tractable

32 / 54

Page 137: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Finding an optimal solution is NP-hard (and so is Achieving ac)

Given an ordering (red, blue, green, ...), we can define a greedy algo:I Assign X to the first value whenever possible, then the second, etc.

If values are ordered by occurrences: 2-approximation

There exists such an ordering that gives an optimal solution

There is an algorithm exponential only in the number of values (V )

Exponential in something that is potentially smaller than the data ndI Fixed Parameter Tractable

32 / 54

Page 138: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Finding an optimal solution is NP-hard (and so is Achieving ac)

Given an ordering (red, blue, green, ...), we can define a greedy algo:I Assign X to the first value whenever possible, then the second, etc.

If values are ordered by occurrences: 2-approximation

There exists such an ordering that gives an optimal solution

There is an algorithm exponential only in the number of values (V )

Exponential in something that is potentially smaller than the data ndI Fixed Parameter Tractable

32 / 54

Page 139: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Finding an optimal solution is NP-hard (and so is Achieving ac)

Given an ordering (red, blue, green, ...), we can define a greedy algo:I Assign X to the first value whenever possible, then the second, etc.

If values are ordered by occurrences: 2-approximation

There exists such an ordering that gives an optimal solution

There is an algorithm exponential only in the number of values (V )

Exponential in something that is potentially smaller than the data ndI Fixed Parameter Tractable

32 / 54

Page 140: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Finding an optimal solution is NP-hard (and so is Achieving ac)

Given an ordering (red, blue, green, ...), we can define a greedy algo:I Assign X to the first value whenever possible, then the second, etc.

If values are ordered by occurrences: 2-approximation

There exists such an ordering that gives an optimal solution

There is an algorithm exponential only in the number of values (V )

Exponential in something that is potentially smaller than the data ndI Fixed Parameter Tractable

32 / 54

Page 141: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Achieving ac is NP-hard

What about bc?

33 / 54

Page 142: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The SoftAllEqual Constraint

Achieving ac is NP-hard

What about bc?

33 / 54

Page 143: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A bc Algorithm for SoftAllEqual

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

If we assign the value 55 first, we assign it to all variables

The problem is split into two smaller parts

I Polynomial size search tree: Dynamic Programming

34 / 54

Page 144: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A bc Algorithm for SoftAllEqual

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

If we assign the value 55 first, we assign it to all variables

The problem is split into two smaller parts

I Polynomial size search tree: Dynamic Programming

34 / 54

Page 145: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A bc Algorithm for SoftAllEqual

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

If we assign the value 55 first, we assign it to all variables

The problem is split into two smaller parts

I Polynomial size search tree: Dynamic Programming

34 / 54

Page 146: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

A bc Algorithm for SoftAllEqual

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

If we assign the value 55 first, we assign it to all variables

The problem is split into two smaller partsI Polynomial size search tree: Dynamic Programming

34 / 54

Page 147: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

Ta,b = Maximum equalities on variables entirely contained in [a, b]

Given a value v ∈ [a, b], we must assign variables to v if possibleI Ta,b(v) = (Binomial coeff of) the number of variables hit by v +I table content on the splitted parts: Ta,v−1 + Tv+1,b

35 / 54

Page 148: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

Ta,b = Maximum equalities on variables entirely contained in [a, b]

Given a value v ∈ [a, b], we must assign variables to v if possibleI Ta,b(v) = (Binomial coeff of) the number of variables hit by v +

I table content on the splitted parts: Ta,v−1 + Tv+1,b

35 / 54

Page 149: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

20 60

60 90

0 40

50 80

10 40

0 90

20 60

50 80

0 90

55

Ta,b = Maximum equalities on variables entirely contained in [a, b]

Given a value v ∈ [a, b], we must assign variables to v if possibleI Ta,b(v) = (Binomial coeff of) the number of variables hit by v +I table content on the splitted parts: Ta,v−1 + Tv+1,b

35 / 54

Page 150: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

Time complexity: O(nV 3)I Table of size V 2, for each cell, go through the V values and count

occurrences (O(n))

Since we consider interval domains, V can be very large!

I We can count occurrences of all values in O(n + V )I Only maximal cliques matterI We can reformulate in an equivalent problem with as many values as

maximal cliquesI Interval graph, we can find all (O(n)) cliques in O(n log n) time

Algorithm in O(n3) to find a solution and O(n4) for bc

36 / 54

Page 151: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

Time complexity: O(nV 3)I Table of size V 2, for each cell, go through the V values and count

occurrences (O(n))

Since we consider interval domains, V can be very large!I We can count occurrences of all values in O(n + V )

I Only maximal cliques matterI We can reformulate in an equivalent problem with as many values as

maximal cliquesI Interval graph, we can find all (O(n)) cliques in O(n log n) time

Algorithm in O(n3) to find a solution and O(n4) for bc

36 / 54

Page 152: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

Time complexity: O(nV 3)I Table of size V 2, for each cell, go through the V values and count

occurrences (O(n))

Since we consider interval domains, V can be very large!I We can count occurrences of all values in O(n + V )I Only maximal cliques matter

I We can reformulate in an equivalent problem with as many values asmaximal cliques

I Interval graph, we can find all (O(n)) cliques in O(n log n) time

Algorithm in O(n3) to find a solution and O(n4) for bc

36 / 54

Page 153: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

Time complexity: O(nV 3)I Table of size V 2, for each cell, go through the V values and count

occurrences (O(n))

Since we consider interval domains, V can be very large!I We can count occurrences of all values in O(n + V )I Only maximal cliques matterI We can reformulate in an equivalent problem with as many values as

maximal cliquesI Interval graph, we can find all (O(n)) cliques in O(n log n) time

Algorithm in O(n3) to find a solution and O(n4) for bc

36 / 54

Page 154: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Dynamic Programming

Time complexity: O(nV 3)I Table of size V 2, for each cell, go through the V values and count

occurrences (O(n))

Since we consider interval domains, V can be very large!I We can count occurrences of all values in O(n + V )I Only maximal cliques matterI We can reformulate in an equivalent problem with as many values as

maximal cliquesI Interval graph, we can find all (O(n)) cliques in O(n log n) time

Algorithm in O(n3) to find a solution and O(n4) for bc

36 / 54

Page 155: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternativesI Achieve a weaker consistency (e.g., bc)I Approximate acI Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 156: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternativesI Achieve a weaker consistency (e.g., bc)I Approximate acI Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 157: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternatives

I Achieve a weaker consistency (e.g., bc)I Approximate acI Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 158: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternativesI Achieve a weaker consistency (e.g., bc)

I Approximate acI Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 159: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternativesI Achieve a weaker consistency (e.g., bc)I Approximate ac

I Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 160: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternativesI Achieve a weaker consistency (e.g., bc)I Approximate acI Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 161: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff

If solving is NP-hard, then achieving ac is NP-hard

Should we decompose into simpler constraints?

There are alternativesI Achieve a weaker consistency (e.g., bc)I Approximate acI Use an exponential algorithm (good case: Fixed Parameter Tractable)

The best tradeoff might not be obviousI Theoretical comparisonI Empirical comparison

37 / 54

Page 162: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff: The AtMostNValue Constraint

Definition: AtMostNValue([x1, . . . , xn],N) ⇐⇒

[x1, . . . , xn] assigned using at most N distinct values

NP-hard, equivalent to Minimum Hitting SetI Domains = collection of sets (D(xi ) = Si )I xi = an element in H ∩ SiI N = |H|

38 / 54

Page 163: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff: The AtMostNValue Constraint

Definition: AtMostNValue([x1, . . . , xn],N) ⇐⇒

[x1, . . . , xn] assigned using at most N distinct values

NP-hard, equivalent to Minimum Hitting Set

I Domains = collection of sets (D(xi ) = Si )I xi = an element in H ∩ SiI N = |H|

38 / 54

Page 164: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff: The AtMostNValue Constraint

Definition: AtMostNValue([x1, . . . , xn],N) ⇐⇒

[x1, . . . , xn] assigned using at most N distinct values

NP-hard, equivalent to Minimum Hitting Set

I Domains = collection of sets (D(xi ) = Si )I xi = an element in H ∩ SiI N = |H|

38 / 54

Page 165: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff: The AtMostNValue Constraint

Definition: AtMostNValue([x1, . . . , xn],N) ⇐⇒

[x1, . . . , xn] assigned using at most N distinct values

NP-hard, equivalent to Minimum Hitting SetI Domains = collection of sets (D(xi ) = Si )

I xi = an element in H ∩ SiI N = |H|

38 / 54

Page 166: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff: The AtMostNValue Constraint

Definition: AtMostNValue([x1, . . . , xn],N) ⇐⇒

[x1, . . . , xn] assigned using at most N distinct values

NP-hard, equivalent to Minimum Hitting SetI Domains = collection of sets (D(xi ) = Si )I xi = an element in H ∩ Si

I N = |H|

38 / 54

Page 167: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Assessing the Tradeoff: The AtMostNValue Constraint

Definition: AtMostNValue([x1, . . . , xn],N) ⇐⇒

[x1, . . . , xn] assigned using at most N distinct values

NP-hard, equivalent to Minimum Hitting SetI Domains = collection of sets (D(xi ) = Si )I xi = an element in H ∩ SiI N = |H|

38 / 54

Page 168: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set

1

2

3

4

5

6

7

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

{2, 3}

{3, 4}

{1, 4, 5, 7}

{5, 6}

{6, 7}

{2, 3, 7}

3

5

6

39 / 54

Page 169: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set

1

2

3

4

5

6

7

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

{2, 3}

{3, 4}

{1, 4, 5, 7}

{5, 6}

{6, 7}

{2, 3, 7}

3

5

6

39 / 54

Page 170: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set

1

2

3

4

5

6

7

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

{2, 3}

{3, 4}

{1, 4, 5, 7}

{5, 6}

{6, 7}

{2, 3, 7}

3

5

6

39 / 54

Page 171: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set

1

2

3

4

5

6

7

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

{2, 3}

{3, 4}

{1, 4, 5, 7}

{5, 6}

{6, 7}

{2, 3, 7}

3

5

6

39 / 54

Page 172: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set

1

2

3

4

5

6

7

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

{2, 3}

{3, 4}

{1, 4, 5, 7}

{5, 6}

{6, 7}

{2, 3, 7}

3

5

6

39 / 54

Page 173: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set, Clique Cover

Can we approximate Minimum Hitting Set to filterAtMostNValue?

I We need a lower bound; approximating MHS gives us an upper bound

I Another approach: Clique Cover of the Intersection Graph

40 / 54

Page 174: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set, Clique Cover

Can we approximate Minimum Hitting Set to filterAtMostNValue?

I We need a lower bound; approximating MHS gives us an upper bound

I Another approach: Clique Cover of the Intersection Graph

40 / 54

Page 175: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Hitting Set, Clique Cover

Can we approximate Minimum Hitting Set to filterAtMostNValue?

I We need a lower bound; approximating MHS gives us an upper boundI Another approach: Clique Cover of the Intersection Graph

40 / 54

Page 176: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

5

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 177: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3D(a) = {2, 3}D(b) = {3, 4}

4

5

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 178: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

D(b) = {3, 4}D(c) = {1, 4, 5, 7}

5

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 179: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

5

D(c) = {1, 4, 5, 7}D(d) = {5, 6}

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 180: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

5

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 181: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

5

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 182: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Discrete domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

5

77

6

7

2,3

3

A Minimum Clique Cover is a lower bound

However, finding a Minimum Clique Cover is NP-hard

41 / 54

Page 183: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Interval domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

4

5

77

6

7

2,3

3

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, . . . , 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, . . . , 7}

3

4

5, 6

6, 72, . . . , 7

6

6, 7

2, 3

3, 4

2, 3

5, 6

Finding a Minimum Clique Cover is polynomial (O(n log n))

A Minimum Clique Cover is an exact lower bound [Beldiceanu 2001]

42 / 54

Page 184: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Interval domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, . . . , 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, . . . , 7}

3

4

5, 6

6, 72, . . . , 7

6

6, 7

2, 3

3, 4

2, 3

5, 6

Finding a Minimum Clique Cover is polynomial (O(n log n))

A Minimum Clique Cover is an exact lower bound [Beldiceanu 2001]

42 / 54

Page 185: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Interval domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, . . . , 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, . . . , 7}

3

4

5, 6

6, 72, . . . , 7

6

6, 7

2, 3

3, 4

2, 3

5, 6

Finding a Minimum Clique Cover is polynomial (O(n log n))

A Minimum Clique Cover is an exact lower bound [Beldiceanu 2001]

42 / 54

Page 186: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Interval domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, . . . , 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, . . . , 7}

3

4

5, 6

6, 72, . . . , 7

6

6, 7

2, 3

3, 4

2, 3

5, 6

Finding a Minimum Clique Cover is polynomial (O(n log n))

A Minimum Clique Cover is an exact lower bound [Beldiceanu 2001]

42 / 54

Page 187: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Intersection Graph: Interval domains

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, . . . , 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, . . . , 7}

3

4

5, 6

6, 72, . . . , 7

6

6, 7

2, 3

3, 4

2, 3

5, 6

Finding a Minimum Clique Cover is polynomial (O(n log n))

A Minimum Clique Cover is an exact lower bound [Beldiceanu 2001]

42 / 54

Page 188: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Independent Set

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

2,3

4

7

7

3

5

7

6

a

b

f

c

d

e

Find an Independent Set

Independance Number of G ≤ Intersection Number of θ(G )

43 / 54

Page 189: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Independent Set

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

3

2,3

4

7

7

3

5

7

6

a

b

f

c

d

e

Find an Independent Set

Independance Number of G ≤ Intersection Number of θ(G )

43 / 54

Page 190: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Independent Set

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

5

7

6

a

b

f

c

d

e

Find an Independent Set

Independance Number of G ≤ Intersection Number of θ(G )

43 / 54

Page 191: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Independent Set

a

b c

d

ef

D(a) = {2, 3}D(b) = {3, 4}D(c) = {1, 4, 5, 7}D(d) = {5, 6}D(e) = {6, 7}D(f ) = {2, 3, 7}

a

b

f

c

d

e

Find an Independent Set

Independance Number of G ≤ Intersection Number of θ(G )

43 / 54

Page 192: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Turan’s Lower Bound

There are even simpler lower boundsI [Turan 1941]

I [Favaron et al. 1993]

α(G ) ≤⌈

n2

2m + n

2n − 2m

d 2mn e⌈

2mn

⌉+ 1

44 / 54

Page 193: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Turan’s Lower Bound

There are even simpler lower boundsI [Turan 1941]I [Favaron et al. 1993]

α(G ) ≤⌈

n2

2m + n

⌉≤

2n − 2m

d 2mn e⌈

2mn

⌉+ 1

44 / 54

Page 194: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear Program

minimize∑v∈D

yv

subject to∑v∈xi

yv ≥ 1, xi ∈ X

yv ≥ 0 , v ∈ D

number of values

each variable takes a value

An integral solution is a Hitting Set

The linear relaxation gives a lower bound

45 / 54

Page 195: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear Program

minimize∑v∈D

yv

subject to∑v∈xi

yv ≥ 1, xi ∈ X

yv ≥ 0 , v ∈ D

number of values

each variable takes a value

An integral solution is a Hitting Set

The linear relaxation gives a lower bound

45 / 54

Page 196: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear Program

minimize∑v∈D

yv

subject to∑v∈xi

yv ≥ 1, xi ∈ X

yv ≥ 0 , v ∈ D

number of values

each variable takes a value

An integral solution is a Hitting Set

The linear relaxation gives a lower bound

45 / 54

Page 197: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?

I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain DI φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 198: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain DI φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 199: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain D

I φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 200: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain DI φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 201: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain DI φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 202: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain DI φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 203: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: Theory

Which solution is best?I Better time complexity vs. better propagation

Comparing propagation φ against ψ, constraint C domain DI φ(C ,D) the domain representation / set of solutions after applying φI ψ(C ,D) the domain representation / set of solutions after applying ψ

φ is as strong as ψ is φ(C ,D) ⊆ ψ(C ,D)

Turan

MD

bc

LP ac6=

6=

Turan amortisedbc O(n log n)MD O(n2d)LP O(nd4)ac NP-hard

experiments

46 / 54

Page 204: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Conclusion

When solving a problem: find the algorithm with best complexity

I Here we also want to achieve the highest possible consistencyF ac? bc? Mdd-C? (SAC, MaxRPC, ...)F Even something undefined

When achieving a given consistency is NP-hardI Consider a lower consistencyI Consider approximationsI Consider parameterized complexity

Other related questions:I Is it decomposable?I What consistency/decomposition is the strongest?

Experimental tradeoff!

47 / 54

Page 205: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Conclusion

When solving a problem: find the algorithm with best complexityI Here we also want to achieve the highest possible consistency

F ac? bc? Mdd-C? (SAC, MaxRPC, ...)

F Even something undefined

When achieving a given consistency is NP-hardI Consider a lower consistencyI Consider approximationsI Consider parameterized complexity

Other related questions:I Is it decomposable?I What consistency/decomposition is the strongest?

Experimental tradeoff!

47 / 54

Page 206: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Conclusion

When solving a problem: find the algorithm with best complexityI Here we also want to achieve the highest possible consistency

F ac? bc? Mdd-C? (SAC, MaxRPC, ...)F Even something undefined

When achieving a given consistency is NP-hardI Consider a lower consistencyI Consider approximationsI Consider parameterized complexity

Other related questions:I Is it decomposable?I What consistency/decomposition is the strongest?

Experimental tradeoff!

47 / 54

Page 207: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Conclusion

When solving a problem: find the algorithm with best complexityI Here we also want to achieve the highest possible consistency

F ac? bc? Mdd-C? (SAC, MaxRPC, ...)F Even something undefined

When achieving a given consistency is NP-hardI Consider a lower consistencyI Consider approximationsI Consider parameterized complexity

Other related questions:I Is it decomposable?I What consistency/decomposition is the strongest?

Experimental tradeoff!

47 / 54

Page 208: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

The End

Questions?

48 / 54

Page 209: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental Evaluation (120 garments, 3 machines, 7 colors)

120

140

160

180

200

220

0 10000 20000 30000 40000 50000 60000

objective (#switches)

cpu time (ms)

Decomposition (Impact)Decomposition (Wdeg)

Propagator (Impact)Propagator (Wdeg)

back

49 / 54

Page 210: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental results

[label=expeamsc]

Table: Car-sequencing

ModelsG1 (70× 34× 5) G2 (4× 34× 5) G3 (5× 34× 5) G4 (7× 34× 5)

11900 680 850 1190#sol time #sol time #sol time #sol time

sum 8480 13.93 95 76.60 0 > 1200 64 43.81gsc 11218 3.60 325 110.99 31 276.06 140 56.61

amsc 10702 4.43 360 72.00 16 8.62 153 33.56amsc+gsc 11243 3.43 339 106.53 32 285.43 147 66.45

Sum: simple decomposition

GSC (Global Sequencing Constraint)I same as AtMostSeqCard for an option + demand for each type of

car requiring this optionI NP-hard, approximation

50 / 54

Page 211: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental results

[label=expeamsc]

Table: Car-sequencing

ModelsG1 (70× 34× 5) G2 (4× 34× 5) G3 (5× 34× 5) G4 (7× 34× 5)

11900 680 850 1190#sol time #sol time #sol time #sol time

sum 8480 13.93 95 76.60 0 > 1200 64 43.81gsc 11218 3.60 325 110.99 31 276.06 140 56.61

amsc 10702 4.43 360 72.00 16 8.62 153 33.56amsc+gsc 11243 3.43 339 106.53 32 285.43 147 66.45

Sum: simple decomposition

GSC (Global Sequencing Constraint)I same as AtMostSeqCard for an option + demand for each type of

car requiring this optionI NP-hard, approximation

50 / 54

Page 212: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental results

[label=expeamsc]

Table: Car-sequencing

ModelsG1 (70× 34× 5) G2 (4× 34× 5) G3 (5× 34× 5) G4 (7× 34× 5)

11900 680 850 1190#sol time #sol time #sol time #sol time

sum 8480 13.93 95 76.60 0 > 1200 64 43.81gsc 11218 3.60 325 110.99 31 276.06 140 56.61

amsc 10702 4.43 360 72.00 16 8.62 153 33.56amsc+gsc 11243 3.43 339 106.53 32 285.43 147 66.45

Sum: simple decomposition

GSC (Global Sequencing Constraint)

I same as AtMostSeqCard for an option + demand for each type ofcar requiring this option

I NP-hard, approximation

50 / 54

Page 213: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental results

[label=expeamsc]

Table: Car-sequencing

ModelsG1 (70× 34× 5) G2 (4× 34× 5) G3 (5× 34× 5) G4 (7× 34× 5)

11900 680 850 1190#sol time #sol time #sol time #sol time

sum 8480 13.93 95 76.60 0 > 1200 64 43.81gsc 11218 3.60 325 110.99 31 276.06 140 56.61

amsc 10702 4.43 360 72.00 16 8.62 153 33.56amsc+gsc 11243 3.43 339 106.53 32 285.43 147 66.45

Sum: simple decomposition

GSC (Global Sequencing Constraint)I same as AtMostSeqCard for an option + demand for each type of

car requiring this optionI NP-hard, approximation

50 / 54

Page 214: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental results

Table: Crew-Rostering

Heuristic Lexicographic

Modelsatifisable (1140) unsatisfiable (385)

#sol time avg bts #sol time avg btssum 0 - - 170 0.05 86gsc 25 308.93 74074 175 2.56 262

amsc 125 164.36 1828347 213 1.76 22621mamsc 534 87.29 685720 271 2.80 27150

MultiAtMostSeqCard: several capacity constraints together

back

51 / 54

Page 215: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Experimental results

Table: Crew-Rostering

Heuristic Lexicographic

Modelsatifisable (1140) unsatisfiable (385)

#sol time avg bts #sol time avg btssum 0 - - 170 0.05 86gsc 25 308.93 74074 175 2.56 262

amsc 125 164.36 1828347 213 1.76 22621mamsc 534 87.29 685720 271 2.80 27150

MultiAtMostSeqCard: several capacity constraints together

back

51 / 54

Page 216: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 . 0 . 0 1 . . 1 . . . . . . . 1

card(8, 0) = 4−2 = 2

card(8, 1) = 4−3 = 1

card(8, 2) = 4−3 = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 217: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 . 0 . 0 1 . . 1 . . . . . . . 1

card(8, 0) = 4−2 = 2

card(8, 1) = 4−3 = 1

card(8, 2) = 4−3 = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 218: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(7, 0) = 2

card(8, 0) = 4−2 = 2

card(7, 1) = 1

card(8, 1) = 4−3 = 1

card(7, 2) = 0

card(8, 2) = 4−3 = 1

card(7, 3) = 0

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 219: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(7, 0) = 2

card(8, 0) = 4−2 = 2

card(7, 1) = 1

card(8, 1) = 4−3 = 1

card(7, 2) = 0

card(8, 2) = 4−3 = 1

card(7, 3) = 0

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 220: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(8, 0) = 1

card(8, 0) = 4−2 = 2

card(8, 1) = 0

card(8, 1) = 4−3 = 1

card(8, 2) = 0

card(8, 2) = 4−3 = 1

card(8, 3) = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 221: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(7, 0) = 2

card(8, 0) = 4−2 = 2

card(7, 1) = 1

card(8, 1) = 4−3 = 1

card(7, 2) = 0

card(8, 2) = 4−3 = 1

card(7, 3) = 0

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 222: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(7, 0) = 3−1 = 2

card(8, 0) = 4−2 = 2

card(7, 1) = 3−2 = 1

card(8, 1) = 4−3 = 1

card(7, 2) = 3−3 = 0

card(8, 2) = 4−3 = 1

card(7, 3) = 3−3 = 0

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 223: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(8, 0) = 3−2 = 1

card(8, 0) = 4−2 = 2

card(8, 1) = 3−3 = 0

card(8, 1) = 4−3 = 1

card(8, 2) = 3−3 = 0

card(8, 2) = 4−3 = 1

card(8, 3) = 3−2 = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 224: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 . 0 1 . . 1 . . . . . . . 1

card(8, 0) = 3−2 = 1

card(8, 0) = 4−2 = 2

card(8, 1) = 3−3 = 0

card(8, 1) = 4−3 = 1

card(8, 2) = 3−3 = 0

card(8, 2) = 4−3 = 1

card(8, 3) = 3−2 = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 225: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 1 0 1 . . 1 . . . . . . . 1

card(8, 0) = 3−2 = 1

card(8, 0) = 4−2 = 2

card(8, 1) = 3−3 = 0

card(8, 1) = 4−3 = 1

card(8, 2) = 3−3 = 0

card(8, 2) = 4−3 = 1

card(8, 3) = 3−2 = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 226: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I access the cardinality of the jth subsequence containing xi : card(i , j)

F jump from xi to xi+1

F increment all subsequences containing xi

1 0 0 1 1 0 0 0 1 0 1 . . 1 . . . . . . . 1

card(8, 0) = 4−2 = 2

card(8, 1) = 4−3 = 1

card(8, 2) = 4−3 = 1

card(8, 3) = 4−2 = 2

card(i , j)=∑i

k=1 +c[i + j mod q]

back

52 / 54

Page 227: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I check whether there exists a subsequence of cardinality u: #sub(i , k)

F jump from xi to xi+1

→ OK using card(i , 0) and card(i + 1, 4)

F increment all subsequences containing xi

→ decrement pointer

0 0 0 0 0 0 3 1 2 0

back

53 / 54

Page 228: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I check whether there exists a subsequence of cardinality u: #sub(i , k)

F jump from xi to xi+1

→ OK using card(i , 0) and card(i + 1, 4)

F increment all subsequences containing xi

→ decrement pointer

0 0 0 0 0 0 3 1 2 0

0 1 2 3

back

53 / 54

Page 229: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I check whether there exists a subsequence of cardinality u: #sub(i , k)

F jump from xi to xi+1 → OK using card(i , 0) and card(i + 1, 4)F increment all subsequences containing xi

→ decrement pointer

0 0 0 0 0 0 3 1 2 0

0 1 2 3

back

53 / 54

Page 230: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I check whether there exists a subsequence of cardinality u: #sub(i , k)

F jump from xi to xi+1 → OK using card(i , 0) and card(i + 1, 4)F increment all subsequences containing xi → decrement pointer

0 0 0 0 0 0 3 1 2 0

0 1 2 3

back

53 / 54

Page 231: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Linear time algorithm

We need to do each of the following in O(1):I check whether there exists a subsequence of cardinality u: #sub(i , k)

F jump from xi to xi+1 → OK using card(i , 0) and card(i + 1, 4)F increment all subsequences containing xi → decrement pointer

0 0 0 0 0 0 3 1 2 0

0 1 2 3

back

53 / 54

Page 232: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: In Practice

Random instances

Dominating set of the Queens Graph of order nI One vertex per square of the chessboard (n2)I An edge iff if the two squares are attacked (same row, column or

diagonal)

minimum number of Queens to attack the whole chessboard

problemTuran bc MD LP

time bkt time bkt time bkt time bkt

Random

7.2 90786 6.9 72773 2.5 18885 15.8 17866

n = 50, d = 15

Queens

- - - - 203 880669 16 2243

(9× 9)

54 / 54

Page 233: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: In Practice

Random instances

Dominating set of the Queens Graph of order nI One vertex per square of the chessboard (n2)I An edge iff if the two squares are attacked (same row, column or

diagonal)

minimum number of Queens to attack the whole chessboard

problemTuran bc MD LP

time bkt time bkt time bkt time bkt

Random

7.2 90786 6.9 72773 2.5 18885 15.8 17866

n = 50, d = 15

Queens

- - - - 203 880669 16 2243

(9× 9)

54 / 54

Page 234: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: In Practice

Random instances

Dominating set of the Queens Graph of order nI One vertex per square of the chessboard (n2)I An edge iff if the two squares are attacked (same row, column or

diagonal)

minimum number of Queens to attack the whole chessboard

problemTuran bc MD LP

time bkt time bkt time bkt time bkt

Random7.2 90786 6.9 72773 2.5 18885 15.8 17866

n = 50, d = 15

Queens

- - - - 203 880669 16 2243

(9× 9)

54 / 54

Page 235: The Thousand Faces of Constraint Propagation · Outline 1 Propagation and Constraint Programming 2 An Example of Propagator The Switch constraint 3 Complexity of Propagating vs. Complexity

Tradeoff: In Practice

Random instances

Dominating set of the Queens Graph of order nI One vertex per square of the chessboard (n2)I An edge iff if the two squares are attacked (same row, column or

diagonal)

minimum number of Queens to attack the whole chessboard

problemTuran bc MD LP

time bkt time bkt time bkt time bkt

Random7.2 90786 6.9 72773 2.5 18885 15.8 17866

n = 50, d = 15

Queens- - - - 203 880669 16 2243

(9× 9)

54 / 54