Download presentation

Presentation is loading. Please wait.

Published byFrank Brooks Modified about 1 year ago

1
The Theory and Practice of Constraint Programming: An Overview Brahim Hnich Faculty of Computer Science Izmir University of Economics Izmir, Turkey

2
11/04/2015A CP Tutorial: Hnich2 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

3
11/04/2015A CP Tutorial: Hnich3 Caveat In this talk: Constraint programming for combinatorial problems “Programming” refers to its roots in computer science (programming languages)

4
11/04/2015A CP Tutorial: Hnich4 Outline Modelling Constraint propagation Search Demo: Lot-sizing with stochastic non-stationary demand

5
11/04/2015A CP Tutorial: Hnich5 A Puzzle Place the numbers 1 through 8 in the nodes such that: Each number appears exactly once No connected nodes have consecutive numbers ? ? ? ? ? ? ??

6
11/04/2015A CP Tutorial: Hnich6 Modeling Each node a decision variable {1, …, 8} values in the domain of each variable No consecutive numbers a constraint (v i, v j ) |v i – v j | > 1 All values used a clique of not-equals constraints forall i

7
11/04/2015A CP Tutorial: Hnich7 Modeling Each node a decision variable {1, …, 8} values in the domain of each variable No consecutive numbers a constraint (v i, v j ) |v i – v j | > 1 All values used forall i

8
11/04/2015A CP Tutorial: Hnich8 Heuristic Search ? ? ? ? ? ? ?? 18 {1, 2, 3, 4, 5, 6, 7, 8}

9
11/04/2015A CP Tutorial: Hnich9 Inference/Propagation ? ? ? ? ? ? ?? 18 {1, 2, 3, 4, 5, 6, 7, 8}

10
11/04/2015A CP Tutorial: Hnich10 Inference/Propagation ? ? ? ? ? ? ?? 18 {3, 4, 5, 6} {3, 4, 5, 6, 7}{2, 3, 4, 5, 6}

11
11/04/2015A CP Tutorial: Hnich11 An OPL Model int N=8; struct edge{int x; int y;}; {edge} Edges ={,,…, }; 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); };

12
11/04/2015A CP Tutorial: Hnich12 The Core of Constraint Computation Solving Heuristic Search Propagation Modelling

13
ANY QUESTIONS?

14
Modeling

15
11/04/2015A CP Tutorial: Hnich15 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)

16
11/04/2015A CP Tutorial: Hnich16 Constraint Satisfaction Problems CSP: (X, D, C) oX = {x 1, x 2,…, x n } variables oD = {d 1, d 2,…,d n } domains (finite) oC = {c 1,c 2,…,c e } constraints c ЄC var(c) = {x i, x j,…, x k } scope rel(c) ⊆ d i x d j x.. x d k permitted tuples Solution: oassignment satisfying every constraint oNP-complete task

17
11/04/2015A CP Tutorial: Hnich17 CSP: Relevance Artificial Intelligence o temporal reasoning Control Theory o controllers for sensory based robots Concurency o process comm. and synchr. Computer Graphics o geometric coherence Database Systems o constraint databases Bioinformatics o sequence alignment Operations research o optimization Real-life applications Production planning Staff scheduling Resource allocation Circuit design Option trading DNA sequencing ... Many problems can be represented as CSP:

18
11/04/2015A CP Tutorial: Hnich18 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

19
11/04/2015A CP Tutorial: Hnich19 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

20
11/04/2015A CP Tutorial: Hnich20 Map Colouring N S F Variables: F, N, S Values: { } Constraints: N ≠ S ≠ F ≠ N A solution: F N S

21
11/04/2015A CP Tutorial: Hnich21 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: 1.Each word in S has 4 symbols from { C,G };

22
11/04/2015A CP Tutorial: Hnich22 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: 1.Each word in S has 4 symbols from { C,G }; 2.Each pair of distinct words in S differ in at least 4 positions; and

