Download presentation

Presentation is loading. Please wait.

Published byFrank Brooks Modified over 2 years ago

1
**The Theory and Practice of Constraint Programming: An Overview**

Brahim Hnich Faculty of Computer Science Izmir University of Economics Izmir, Turkey

2
Quotation “Constraint programming represents one of the closest approaches computer science has yet made to the Holy Grail of programming: the user states the problem, the computer solves it.” Eugene C. Freuder, Constraints, April 1997 10/04/2017 A CP Tutorial: Hnich

3
**Caveat In this talk: Constraint programming for combinatorial problems**

“Programming” refers to its roots in computer science (programming languages) 10/04/2017 A CP Tutorial: Hnich

4
**Outline Modelling Constraint propagation Search**

Demo: Lot-sizing with stochastic non-stationary demand 10/04/2017 A CP Tutorial: Hnich

5
**A Puzzle Place the numbers 1 through 8 in the nodes such that: ?**

Each number appears exactly once No connected nodes have consecutive numbers ? 10/04/2017 A CP Tutorial: Hnich

6
**Modeling Each node a decision variable**

{1, …, 8} values in the domain of each variable No consecutive numbers a constraint (vi, vj) |vi – vj| > 1 All values used a clique of not-equals constraints forall i<j. vi ≠ vj, 10/04/2017 A CP Tutorial: Hnich

7
**Modeling Each node a decision variable**

{1, …, 8} values in the domain of each variable No consecutive numbers a constraint (vi, vj) |vi – vj| > 1 All values used forall i<j. vi ≠ vj, Or more compactly, all-different[v1,…,v8] 10/04/2017 A CP Tutorial: Hnich

8
Heuristic Search {1, 2, 3, 4, 5, 6, 7, 8} ? 1 8 10/04/2017 A CP Tutorial: Hnich

9
**Inference/Propagation**

{1, 2, 3, 4, 5, 6, 7, 8} ? 1 8 {1, 2, 3, 4, 5, 6, 7, 8} 10/04/2017 A CP Tutorial: Hnich

10
**Inference/Propagation**

{3, 4, 5, 6} {3, 4, 5, 6} ? 3 6 {3, 4, 5, 6, 7} {2, 3, 4, 5, 6} 7 1 8 2 4 5 {3, 4, 5, 6} {3, 4, 5, 6} 10/04/2017 A CP Tutorial: Hnich

11
**An OPL Model int N=8; struct edge{int x; int y;};**

{edge} Edges ={<1,2>, <1,3>,…,<7,8>}; range Nodes 1..N; range Values 1..N; var int Solution[Nodes] in Values; solve{ forall(e in Edges) abs(Solution[e.x] - Solution[e.y]) >1; alldifferent(Solution); }; 10/04/2017 A CP Tutorial: Hnich

12
**The Core of Constraint Computation**

Modelling Solving Heuristic Search Propagation 10/04/2017 A CP Tutorial: Hnich

13
ANY QUESTIONS?

14
Modeling

15
**Finite-domain Variables**

To each variable x is associated a set of values called its domain e.g x Є {1,3,11} Each variable must take a value from its domain That domain is updated as decisions are made A domain may only shrink (no value is ever added) 10/04/2017 A CP Tutorial: Hnich

16
**Constraint Satisfaction Problems**

CSP: (X, D, C) X = {x1, x2,…, xn} variables D = {d1, d2,…,dn} domains (finite) C = {c1,c2,…,ce } constraints c ЄC var(c) = {xi, xj,…, xk} scope rel(c) ⊆ di x dj x .. x dk permitted tuples Solution: assignment satisfying every constraint NP-complete task 10/04/2017 A CP Tutorial: Hnich

17
**CSP: Relevance Many problems can be represented as CSP:**

Real-life applications Production planning Staff scheduling Resource allocation Circuit design Option trading DNA sequencing ... Artificial Intelligence temporal reasoning Control Theory controllers for sensory based robots Concurency process comm. and synchr. Computer Graphics geometric coherence Database Systems constraint databases Bioinformatics sequence alignment Operations research optimization 10/04/2017 A CP Tutorial: Hnich

