The Theory and Practice of Constraint Programming: An Overview

Slides:



Advertisements
Similar presentations
Constraint Satisfaction Problems
Advertisements

Artificial Intelligence 15. Constraint Satisfaction Problems
DCS Lecture how to solve it Patrick Prosser. Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Non-Binary Constraint Satisfaction Toby Walsh Cork Constraint Computation Center.
Non-binary Constraints Toby Walsh
Constraint Programming Peter van Beek University of Waterloo.
Constraint Satisfaction Problems Russell and Norvig: Chapter
University of Toronto Mechanical & Industrial Engineering An Introduction to Constraint Programming J. Christopher Beck Dept. of Mechanical & Industrial.
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Global Constraints Toby Walsh NICTA and University of New South Wales
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
Constraint Optimization We are interested in the general non-linear programming problem like the following Find x which optimizes f(x) subject to gi(x)
Constraint Satisfaction taking advantage of internal structure of states when paths don’t matter.
Constraint Networks (cont.) Emma Rollón Postdoctoral researcher at UCI April 1st, 2009.
Constraint Satisfaction Problems Russell and Norvig: Parts of Chapter 5 Slides adapted from: robotics.stanford.edu/~latombe/cs121/2004/home.htm Prof: Dekang.
1 Material to Cover  relationship between different types of models  incorrect to round real to integer variables  logical relationship: site selection.
Lecture 24 MAS 714 Hartmut Klauck
Global Constraints Toby Walsh National ICT Australia and University of New South Wales
1 Constraint Satisfaction Problems A Quick Overview (based on AIMA book slides)
1 Finite Constraint Domains. 2 u Constraint satisfaction problems (CSP) u A backtracking solver u Node and arc consistency u Bounds consistency u Generalized.
ICS-271:Notes 5: 1 Lecture 5: Constraint Satisfaction Problems ICS 271 Fall 2008.
G53CLP Constraint Logic Programming Modeling CSPs – Case Study I Dr Rong Qu.
1 Transportation problem The transportation problem seeks the determination of a minimum cost transportation plan for a single commodity from a number.
Case study 5: balanced academic curriculum problem Joint work with Brahim Hnich and Zeynep Kiziltan (CPAIOR 2002)
Leeds: 6 June 02Constraint Technology for the Masses Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Collaborators:
Transforming and Refining Abstract Constraint Specifications Alan Frisch, Brahim Hnich*, Ian Miguel, Barbara Smith, and Toby Walsh *Cork Constraint Computation.
Constraint Models for the Covering Test Problems Authors: Brahim Hnich, Steven D. Prestwich, Evgeny Selensky, Barbara M. Smith Speaker: Pingyu Zhang CSE.
Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Extending the Reach of Constraint Technology through Reformulation.
Matrix Modelling Alan M. Frisch and Ian Miguel (York) Brahim Hnich, Zeynep Kiziltan (Uppsala) Toby Walsh (Cork)
Matrix Modelling Pierre Flener (Uppsala) Alan M. Frisch (York) Brahim Hnich, Zeynep Kiziltan (Uppsala) Ian Miguel, and Toby Walsh (York)
Modeling the Covering Test Problem Brahim Hnich, Steven Prestwich, and Evgeny Selensky Cork Constraint Computation Center UCC Supported by SFI.
Alan M. Frisch Artificial Intelligence Group Department of Computer Science University of York Co-authors Ian Miguel, Toby Walsh, Pierre Flener, Brahim.
Global Constraints for Lexicographic Orderings Alan Frisch, Ian Miguel (University of York) Brahim Hnich, Toby Walsh (4C) Zeynep Kiziltan (Uppsala University)
Important Problem Types and Fundamental Data Structures
CP Summer School Modelling for Constraint Programming Barbara Smith 1.Definitions, Viewpoints, Constraints 2.Implied Constraints, Optimization,
Symmetry Breaking Ordering Constraints Zeynep Kiziltan Department of Information Science Uppsala University, Sweden A progress.
Constraint Satisfaction Problems (CSPs) CPSC 322 – CSP 1 Poole & Mackworth textbook: Sections § Lecturer: Alan Mackworth September 28, 2012.
© J. Christopher Beck Lecture 13: Modeling in Constraint Programming.
Modelling for Constraint Programming Barbara Smith CP 2010 Doctoral Programme.
CP Summer School Modelling for Constraint Programming Barbara Smith 2. Implied Constraints, Optimization, Dominance Rules.
Decision Diagrams for Sequencing and Scheduling Andre Augusto Cire Joint work with David Bergman, Willem-Jan van Hoeve, and John Hooker Tepper School of.
Chapter 1. Formulations 1. Integer Programming  Mixed Integer Optimization Problem (or (Linear) Mixed Integer Program, MIP) min c’x + d’y Ax +
The AllDifferent Constraint: Efficiency Measures Ian P. Gent, Ian Miguel, Peter Nightingale.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 8. Greedy Algorithms.
Sports Scheduling Written by Kelly Easton, George Nemhauser, Michael Trick Presented by Matthew Lai.
Chapter 5: Constraint Satisfaction ICS 171 Fall 2006.
CSC 423 ARTIFICIAL INTELLIGENCE Constraint Satisfaction Problems.
Exact and heuristics algorithms
Constraints and Search Toby Walsh Cork Constraint Computation Centre (4C) Logic & AR Summer School, 2002.
Chapter 2) CSP solving-An overview Overview of CSP solving techniques: problem reduction, search and solution synthesis Analyses of the characteristics.
CP Summer School Modelling for Constraint Programming Barbara Smith 3. Symmetry, Viewpoints.
Put a different number in each circle (1 to 8) such that adjacent circles cannot take consecutive numbers.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Computer Sciences Department1.  Property 1: each node can have up to two successor nodes (children)  The predecessor node of a node is called its.
Eliminating non- binary constraints Toby Walsh Cork Constraint Computation Center.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
10.3 Reformulation The Lex-Leader Method Shant Karakashian 1.
Scheduling with Constraint Programming
Constraint Programming
The minimum cost flow problem
Constraint Satisfaction
1.3 Modeling with exponentially many constr.
Chapter 1. Formulations (BW)
1.3 Modeling with exponentially many constr.
Constraints and Search
Chapter 1. Formulations.
Constraint Satisfaction Problems
Presentation transcript:

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

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

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