23
11/04/2015A CP Tutorial: Hnich23 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 : 1.Each word in S has 4 symbols from { C,G }; 2.Each pair of distinct words in S differ in at least 4 positions; and 3.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. o(x1,…,x8)R = ( x8,…,x1 ) is the reverse of ( x1,…,x8 ) o(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.

24
11/04/2015A CP Tutorial: Hnich24 A Solution S= { AAGCCGTT, TACGCGAT} Each word in S has 4 symbols from { C,G };

25
11/04/2015A CP Tutorial: Hnich25 A Solution S= { AAGCCGTT, TACGCGAT} Each pair of distinct words in S differ in at least 4 positions

26
11/04/2015A CP Tutorial: Hnich26 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

27
11/04/2015A CP Tutorial: Hnich27 A Matrix Model M { A,C,G,T } … m Each row represents a word in S M[i,j]: a decision variable with domain { A,C,G,T }

28
11/04/2015A CP Tutorial: Hnich28 A Matrix Model M { A,C,G,T } … m 1.Expressing that each word in S has 4 symbols from { C,G }

29
11/04/2015A CP Tutorial: Hnich29 A Matrix Model M { 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

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

31
11/04/2015A CP Tutorial: Hnich31 A Matrix Model MC { A,C,G,T } … m 1.… 2.… 3.xR and yC differ in at least 4 positions. Introduce a “compliment matrix” Each pair //channelling constraints in {,,, }

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

33
ANY QUESTIONS?

34
Constraint Propagation

35
11/04/2015A CP Tutorial: Hnich35 Constraint Propagation General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion

36
11/04/2015A CP Tutorial: Hnich36 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

37
11/04/2015A CP Tutorial: Hnich37 General Principle ? ? ? ? ? ? ?? 18 {1, 2, 3, 4, 5, 6, 7, 8} ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ ≠ Constraint network

38
11/04/2015A CP Tutorial: Hnich38 General Principle This propagation necessarily terminates The results is the same regardless of the order in which we consider the constraints

39
11/04/2015A CP Tutorial: Hnich39 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)

40
11/04/2015A CP Tutorial: Hnich40 Constraint Propagation General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion

41
11/04/2015A CP Tutorial: Hnich41 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

42
11/04/2015A CP Tutorial: Hnich42 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.

43
11/04/2015A CP Tutorial: Hnich43 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.

44
11/04/2015A CP Tutorial: Hnich44 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

45
11/04/2015A CP Tutorial: Hnich45 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

46
11/04/2015A CP Tutorial: Hnich46 Constraint Propagation General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion

47
11/04/2015A CP Tutorial: Hnich47 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

48
11/04/2015A CP Tutorial: Hnich48 Inequalities: Filtering Algorithm Consider x

49
11/04/2015A CP Tutorial: Hnich49 Constraint Propagation General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion

50
11/04/2015A CP Tutorial: Hnich50 Example: all-different 3 binary constraints, they are GAC, no pruning Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠≠ ≠

51
11/04/2015A CP Tutorial: Hnich51 Example: all-different Using binary disequalities, this inconsistency goes undetected 3 binary constraints, they are GAC, no pruning Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠≠ ≠

52
11/04/2015A CP Tutorial: Hnich52 Example: all-different We can do something simple: 1.Count the number of variables, n 2.Count the number of values in the union of their domains, m 3.If n > m then no solution can possibly be found 3 binary constraints, they are GAC, no pruning Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠≠ ≠

53
11/04/2015A CP Tutorial: Hnich53 Example: all-different We can do something simple: 1.Count the number of variables, n 2.Count the number of values in the union of their domains, m 3.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 Var: F, N, S; Val: { }; Ctrs: N ≠ S ≠ F ≠ N F { } S { } N { } ≠≠ ≠

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

55
11/04/2015A CP Tutorial: Hnich55 All-different: A Filtering Algorithm Build the corresponding bipartite graph x2 x1 x3 x5 x4 x6

56
11/04/2015A CP Tutorial: Hnich56 All-different: A Filtering Algorithm Build the corresponding bipartite graph ∃ solution iff ∃ matching covering all the variables x2 x1 x3 x5 x4 x6

57
11/04/2015A CP Tutorial: Hnich57 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] x2 x1 x3 x5 x4 x6