18
**Constraint Programming**

CP: provides a platform for solving CSPs proven useful in many real applications Platform: set of common structures to reuse best known algorithms for propagation & solving Two stages: modelling solving 10/04/2017 A CP Tutorial: Hnich

19
**Language of Constraints**

The usual relational operators (<, =, >, ≤, …) … including ≠ Linear and nonlinear constraints Logical connectives (→, ↔, ┐, …) Set constraints (subset, union, intersection,…) “Global constraints”: constraints capturing a common substructure (pattern) of combinatorial problems 10/04/2017 A CP Tutorial: Hnich

20
**Map Colouring Variables: F, N, S Values: { }**

Constraints: N ≠ S ≠ F ≠ N N S F A solution: F N S 10/04/2017 A CP Tutorial: Hnich

21
Word Design Problem This problem has its roots in Bioinformatics and Coding Theory. Problem: find as large a set S of strings (words) of length 8 over the alphabet W = { A,C,G,T } with the following properties: Each word in S has 4 symbols from { C,G }; 10/04/2017 A CP Tutorial: Hnich

22
Word Design Problem Problem: find as large a set S of strings (words) of length 8 over the alphabet W = { A,C,G,T } with the following properties: Each word in S has 4 symbols from { C,G }; Each pair of distinct words in S differ in at least 4 positions; and 10/04/2017 A CP Tutorial: Hnich

23
**Word Design Problem Each word in S has 4 symbols from { C,G };**

Problem: find as large a set S of strings (words) of length 8 over the alphabet W = { A,C,G,T } with the following properties: Each word in S has 4 symbols from { C,G }; Each pair of distinct words in S differ in at least 4 positions; and Each pair of words x and y in S (where x and y may be identical) are such that xR and yC differ in at least 4 positions. (x1,…,x8)R = ( x8,…,x1 ) is the reverse of ( x1,…,x8 ) (y1,…,y8)C is the Watson-Crick complement of ( y1,…,y8 ), i.e. the word where each A is replaced by a T and vice versa and each C is replaced by a G and vice versa. 10/04/2017 A CP Tutorial: Hnich

24
**A Solution S= { AAGCCGTT, TACGCGAT}**

Each word in S has 4 symbols from { C,G }; 10/04/2017 A CP Tutorial: Hnich

25
**A Solution S= { AAGCCGTT, TACGCGAT}**

Each pair of distinct words in S differ in at least 4 positions 10/04/2017 A CP Tutorial: Hnich

26
**A Solution S= { AAGCCGTT, TACGCGAT} SR= { TTGCCGAA, TAGCGCAT}**

SC= { TTCGGCAA, ATGCGCTA} Each pair of words x and y in S (where x and y may be identical) are such that xR and yC differ in at least 4 positions 10/04/2017 A CP Tutorial: Hnich

27
**A Matrix Model M 1 2 3 4 5 6 7 8 … m Each row represents a word in S**

{ A,C,G,T } … m Each row represents a word in S M[i,j]: a decision variable with domain { A,C,G,T } 10/04/2017 A CP Tutorial: Hnich

28
A Matrix Model Expressing that each word in S has 4 symbols from { C,G } M 1 2 3 4 5 6 7 8 { A,C,G,T } … m 10/04/2017 A CP Tutorial: Hnich

29
**A Matrix Model M 1 2 3 4 5 6 7 8 … m For each row r**

{ A,C,G,T } … m For each row r sum (p in 1..8) //channelling constraints (M[r,p]=C or M[r,p]=G) = 4 10/04/2017 A CP Tutorial: Hnich

30
A Matrix Model … Each pair of distinct words in S differ in at least 4 positions M 1 2 3 4 5 6 7 8 { A,C,G,T } … m For each distinct rows r1 and r2 sum(p in 1..8) (M[r1,p] ≠ M[r2,p]) >= 4 10/04/2017 A CP Tutorial: Hnich

