10/7/2014 Constrainedness of Search Toby Walsh NICTA and UNSW tw.
Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.
-
Upload
crystal-hasler -
Category
Documents
-
view
220 -
download
4
Transcript of Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.
![Page 1: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/1.jpg)
Non-binary constraints: modelling
Toby Walsh
Cork Constraint Computation Center
![Page 2: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/2.jpg)
Modelling case studies
• Golomb rulers Graceful graphs [Smith & Walsh
AAAI2000]
• Permutation problems Channelling
constraints [Walsh LPAR 2001]
![Page 3: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/3.jpg)
Golomb rulers
• Mark ticks on a ruler Distance between any two ticks (not just
neighbouring ticks) is distinct
• Applications in radio-astronomy, cystallography, … http://www.csplib.org/prob/prob006
![Page 4: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/4.jpg)
Golomb rulers
• Simple solution Exponentially long ruler Ticks at 0,1,3,7,15,31,63,…
• Goal is to find minimal length rulers turn optimization problem into sequence of satisfaction
problemsIs there a ruler of length m?Is there a ruler of length m-1?….
![Page 5: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/5.jpg)
Optimal Golomb rulers
• Known for up to 23 ticks• Distributed internet project to find large rulers
0,1
0,1,3
0,1,4,6
0,1,4,9,11
0,1,4,10,12,17
0,1,4,10,18,23,25
Solutions grow as approximately O(n^2)
![Page 6: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/6.jpg)
Modelling the Golomb ruler
• Variable, Xi for each tick
• Value is position on ruler
• Naïve model with quaternary constraints For all i>j,k>l>j |Xi-Xj| \= |Xk-Xl|
![Page 7: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/7.jpg)
Problems with naïve model
• Large number of quaternary constraints O(n^4) constraints
• Looseness of quaternary constraints Many values satisfy |Xi-Xj| \= |Xk-Xl| Limited pruning
![Page 8: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/8.jpg)
A better non-binary model
• Introduce auxiliary variables for inter-tick distances Dij = |Xi-Xj| O(n^2) ternary constraints
• Post single large non-binary constraint alldifferent([D11,D12,…]). Tighter constraints and denser constraint graph
![Page 9: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/9.jpg)
Other modeling issues
• Symmetry A ruler can always be reversed! Break this symmetry by adding constraint:
D12 < Dn-1,n Also break symmetry on Xi
X1 < X2 < … Xn Such tricks important in many problems
![Page 10: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/10.jpg)
Other modelling issues
• Additional (implied) constraints Don’t change set of solutions But may reduce search significantly
E.g. D12 < D13, D23 < D24, …
E.g. D1k at least sum of first k integers
• Pure declarative specifications are not enough!
![Page 11: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/11.jpg)
Solving issues
• Labeling strategies often very important Smallest domain often good idea Focuses on “hardest” part of problem
• Best strategy for Golomb ruler is instantiate variables in strict order Heuristics like fail-first (smallest domain) not
effective on this problem!
![Page 12: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/12.jpg)
Experimental results
Runtime/sec Naïve model Alldifferent model
8-Find 2.0 0.1
8-Prove 12.0 10.2
9-Find 31.7 1.6
9-Prove 168 9.7
10-Find 657 24.3
10-Prove > 10^5 68.3
![Page 13: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/13.jpg)
Model (re)formulation
• Can we automate the process of refining and improving a model? Identify and breaking
symmetries Inferring implied
constraints …
CGRASS proof planner hopes to do this!
![Page 14: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/14.jpg)
The `Introduce` Method
Preconditions1. Exp occurs more than once in the constraint set.2. someVariable = Exp not already present.Post-conditions1. Generate new var, x, domain defined by Exp.2. Add constraint: x = Exp.
Motivation: solver propagates through newly introduced variable
![Page 15: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/15.jpg)
Other automatic methods
• Symmetry identification and removal Order ticks
• Variable elimination Generalization of Gaussian
elimination
• Automatically turns naïve Golomb model into a reasonable one!
![Page 16: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/16.jpg)
Something to try at home?
• Circular (or modular) Golomb rulers Inter-tick distance
variables more central, removing rotational symmetry?
• 2-d Golomb rulers
All examples of “graceful” graphs
![Page 17: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/17.jpg)
Summary
• Benefits of non-binary constraints Compact, declarative models Efficient and effective constraint propagation
• Supported by many constraint toolkits alldifferent, atmost, cardinality, …
• Large space of models Non-binary constraints only make this worse? Automatic tools can help with model selection and
reformulation
![Page 18: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/18.jpg)
Summary (II)
• Modelling decisions: Auxiliary variables Implied constraints Symmetry breaking constraints
• More to constraints than just declarative problem specifications!
![Page 19: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/19.jpg)
Case study II: permutation problems
Wide variety of scheduling, assignment and routing problems involve finding a permutation Plus satisfying some
additional constraints
Illustrates some of the fundamental decisions that must be made when modelling!
![Page 20: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/20.jpg)
Modelling choices
• Need to decide variables, domains and constraints
• Often difficult choice for something even as basic as the decision variables?
E.g. consider scheduling the World Cup.
Are vars=games, vals=times
or vars=times, vals=games ?
![Page 21: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/21.jpg)
Permutation problems
• |vars|=|vals| each var has unique val
• many examples scheduling timetabling routing assignment problems
• permute vars for vals which do we choose?TSP problem = find permutation of cities
which makes a tour of minimum length
![Page 22: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/22.jpg)
Meta-motivation
• Methodology for comparing models based on definition of
constraint tightness
• Other applications comparing implied constraints impact of reformulation
![Page 23: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/23.jpg)
Comparing models
• Choice of model affects amount of constraint propagation tighter model more pruning and propagation
• Need dynamic tightness measure domains shrink as we descend down search tree other constraints may prune domains
![Page 24: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/24.jpg)
Constraint tightness
• Pruning depends on local consistency enforced higher consistencies will infer implied constraints
missing from looser models
• Introduce tightness measure: parameterized by level of consistency enforced considers domains changing in size
![Page 25: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/25.jpg)
Definition of tightness
• model 1 is as tight as model 2 wrt A-consistency iff
given any domains
model 1 is A-consistent -> model 2 is A-consistent
• written A1 A2
![Page 26: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/26.jpg)
How does this compare to the previous definition?
• Tightness measure introduced by Debruyne & Bessiere [IJCAI-97]
• A-consistency is tighter than B-consistency iff given any modelthe model is A-consistent -> the model is B-consistent
• We fix models but vary domains
![Page 27: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/27.jpg)
Properties of new ordering
• Partial ordering reflexive A1 A1 transitive A1 A2 & A2 A3 implies A1 A3
• Defined relations tighter A1 A2 iff A1 A2 & not A2 A1
equivalence A1 = A2 iff A1 A2 & A2 A1
incomparable A1 @ A2 iff neither A1 A2 nor A2 A1
![Page 28: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/28.jpg)
Further properties
• Monotonicity AC1u2 AC1 AC1n2
adding constraints can only tighten a model
• Fixed point AC1 AC2 implies AC1u2 = AC1
combining a looser model with a tighter model doesn’t help!
![Page 29: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/29.jpg)
Extensions
• Ordering extends to search algorithms E.g. MAC1 MAC2 iff, given any domains, MAC on
model 1 visits no more nodes than MAC on model 2 assume equivalent var and val ordering
Similar monotonicity and fixed point properties
• Ordering extends to different consistencies applied to the different models E.g. GAC1 AC2
![Page 30: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/30.jpg)
Permutation models
• primal model xi xj for all i,j
• primal alldiff model alldifferent(x1,x2,…)
• primal/dual models (dual) variables
associated with each (primal) value
“Modelling a Permutation Problem”, Barbara M Smith, ECAI'2000 Workshop on Modelling and Solving Problems with Constraints
![Page 31: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/31.jpg)
Primal model
• n primal variables each with n values
• O(n^2) binary constraints
xi xj
x5
x6
x1 x2
x3
x4
![Page 32: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/32.jpg)
Primal all-different model
• n primal variables each with n values
• one non-binary constraint
all-different(x1,x2,..)x6
x5 x4
x3
x2x1
![Page 33: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/33.jpg)
Primal/dual model
• n primal variables each with n values
• n dual variables one for each primal value each dual value associated
with a primal variable
• n^2 channelling constraints
xi=j iff dj=i
• no other constraints needed!
x5
x1
x2
x3
x4
d5
d1
d2
d3
d4
![Page 34: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/34.jpg)
Other reason to channel
• Channelling between models frequent modelling technique
• Some constraints easier to specify in one model
• Others easier to specify in a (dual) model
• Channelling maintains consistency between the 2 models
![Page 35: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/35.jpg)
Multiple permutation problems
• Some problems consist of several permutations order n quasigroup (or
Latin square) has 2n intersecting permuations each of size n
• Following results extend to such cases
![Page 36: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/36.jpg)
Some notation
BC bounds consistency AC arc consistency RPC restricted path consistency PIC path inverse consistency SAC singleton arc consistency ACPC strong path consistency GAC generalized arc consistency
↓increasingpruning
![Page 37: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/37.jpg)
Some notation
primal not equals primal alldiff c channelling constraints c channelling constraints & primal not equals c channelling constraints & primal alldiff c channelling constraints & primal/dual not equals...
![Page 38: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/38.jpg)
Theoretical results
![Page 39: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/39.jpg)
SAT models
• n Boolean vars, Xij true iff xi=j• primal SAT model
O(n) clauses, each var takes at least one val O(n^3) clauses, no primal var takes two vals O(n^3) clauses, no two primal vars take same val
• channelling SAT model no need for (dual) Boolean vars as Xij can be used again
[Gomes et al 2001] and [Bejar & Manya 2000] report promising experimental results using SAT models of permutation problems with the Davis Putnam (DP) tree search algorithm
![Page 40: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/40.jpg)
Theoretical results
MAC tighter than DP, DP as tight as FC
![Page 41: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/41.jpg)
Asymptotic results
• Tightness ordering reflects asymptotic cost E.g. GAC ACc AC
O(n^4) O(n^3) O(n^2)
In each case, using best known algorithm
Hence we need to run experiments to know if extra pruning is worth the cost!
![Page 42: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/42.jpg)
Experimental results
• [Smith 2000] reports promising results for MACc on Langford’s problem
• I studied 3 other permutation problems all interval series circular Golomb rulers quasigroups (Latin squares)
All 4 problems in www.csplib.org
![Page 43: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/43.jpg)
Experimental results
• using Sicstus FD constraint library channelling is a standard non-binary constraint
• MACc best on “looser” problems Langford’s problem, all interval series
• Maintaining GAC better on “tighter” problems circular Golomb rulers, mean (but not median)
quasigroup performance
![Page 44: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/44.jpg)
Extensions
• injective mappings more vals than vars, each var takes unique val can introduce dummy vars to make permutation
• channelling constraints useful in many other problems often (but not always) bijective propagate pruning rapidly between models
![Page 45: Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center.](https://reader036.fdocuments.net/reader036/viewer/2022081519/56649c9b5503460f94958920/html5/thumbnails/45.jpg)
Conclusions
• Many ways to model and solve even something as simple as a permutation problem Hard even to decide what are the variables!
• Theory and experiment needed to compare models properly Dominance/asymptotic results only take us so far
• Best model may not be a single model! Channel between two (or more?) models