58
11/04/2015A CP Tutorial: Hnich58 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 x2 x1 x3 x5 x4 x6

59
11/04/2015A CP Tutorial: Hnich59 Cardinality: A Filtering Algorithm distribute([c1,..., cm],[v1,..., vm],[x1,...,xn]), ci ∈ [li, ui]

60
11/04/2015A CP Tutorial: Hnich60 Cardinality: A Filtering Algorithm distribute([c1,..., cm],[v1,..., vm],[x1,...,xn]), ci ∈ [li, ui] transformed into a network flow problem ∃ solution iff ∃ feasible flow S T x1 xn xi v2 v1 vm vj [1,1] [0,1] [l1,u1] [lm,um]

61
11/04/2015A CP Tutorial: Hnich61 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

62
11/04/2015A CP Tutorial: Hnich62 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 lex

63
11/04/2015A CP Tutorial: Hnich63 Motivation: Symmetry Symmetry: transformation of an entity that preserves the properties of the entity Example: 180º

64
11/04/2015A CP Tutorial: Hnich64 Motivation: Symmetry Frequently occurs Combinatorial problems like covering arrays oRows and columns can be permuted Messy real world problems like nurse rostering oNurses with same skills can be swapped Tough for IP Very active research area within CP Some effective techniques have been developed

65
11/04/2015A CP Tutorial: Hnich65 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

66
11/04/2015A CP Tutorial: Hnich66 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 Example: Sports Scheduling

67
11/04/2015A CP Tutorial: Hnich67 Example: Sport Scheduling Period3 Period4 Period 2 Period1 0 vs 72 vs 72 vs 60 vs 41 vs 63 vs 54 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 31 vs 22 vs 54 vs 66 vs 7 5 vs 65 vs 70 vs 31 vs 72 vs 3 2 vs 43 vs 64 vs 7 0 vs 2 0 vs 1 Week 7Week 4Week 3Week 2Week1 We need a table of meetings!

68
11/04/2015A CP Tutorial: Hnich68 Example: Sport Scheduling Period3 Period4 Period 2 Period1 0 vs 72 vs 72 vs 60 vs 41 vs 63 vs 54 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 31 vs 22 vs 54 vs 66 vs 7 5 vs 65 vs 70 vs 31 vs 72 vs 3 2 vs 43 vs 64 vs 7 0 vs 2 0 vs 1 Week 7Week 4Week 3Week 2Week1 Weeks are indistinguishable Periods are indistinguishable We need a table of meetings!

69
11/04/2015A CP Tutorial: Hnich69 0 vs 72 vs 72 vs 60 vs 41 vs 63 vs 54 vs 5 Period 3 0 vs 5 1 vs 4 3 vs 7 Week 5 3 vs 4 0 vs 6 1 vs 5 Week 6 1 vs 31 vs 22 vs 54 vs 66 vs 7 Period 4 5 vs 65 vs 70 vs 31 vs 72 vs 3 Period 2 2 vs 43 vs 64 vs 7 0 vs 2 0 vs 1 Period 1 Week 7Week 4Week 3Week 2Week 1 Example: Sport Scheduling Weeks are indistinguishable Periods are indistinguishable

70
11/04/2015A CP Tutorial: Hnich70 0 vs 72 vs 72 vs 60 vs 41 vs 6 3 vs 5 4 vs 5 Period 3 0 vs 5 1 vs 4 3 vs 7 Week 5 3 vs 4 0 vs 6 1 vs 5 Week 6 1 vs 31 vs 22 vs 54 vs 66 vs 7 Period 4 5 vs 65 vs 70 vs 3 1 vs 7 2 vs 3 Period 2 2 vs 43 vs 64 vs 7 0 vs 2 0 vs 1 Period 1 Week 7Week 4Week 3Week 2Week 1 Example: Sport Scheduling Weeks are indistinguishable Periods are indistinguishable

71
11/04/2015A CP Tutorial: Hnich71 Example: Bin Packing Consider 2 identical bins: BA