31
A Matrix Model … xR and yC differ in at least 4 positions. MC 1 2 3 4 5 6 7 8 { A,C,G,T } … m Introduce a “compliment matrix” Each pair //channelling constraints <M[i,j], MC[i,j]> in {<C,G>, <G,C>, <A,T>, <T,A>} 10/04/2017 A CP Tutorial: Hnich

32
A Matrix Model … xR and yC differ in at least 4 positions. MC 1 2 3 4 5 6 7 8 { A,C,G,T } … m For each rows r1 and r2 sum(p in 1..8) (M[r1,9-p] ≠ MC[r2,p]) >= 4 10/04/2017 A CP Tutorial: Hnich

33
ANY QUESTIONS?

34
**Constraint Propagation**

35
**Constraint Propagation**

General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion 10/04/2017 A CP Tutorial: Hnich

36
General Principle Each type of constraint relies on its own specific filtering algorithm to filter out (locally) inconsistent variable assignment The communication between the different filtering algorithms takes place through the domains of the variables It makes it easy to have different types of constraints work together 10/04/2017 A CP Tutorial: Hnich

37
General Principle {1, 2, 3, 4, 5, 6, 7, 8} Constraint network ? ≠ ≠ ≠ ≠ ≠ ≠ ≠ 1 8 ≠ ≠ ≠ ≠ ≠ ≠ ≠ {1, 2, 3, 4, 5, 6, 7, 8} ≠ ≠ ≠ 10/04/2017 A CP Tutorial: Hnich

38
**General Principle This propagation necessarily terminates**

The results is the same regardless of the order in which we consider the constraints 10/04/2017 A CP Tutorial: Hnich

39
**Triggering the constraints**

A constraint is woken up by one of its variables. domain event: anytime the domain changes (i.e. some value has been removed) range event: only when the minimum or maximum value in the domain has changed (e.g. for x ≤ y constraint) value event: only when the domain is reduced to a single value (e.g. for x≠y constraint) 10/04/2017 A CP Tutorial: Hnich

40
**Constraint Propagation**

General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion 10/04/2017 A CP Tutorial: Hnich

41
**Consistency We reason locally about a constraint, removing**

inconsistent values from domains We can often characterize the level of consistency achieved by a filtering algorithm 10/04/2017 A CP Tutorial: Hnich

42
**Generalized Arc Consistency**

Given a constraint C on the variables X A support for Xi = vj on C is a partial assignment containing Xi = vj that satisfies C. A variable Xi is generalized arc consistent (GAC) on C iff every value in D(Xi) has support on C. C is GAC iff each constrained variable is GAC on C. 10/04/2017 A CP Tutorial: Hnich

43
**Bounds Consistency Given a constraint C on the variables X**

A bound support on C is a support where the interval [min(Xi); max(Xi)] is substituted for the domain of each constrained variable Xi. A variable Xi is bound consistent (BC) on C if min(Xi) and max(Xi) have bound support on C. C is BC iff all constrained variables are BC on C. 10/04/2017 A CP Tutorial: Hnich

44
**Consistency: BC example**

Consider 4x + 3y - 2z = 10 with Dx = Dy = Dz = {0, 1, , 9} Maintaining BC reduces domains to Dx = {0, 1, , 7}, Dy = Dz = {0, 1, , 9} BC is triggered on range event 10/04/2017 A CP Tutorial: Hnich

45
**Consistency: GAC example**

Consider 4x + 3y - 2z = 10 with Dx = Dy = Dz = {0, 1, , 9} Maintaining GAC reduces domains to Dx = {0, 1, , 7}, Dy = {0, 2, 4, 6, 8}, Dz = {0, 1, , 9} GAC is triggered on domain event 10/04/2017 A CP Tutorial: Hnich

46
**Constraint Propagation**

General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion 10/04/2017 A CP Tutorial: Hnich

47
**Disequalities: Filtering Algorithm**

Consider x≠y with Dx = Dy = {0, 1, , 9} Only once one of the variables is fixed may we remove any value from the domain of the other: Dx = {3} → Dy = {0, , 2, 4, , 9} achieves GAC triggered on value event 10/04/2017 A CP Tutorial: Hnich

48
**Inequalities: Filtering Algorithm**

