450 likes | 477 Views
Non-binary constraints: modelling. Toby Walsh Cork Constraint Computation Center. Modelling case studies. Golomb rulers Graceful graphs [Smith & Walsh AAAI2000] Permutation problems Channelling constraints [Walsh LPAR 2001]. Golomb rulers. Mark ticks on a ruler
E N D
Non-binary constraints: modelling Toby Walsh Cork Constraint Computation Center
Modelling case studies • Golomb rulers • Graceful graphs • [Smith & Walsh AAAI2000] • Permutation problems • Channelling constraints • [Walsh LPAR 2001]
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
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 problems Is there a ruler of length m? Is there a ruler of length m-1? ….
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)
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|
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
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
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
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!
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!
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!
The `Introduce` Method Preconditions • Exp occurs more than once in the constraint set. • someVariable = Exp not already present. Post-conditions • Generate new var, x, domain defined by Exp. • Add constraint: x = Exp. Motivation: solver propagates through newly introduced variable
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!
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
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
Summary (II) • Modelling decisions: • Auxiliary variables • Implied constraints • Symmetry breaking constraints • More to constraints than just declarative problem specifications!
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!
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 ?
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
Meta-motivation • Methodology for comparing models • based on definition of constraint tightness • Other applications • comparing implied constraints • impact of reformulation
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
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
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
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 model the model is A-consistent -> the model is B-consistent • We fix models but vary domains
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 A2A1
Further properties • Monotonicity • AC1u2AC1AC1n2 adding constraints can only tighten a model • Fixed point • AC1AC2impliesAC1u2 = AC1 combining a looser model with a tighter model doesn’t help!
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
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
Primal model • n primal variables • each with n values • O(n^2) binary constraints xi xj x1 x2 x6 x3 x4 x5
Primal all-different model • n primal variables • each with n values • one non-binary constraint all-different(x1,x2,..) x1 x2 x6 x3 x5 x4
Primal/dual model x1 d1 • 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! x2 d2 x3 d3 x4 d4 x5 d5
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
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
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 increasing pruning
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 ...
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
Theoretical results MAC tighter than DP, DP as tight as FC
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!
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
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
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
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