Outline Modelling Constraint propagation Search Demo: Lot-sizing with stochastic non-stationary demand 10/04/2017 A CP Tutorial: Hnich

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

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

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

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

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

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

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

The Core of Constraint Computation Modelling Solving Heuristic Search Propagation 10/04/2017 A CP Tutorial: Hnich

ANY QUESTIONS?

Modeling

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ANY QUESTIONS?

Constraint Propagation

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Example: Bin Packing Consider 2 identical bins: A B 10/04/2017 A CP Tutorial: Hnich

Example Consider 2 identical bins: We must pack 6 items: A B 1 2 3 4 5 10/04/2017 A CP Tutorial: Hnich

Example Here is one solution: 5 6 3 4 1 2 A B 10/04/2017 A CP Tutorial: Hnich

Example Here is another: 6 5 4 3 2 1 A B 10/04/2017 A CP Tutorial: Hnich

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

ANY QUESTIONS?

Search

Search General principle Variable selection heuristics Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

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

General principle … var int Solution[Nodes] in Values; solve{ }; search { } 10/04/2017 A CP Tutorial: Hnich

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

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

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

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

Search General principle Variable selection heuristics Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

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

Search General principle Variable selection heuristics Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

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

Search General principle Variable selection heuristics Value selection heuristics Conclusion 10/04/2017 A CP Tutorial: Hnich

Conclusion A lot of control over the search strategy Many heuristics developed, some of them generic 10/04/2017 A CP Tutorial: Hnich

ANY QUESTIONS?

Lot-sizing under demand uncertainty

Demand Uncertainty in Supply Chain Networks Inventories Production 10/04/2017 A CP Tutorial: Hnich Sales

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

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

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

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

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

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

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

ANY QUESTIONS?

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

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

Finding out more Books: Apt, K., Principles of Constraint Programming, Cambridge University Press, 2003. 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

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