Consider x<y with Dx = Dy = {0, 1, 2, 3} Only once one of the variables’ bound is changed may we remove any value from the domain of the other: Dx = {0, 1, 2} Dy = {1, 2, 3} achieves BC (which is equivalent to GAC because of monotonicity) triggered on range event 10/04/2017 A CP Tutorial: Hnich

49
**Constraint Propagation**

General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion 10/04/2017 A CP Tutorial: Hnich

50
**Example: all-different**

Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠ 3 binary constraints, they are GAC, no pruning 10/04/2017 A CP Tutorial: Hnich

51
**Example: all-different**

Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠ Using binary disequalities, this inconsistency goes undetected 3 binary constraints, they are GAC, no pruning 10/04/2017 A CP Tutorial: Hnich

52
**Example: all-different**

Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠ We can do something simple: Count the number of variables, n Count the number of values in the union of their domains, m If n > m then no solution can possibly be found 3 binary constraints, they are GAC, no pruning 10/04/2017 A CP Tutorial: Hnich

53
**Example: all-different**

Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠ We can do something simple: Count the number of variables, n Count the number of values in the union of their domains, m If n > m then no solution can possibly be found ...still fooled by Dx = Dy = Dz = {a, b}, Dw = {c, d} 3 binary constraints, they are GAC, no pruning 10/04/2017 A CP Tutorial: Hnich

54
**Example: all-different**

Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠ all-different F { } S { } N { } logically equivalent 3 binary constraints, they are GAC, no pruning 1 ternary constraint, not GAC, GAC pruning ® empty domain no solution!! 10/04/2017 A CP Tutorial: Hnich

55
**All-different: A Filtering Algorithm**

Build the corresponding bipartite graph x1 x2 x3 x4 x5 x6 1 2 3 4 5 6 7 10/04/2017 A CP Tutorial: Hnich

56
**All-different: A Filtering Algorithm**

Build the corresponding bipartite graph ∃ solution iff ∃ matching covering all the variables x1 x2 x3 x4 x5 x6 1 2 3 4 5 6 7 10/04/2017 A CP Tutorial: Hnich

57
**All-different: A Filtering Algorithm**

Build the corresponding bipartite graph ∃ solution iff ∃ matching covering all the variables filtering find alternating cycles and paths remove inconsistent values (useless edges) [X4=2] fix variables (vital edges) [X4=4] x1 x2 x3 x4 x5 x6 1 2 3 4 5 6 7 10/04/2017 A CP Tutorial: Hnich

58
**All-different: A Filtering Algorithm**

Build the corresponding bipartite graph ∃ solution iff ∃ matching covering all the variables starting from the current matching at each call makes the algorithm incremental achieves GAC x1 x2 x3 x4 x5 x6 1 2 3 4 5 6 7 10/04/2017 A CP Tutorial: Hnich

59
**Cardinality: A Filtering Algorithm**

distribute([c1, , cm],[v1, , vm],[x1, ,xn]), ci ∈ [li, ui] 10/04/2017 A CP Tutorial: Hnich

60
**Cardinality: A Filtering Algorithm**

distribute([c1, , cm],[v1, , vm],[x1, ,xn]), ci ∈ [li, ui] transformed into a network flow problem ∃ solution iff ∃ feasible flow v1 [0,1] [l1,u1] x1 [1,1] v2 T S xi vj xn [lm,um] vm 10/04/2017 A CP Tutorial: Hnich

61
**Cardinality: A Filtering Algorithm**

Compute a maximum flow Build the residual graph Find its strongly connected components Remove zero-flow arcs between components achieves GAC 10/04/2017 A CP Tutorial: Hnich

62
**Lexicographic Ordering: A Filtering Algorithm**

A new family of global constraints Linear time complexity Ensures that a pair of vectors of variables are lexicographically ordered. 1 4 2 lex 2 9 8 7 10/04/2017 A CP Tutorial: Hnich

63
Motivation: Symmetry Symmetry: transformation of an entity that preserves the properties of the entity Example: 180º 10/04/2017 A CP Tutorial: Hnich

64
**Motivation: Symmetry Frequently occurs Tough for IP**