72
11/04/2015A CP Tutorial: Hnich72 Example Consider 2 identical bins: We must pack 6 items: BA

73
11/04/2015A CP Tutorial: Hnich73 Example Here is one solution: BA

74
11/04/2015A CP Tutorial: Hnich74 Example Here is another: BA

75
11/04/2015A CP Tutorial: Hnich75 Example Is there any fundamental difference? a) b) AB BA

76
11/04/2015A CP Tutorial: Hnich76 Example Consider a matrix model: A B A B a) b) AB BA

77
11/04/2015A CP Tutorial: Hnich77 Example Consider a matrix model: NB: ‘1’ means place this item in this bin: A B A B a) b) AB BA

78
11/04/2015A CP Tutorial: Hnich78 Example Consider a matrix model: If we insist that row A lex row B, we remove a) from the solution set A B A B b) BA

79
11/04/2015A CP Tutorial: Hnich79 Example Notice that items 3 and 4 are identical A B b) BA A B c)

80
11/04/2015A CP Tutorial: Hnich80 Example Notice that items 3 and 4 are identical A B b) BA A B If we insist that col 3 lex col 4, we remove c) from the solution set.

81
11/04/2015A CP Tutorial: Hnich81 Aims Main Goal 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

82
11/04/2015A CP Tutorial: Hnich82 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}{0,1,2}

83
11/04/2015A CP Tutorial: Hnich83 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}{0,1,2} We want to enforce GAC on: x lex y.

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

85
11/04/2015A CP Tutorial: Hnich85 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors. We index the vectors as follows: 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}{0,1,2} Most Significant Index

86
11/04/2015A CP Tutorial: Hnich86 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors 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}{0,1,2} α: index such that all variables at more significant indices are ground and equal.

87
11/04/2015A CP Tutorial: Hnich87 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors 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}{0,1,2} α: 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.

88
11/04/2015A CP Tutorial: Hnich88 A Tale of Two Pointers We use two pointers, α and β, to avoid repeatedly traversing the vectors 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}{0,1,2} α: index such that all variables at more significant indices are ground and equal. β: If tails never violate the constraint:

89
11/04/2015A CP Tutorial: Hnich89 Pointer Initialisation Needs one traversal of the vectors (linear) 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}{0,1,2} α α: 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.

90
11/04/2015A CP Tutorial: Hnich90 Pointer Initialisation Needs one traversal of the vectors (linear) 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}{0,1,2} α β α: 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.

91
11/04/2015A CP Tutorial: Hnich91 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.

92
11/04/2015A CP Tutorial: Hnich92 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.

93
11/04/2015A CP Tutorial: Hnich93 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.

94
11/04/2015A CP Tutorial: Hnich94 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.

95
11/04/2015A CP Tutorial: Hnich95 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.

96
11/04/2015A CP Tutorial: Hnich96 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.

97
11/04/2015A CP Tutorial: Hnich97 How GACLex Works 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}{0,1,2} α β 0, 1 removed from 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.

98
11/04/2015A CP Tutorial: Hnich98 How GACLex Works 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}{0,1,2} α β 0, 1 removed from 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.

99
11/04/2015A CP Tutorial: Hnich99 How GACLex Works 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}{0,1,2} α β Update α. α: 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.

100
11/04/2015A CP Tutorial: Hnich100 How GACLex Works 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}{0,1,2} α β Update α. α: 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.

101
11/04/2015A CP Tutorial: Hnich101 How GACLex Works 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}{0,1,2} α β 3, 4 removed from x α. α: 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.

102
11/04/2015A CP Tutorial: Hnich102 How GACLex Works 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}{0,1,2} α β 3, 4 removed from x α. α: 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.

103
11/04/2015A CP Tutorial: Hnich103 How GACLex Works 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}{0,1,2} α β Update α. α: 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.

104
11/04/2015A CP Tutorial: Hnich104 How GACLex Works 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}{0,1,2} α β Update α. α: 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.

105
11/04/2015A CP Tutorial: Hnich105 How GACLex Works 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}{0,1,2} α β 4, 5 removed from x α, 0, 1 removed from 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.