Combinatorial problems like covering arrays Rows and columns can be permuted Messy real world problems like nurse rostering Nurses with same skills can be swapped Tough for IP Very active research area within CP Some effective techniques have been developed 10/04/2017 A CP Tutorial: Hnich

65
**Motivation An important class of symmetries in CP**

matrices of decision variables rows/columns represent indistinguishable objects, hence symmetric Rows and columns can be permuted without affecting satisfiability Encountered frequently Chapter 1, Section 1.2 10/04/2017 A CP Tutorial: Hnich

66
**Example: Sports Scheduling**

Schedule games between n teams over n-1 weeks Each week is divided into n/2 periods Each period has 2 slots: home and away Find a schedule such that every team plays exactly once a week every team plays against every other team every team plays at most twice in the same period over the tournament Chapter 1, Section 1.2 10/04/2017 A CP Tutorial: Hnich

67
**Example: Sport Scheduling**

We need a table of meetings! Period3 Period4 Period2 Period1 0 vs 7 2 vs 7 2 vs 6 0 vs 4 1 vs 6 3 vs 5 4 vs 5 0 vs 5 1 vs 4 3 vs 7 Week 5 3 vs 4 0 vs 6 1 vs 5 Week 6 1 vs 3 1 vs 2 2 vs 5 4 vs 6 6 vs 7 5 vs 6 5 vs 7 0 vs 3 1 vs 7 2 vs 3 2 vs 4 3 vs 6 4 vs 7 0 vs 2 0 vs 1 Week 7 Week 4 Week 3 Week 2 Week1 Chapter 1, Section 1.2 10/04/2017 A CP Tutorial: Hnich

68
**Example: Sport Scheduling**

We need a table of meetings! Period3 Period4 Period2 Period1 0 vs 7 2 vs 7 2 vs 6 0 vs 4 1 vs 6 3 vs 5 4 vs 5 0 vs 5 1 vs 4 3 vs 7 Week 5 3 vs 4 0 vs 6 1 vs 5 Week 6 1 vs 3 1 vs 2 2 vs 5 4 vs 6 6 vs 7 5 vs 6 5 vs 7 0 vs 3 1 vs 7 2 vs 3 2 vs 4 3 vs 6 4 vs 7 0 vs 2 0 vs 1 Week 7 Week 4 Week 3 Week 2 Week1 Chapter 1, Section 1.2 Weeks are indistinguishable Periods are indistinguishable 10/04/2017 A CP Tutorial: Hnich

69
**Example: Sport Scheduling**

Weeks are indistinguishable Periods are indistinguishable Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Period 1 0 vs 1 0 vs 2 4 vs 7 3 vs 6 3 vs 7 1 vs 5 2 vs 4 Period 2 Chapter 1, Section 1.2 2 vs 3 1 vs 7 0 vs 3 5 vs 7 1 vs 4 0 vs 6 5 vs 6 Period 3 4 vs 5 3 vs 5 1 vs 6 0 vs 4 2 vs 6 2 vs 7 0 vs 7 Period 4 6 vs 7 4 vs 6 2 vs 5 1 vs 2 0 vs 5 3 vs 4 1 vs 3 10/04/2017 A CP Tutorial: Hnich

70
**Example: Sport Scheduling**

Weeks are indistinguishable Periods are indistinguishable Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Period 1 0 vs 1 3 vs 7 4 vs 7 3 vs 6 0 vs 2 1 vs 5 2 vs 4 Period 2 Chapter 1, Section 1.2 2 vs 3 1 vs 4 0 vs 3 5 vs 7 1 vs 7 0 vs 6 5 vs 6 Period 3 4 vs 5 2 vs 6 1 vs 6 0 vs 4 3 vs 5 2 vs 7 0 vs 7 Period 4 6 vs 7 0 vs 5 2 vs 5 1 vs 2 4 vs 6 3 vs 4 1 vs 3 10/04/2017 A CP Tutorial: Hnich

71
**Example: Bin Packing Consider 2 identical bins: A B 10/04/2017**

A CP Tutorial: Hnich

72
**Example Consider 2 identical bins: We must pack 6 items: A B 1 2 3 4 5**

10/04/2017 A CP Tutorial: Hnich

73
**Example Here is one solution: 5 6 3 4 1 2 A B 10/04/2017**

A CP Tutorial: Hnich

74
**Example Here is another: 6 5 4 3 2 1 A B 10/04/2017**

A CP Tutorial: Hnich

75
**Example Is there any fundamental difference? 5 6 a) 3 4 1 2 A B 6 5 b)**

10/04/2017 A CP Tutorial: Hnich

76
**Example Consider a matrix model: 1 2 3 4 5 6 A B 1 2 3 4 5 6 A B 5 6**

B 5 6 a) 3 4 1 2 A B 1 2 3 4 5 6 A B 6 5 b) 4 3 2 1 A B 10/04/2017 A CP Tutorial: Hnich

77
**Example Consider a matrix model: 1 2 3 4 5 6 A B 1 2 3 4 5 6 A B**

NB: ‘1’ means place this item in this bin: Consider a matrix model: 1 2 3 4 5 6 A B 5 6 a) 3 4 1 2 A B 1 2 3 4 5 6 A B 6 5 b) 4 3 2 1 A B 10/04/2017 A CP Tutorial: Hnich

78
**Example Consider a matrix model: 1 2 3 4 5 6 A B 1 2 3 4 5 6 A B**

B If we insist that row A lex row B, we remove a) from the solution set. 1 2 3 4 5 6 A B 6 5 b) 4 3 2 1 A B 10/04/2017 A CP Tutorial: Hnich

79
**Example Notice that items 3 and 4 are identical. 1 2 3 4 5 6 A B 1 2 3**

B 6 5 b) 4 3 2 1 A B 1 2 3 4 5 6 A B 6 5 c) 3 4 2 1 10/04/2017 A CP Tutorial: Hnich

80
**Example Notice that items 3 and 4 are identical. 1 2 3 4 5 6 A B 1 2 3**

B 6 5 b) 4 3 2 1 A B 1 2 3 4 5 6 A B If we insist that col 3 lex col 4, we remove c) from the solution set. 10/04/2017 A CP Tutorial: Hnich

81
**Aims Main Goal Aims: we focus on lexicographic ordering constraints**

Eliminate row and column symmetries effectively and efficiently. Aims: Investigate types of ordering constraints to break row and column symmetries. Devise global constraints to easily pose and efficiently solve the ordering constraints. Examine the effectiveness of the ordering constraint we focus on lexicographic ordering constraints 10/04/2017 A CP Tutorial: Hnich

82
**How GACLex Works Consider the following example.**

We have two vectors of decision variables: x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} 10/04/2017 A CP Tutorial: Hnich

83
**How GACLex Works Consider the following example.**

We have two vectors of decision variables: x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} We want to enforce GAC on: x lex y. 10/04/2017 A CP Tutorial: Hnich

84
A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 10/04/2017 A CP Tutorial: Hnich

85
A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. We index the vectors as follows: 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} 10/04/2017 Most Significant Index A CP Tutorial: Hnich

86
A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α: index such that all variables at more significant indices are ground and equal. 10/04/2017 A CP Tutorial: Hnich

87
A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

88
A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α: index such that all variables at more significant indices are ground and equal. β: If tails never violate the constraint: 10/04/2017 A CP Tutorial: Hnich

89
**Pointer Initialisation**

Needs one traversal of the vectors (linear). 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

90
**Pointer Initialisation**

Needs one traversal of the vectors (linear). 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

91
**Failure Inconsistent if β α.**

α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

92
**How GACLex Works We maintain α and β as assignments made.**

α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

93
**How GACLex Works We maintain α and β as assignments made.**

When β = α + 1 we enforce bounds consistency on: xα < yα α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

94
**How GACLex Works We maintain α and β as assignments made.**

When β = α + 1 we enforce bounds consistency on: xα < yα The variable at the αth element of each vector. α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

95
**How GACLex Works We maintain α and β as assignments made.**

When β = α + 1 we enforce bounds consistency on: xα < yα When β > α + 1 we enforce bounds consistency on: xα yα α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