106
11/04/2015A CP Tutorial: Hnich106 How GACLex Works 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}{0,1,2} α β 4, 5 removed from x α, 0, 1 removed from 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.

107
11/04/2015A CP Tutorial: Hnich107 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)

108
11/04/2015A CP Tutorial: Hnich108 Results: BIBD Decomposition takes About 9 times longer on each of these instances.

109
11/04/2015A CP Tutorial: Hnich109 Constraint Propagation General principle Consistency Filtering on simple constraints Filtering on global constraints Conclusion

110
11/04/2015A CP Tutorial: Hnich110 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

111
ANY QUESTIONS?

112
Search

113
11/04/2015A CP Tutorial: Hnich113 Search General principle Variable selection heuristics Value selection heuristics Conclusion

114
11/04/2015A CP Tutorial: Hnich114 General principle … var int Solution[Nodes] in Values; solve{ forall(e in Edges) abs(Solution[e.x] - Solution[e.y]) >1; alldifferent(Solution); };

115
11/04/2015A CP Tutorial: Hnich115 General principle … var int Solution[Nodes] in Values; solve{ … }; search { … }

116
11/04/2015A CP Tutorial: Hnich116 General principle … 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

117
11/04/2015A CP Tutorial: Hnich117 Searching for a good solution For any interesting problem, propagation alone is not enough We typically proceed by tree search

118
11/04/2015A CP Tutorial: Hnich118 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

119
11/04/2015A CP Tutorial: Hnich119 Searching for a good solution Two main decisions to control search choose a variable choose a value from its domain

120
11/04/2015A CP Tutorial: Hnich120 Search General principle Variable selection heuristics Value selection heuristics Conclusion

121
11/04/2015A CP Tutorial: Hnich121 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

122
11/04/2015A CP Tutorial: Hnich122 Search General principle Variable selection heuristics Value selection heuristics Conclusion

123
11/04/2015A CP Tutorial: Hnich123 Value Selection Heuristics Not as critical Very problem-dependent Alternative for large domains: domain splitting

124
11/04/2015A CP Tutorial: Hnich124 Search General principle Variable selection heuristics Value selection heuristics Conclusion

125
11/04/2015A CP Tutorial: Hnich125 Conclusion A lot of control over the search strategy Many heuristics developed, some of them generic

126
ANY QUESTIONS?

127
Lot-sizing under demand uncertainty

128
11/04/2015A CP Tutorial: Hnich128 Demand Uncertainty in Supply Chain Networks Production Inventories Sales

129
11/04/2015A CP Tutorial: Hnich129 Demand Uncertainty in Supply Chain Networks Production Inventories Sales ? When to order? How much to order?

130
11/04/2015A CP Tutorial: Hnich130 Demand Uncertainty in Supply Chain Networks Production Inventories Sales Demand Uncertainty ? When to order? How much to order?

131
11/04/2015A CP Tutorial: Hnich131 Demand Uncertainty in Supply Chain Networks Production Inventories Sales Demand Uncertainty ? When to order? How much to order? work in collaboration with Bell Labs Ireland

132
11/04/2015A CP Tutorial: Hnich132 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

133
11/04/2015A CP Tutorial: Hnich133 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

134
11/04/2015A CP Tutorial: Hnich134 (Demo)

135
11/04/2015A CP Tutorial: Hnich135 Experimental results

136
ANY QUESTIONS?

137
11/04/2015A CP Tutorial: Hnich137 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)

138
11/04/2015A CP Tutorial: Hnich138 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,...

139
11/04/2015A CP Tutorial: Hnich139 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, Marriott, K., Stuckey, P.J., Programming with Constraints: An Introduction, MIT Press, Constraint and Integer Programming: Toward a Unified Methodology, edited by M. Milano, Kluwer Academic Publishers, Tsang, E., Foundations of Constraint Satisfaction, Academic Press, Van Hentenryck, P., The OPL Optimization Programming Language, MIT Press, 1999.

140
11/04/2015A CP Tutorial: Hnich140 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

141

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google