96
**How GACLex Works We maintain α and β as assignments made.**

Key: we reduce GAC on vectors to BC on binary constraints. α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

97
How GACLex Works 0, 1 removed from yα. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

98
How GACLex Works 0, 1 removed from yα. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

99
**How GACLex Works Update α.**

1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

100
How GACLex Works Update α. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

101
**How GACLex Works 3, 4 removed from xα. α β**

1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

102
**How GACLex Works 3, 4 removed from xα. α β**

1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

103
**How GACLex Works Update α. α β**

1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

104
**How GACLex Works Update α. α β**

1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

105
How GACLex Works 4, 5 removed from xα, 0, 1 removed from yα. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

106
How GACLex Works 4, 5 removed from xα, 0, 1 removed from yα. 1 2 3 4 x {2} {1,3,4} {1,2,3,4,5} {1,2} {3,4,5} y {0,1,2} {1} {0,1,2,3,4} {0,1} α β α: index such that all variables at more significant indices are ground and equal. β: most significant index from which the two vectors’ tails necessarily violate the constraint. 10/04/2017 A CP Tutorial: Hnich

107
**Complexity Initialisation: O(n) Propagation:**

We enforce bounds consistency between at most n pairs of variables: xα < yα or xα yα. Cost: b. Overall cost: O(nb). Amortised cost: O(b) 10/04/2017 A CP Tutorial: Hnich

108
**Results: BIBD Decomposition takes**

About 9 times longer on each of these instances. 10/04/2017 A CP Tutorial: Hnich

109
**Constraint Propagation**

General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion 10/04/2017 A CP Tutorial: Hnich

110
**Conclusion Constraint propagation is the glue to combine efficient**

filtering algorithms for common substructures Matching theory, network flow theory, automata theory, computational geometry, …, encapsulated in constraints Characterization of level of consistency Aim for incrementality Amount/frequency of filtering vs processing time 10/04/2017 A CP Tutorial: Hnich

111
ANY QUESTIONS?

112
Search

113
**Search General principle Variable selection heuristics**

Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

114
**General principle … var int Solution[Nodes] in Values; solve{**

forall(e in Edges) abs(Solution[e.x] - Solution[e.y]) >1; alldifferent(Solution); }; 10/04/2017 A CP Tutorial: Hnich

115
**General principle … var int Solution[Nodes] in Values; solve{ };**

search { } 10/04/2017 A CP Tutorial: Hnich

116
**General principle With a good search strategy**

… var int Solution[Nodes] in Values; solve{ forall(e in Edges) abs(Solution[e.x] - Solution[e.y]) >1; alldifferent(Solution); }; search { } With a good search strategy We can quickly find good solution 10/04/2017 A CP Tutorial: Hnich

117
**Searching for a good solution**

For any interesting problem, propagation alone is not enough We typically proceed by tree search 10/04/2017 A CP Tutorial: Hnich

118
**Solving CSP by Search Search tree: root: empty node**

one variable per level sucessors of a node: every value of the next level var F N S 10/04/2017 A CP Tutorial: Hnich

119
**Searching for a good solution**

Two main decisions to control search choose a variable choose a value from its domain 10/04/2017 A CP Tutorial: Hnich

120
**Search General principle Variable selection heuristics**

Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

121
**Variable Selection Heuristics**

Has an impact on tree topology static vs dynamic ordering smallest-domain-first first-fail principle: “To succeed, try first where you are most likely to fail.” regret: favour variable with greatest difference in cost between two best values in domain 10/04/2017 A CP Tutorial: Hnich

122
**Search General principle Variable selection heuristics**

Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

123
**Value Selection Heuristics**

Not as critical Very problem-dependent Alternative for large domains: domain splitting 10/04/2017 A CP Tutorial: Hnich

124
**Search General principle Variable selection heuristics**

Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

125
**Conclusion A lot of control over the search strategy**

Many heuristics developed, some of them generic 10/04/2017 A CP Tutorial: Hnich

126
ANY QUESTIONS?

127
**Lot-sizing under demand uncertainty**

128
**Demand Uncertainty in Supply Chain Networks**

Inventories Production 10/04/2017 A CP Tutorial: Hnich Sales

129
**Demand Uncertainty in Supply Chain Networks**

? When to order? How much to order? Inventories Production 10/04/2017 A CP Tutorial: Hnich Sales

130
**Demand Uncertainty in Supply Chain Networks**

? When to order? How much to order? Inventories Production Demand Uncertainty 10/04/2017 A CP Tutorial: Hnich Sales

131
**Demand Uncertainty in Supply Chain Networks**

? When to order? How much to order? Inventories Production Demand Uncertainty work in collaboration with Bell Labs Ireland Sales 10/04/2017 A CP Tutorial: Hnich

132
**Demand Uncertainty in Supply Chain Networks**

Determining the optimal inventory control policy parameters is key to profitability for any company involved in distribution and/or production of goods We developed a CP model to find the optimal dynamic (R,S) inventory policy parameters such that the expected cost is minimized; demand is stochastic, non-stationary; and a minimum service level is required 10/04/2017 A CP Tutorial: Hnich

133
Results State-of-the-art improvement for the stochastic non-stationary formulation of the lot-sizing problem Real-world instances can be solved in few seconds The strategy could be extended to deal with Capacity constraints Lead time uncertainty 10/04/2017 A CP Tutorial: Hnich

134
(Demo) 10/04/2017 A CP Tutorial: Hnich

135
Experimental results 10/04/2017 A CP Tutorial: Hnich

136
ANY QUESTIONS?

137
**Successful CP (Machine) Scheduling**

(whole book on constraint-based scheduling) Sports Scheduling (e.g. NFL) Rostering Allocation (e.g. terminal gates to aircrafts) Transportation (e.g. VRP, airline crew rotation) Even pure problems like Maximum Clique Production planning (Lot-sizing) 10/04/2017 A CP Tutorial: Hnich

138
**Finding out more Talks: CP, CPAIOR, IJCAI, AAAI, ECAI, INFORMS, CORS**

Papers: Lecture Notes in Computer Science (Springer), Constraints (Kluwer), AI journals, OR journals Software: CHIP; ECLiPSe; ECLAIR; FaCiLe; ILOG OPL, Solver; SISCtus Prolog, Choco,. . . 10/04/2017 A CP Tutorial: Hnich

139
**Finding out more Books:**

Apt, K., Principles of Constraint Programming, Cambridge University Press, Baptiste, P., Le Pape, C., Nuijten, W.. Constraint-Based Scheduling, Kluwer Academic Publishers,2001. Hooker, J., Logic-Based Methods for Optimization: Combining Optimization and Constraint Satisfaction, John Wiley & Sons, 2000. Marriott, K., Stuckey, P.J., Programming with Constraints: An Introduction, MIT Press, 1998. Constraint and Integer Programming: Toward a Unified Methodology, edited by M. Milano, Kluwer Academic Publishers, 2003. Tsang, E., Foundations of Constraint Satisfaction, Academic Press, 1993. Van Hentenryck, P., The OPL Optimization Programming Language, MIT Press, 1999. 10/04/2017 A CP Tutorial: Hnich

140
Acknowledgements Some parts of this tutorial are adapted material from tutorials given by: Gilles Pesant Pedro Messeguer Chris Beck Most parts of the tutorial is work done in collaboration with: Alan Frisch, Ian miguel, Zeynep Kiziltan, Toby Walsh, Armagan Tarim, Roberto Rossi, Steven Prestwich 10/04/2017 A CP Tutorial: Hnich

Similar presentations

OK

Global Constraints Toby Walsh NICTA and University of New South Wales www.cse.unsw.edu.au/~tw.

Global Constraints Toby Walsh NICTA and University of New South Wales www.cse.unsw.edu.au/~tw.

© 2018 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on front office department Ppt on ram and rom hyper Respiratory system anatomy and physiology ppt on cells Ppt on tamper resistant paper Ppt on noise in communication system Ppt on preposition in hindi Ppt on year of faith Ppt on javascript events w3school Ppt on world book day character Ppt on different types of dance forms of the world