1. Modelling Issues Modelling is more an art than a science! Choice - - PowerPoint PPT Presentation

1 modelling issues modelling is more an art than a science
SMART_READER_LITE
LIVE PREVIEW

1. Modelling Issues Modelling is more an art than a science! Choice - - PowerPoint PPT Presentation

1. Modelling Issues Modelling is more an art than a science! Choice of the Right Decision Variables Example: Alphametic problems, using backtracking with constraint propagation: For SEND + MORE = MONEY, the model without carry variables is


slide-1
SLIDE 1

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 1 of 29

  • 1. Modelling Issues

Modelling is more an art than a science!

Choice of the Right Decision Variables Example: Alphametic problems, using backtracking with constraint propagation:

  • For SEND + MORE = MONEY, the model without carry variables is more efficient:
  • nly 19 of 23 nodes of the search tree are visited, rather than 23 of 29 nodes.
  • For GERALD + DONALD = ROBERT, the model with carry variables is more efficient:
  • nly 791 of 869 nodes of the search tree are visited, rather than 13,795 of 16,651 nodes.

Choice of the Right (Combination of) Constraints Example: The allDifferent constraint vs the equivalent conjunction of disequality (≠) constraints:

  • For SEND + MORE = MONEY without carry variables, the same domain reduction is achieved.
  • The problem 〈allDifferent(x,y,z) ; x, y, z ∈{1,2}〉 is not hyper-arc-consistent,

whereas the equivalent problem 〈 x≠y≠z≠x ; x, y, z ∈{1,2}〉 is (hyper-)arc-consistent.

slide-2
SLIDE 2

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 2 of 29

Choice of the Right Search Procedure

  • Consider using a computationally more expensive dynamic variable-and-value ordering,

which takes into account the current state of the solver.

  • Use the first-fail principle to delay choice as long as possible:

To succeed, try first where you are most likely to fail. For instance, select the decision variable with the smallest current domain. Optionally break ties by selecting the decision variable that appears in the largest number of currently active constraints.

  • Consider selecting first a value, and then a variable whose current domain contains that value.

Rules of Thumb

  • The size of the search tree is a good measure of the complexity of the model.
  • Use few decision variables.
  • Use simple constraints with good solvers, especially global constraints.
  • Deploy constraint propagation techniques that require little preprocessing.
  • Avoid disjunctive constraints, as they often lead to large search trees.

Careful: These rules of thumb (of course) have their exceptions: It is important to empirically test several combinations of models and search procedures.

slide-3
SLIDE 3

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 3 of 29

  • 2. Reified Constraints

Definition: The reified constraint (or reification) of a primitive constraint c is the constraint c ⇔ B where B is a fresh Boolean decision variable, with truth represented by 1, and falsity by 0. Benefit: Possibly improved constraint propagation, when there are constraints on the introduced Boolean decision variables:

  • When the constraint c becomes satisfied (violated), its Boolean variable B can be set to 1 (0).
  • When the Boolean variable B is set to 1 (0), the constraint c (¬c) is added.

Benefit: Reified constraints are also useful for expressing cardinality (or multiplicity) constraints without recourse to disjunction. Example: Constraining two or three out of five given constraints ci to hold: c1 ⇔ B1 , c2 ⇔ B2 , c3 ⇔ B3 , c4 ⇔ B4 , c5 ⇔ B5 , 2 ≤ B1 + B2 + B3 + B4 + B5 ≤ 3 Example: See the implementation of soft constraints in Section 8 (on slide 28). Careful: Not all primitive constraints are reifiable.

slide-4
SLIDE 4

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 4 of 29

  • 3. Higher-Order Constraints

Definition: A higher-order term is an integer term referring to the truth of a constraint, where truth is represented by 1, and falsity by 0. Notation: We here wrap the embedded constraint into parentheses. Example: The higher-order term denotes the number of elements

  • f the array Series, which is indexed by the set Range, that are equal to a given element i.

Benefit: A higher-order term represents an implicit reification. Definition: A higher-order constraint is a constraint involving higher-order terms. Benefit: Higher-order constraints are useful for expressing cardinality / multiplicity constraints. Example: See the two models of the Warehouse Location problem in Section 5 (on slide 7 and 8). Example: See the model for the Magic Series problem in Section 6 (on slide 13). Series j [ ] i = ( )

j Range ∈∑

slide-5
SLIDE 5

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 5 of 29

  • 4. Redundant Decision Variables and Channelling Constraints

Definition: A redundant decision variable is a decision variable that represents information that is already represented by some other decision variable(s). Benefit: Some constraints may be easier to formulate, or may propagate better. Example: The reification of a constraint implicitly introduces a redundant decision variable. Definition: A channelling constraint is a constraint between mutually redundant decision variables establishing the consistency of their information. Benefit: Not all the decision variables need to be explicitly labelled during search. Example: The reification c ⇔ B channels between the decision variables of the constraint c and the Boolean decision variable B. Example: See the first model of the Warehouse Location problem in Section 5 (on slide 7). Example: See the redundant modelling of relation decision variables in Section 5 (on slide 11).

slide-6
SLIDE 6

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 6 of 29

  • 5. Matrix Modelling and Relational Modelling

Example: The Warehouse Location Problem A company considers opening warehouses on some candidate locations in order to supply its existing stores:

  • Each candidate warehouse has the same maintenance cost.
  • Each candidate warehouse has a supply capacity (the maximum number of stores it can supply).
  • The supply cost to a store depends on the warehouse.

The objective is to determine which warehouses to open, and which of them should supply the various stores, subject to the following constraints:

  • Each store must be supplied by exactly one opened warehouse.
  • Each opened warehouse supplies at most a number of stores equal to its capacity.

and cost function:

  • The sum of the actually incurred maintenance costs and supply costs is minimised.
slide-7
SLIDE 7

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 7 of 29

A First Matrix Model of the Warehouse Location Problem (wlocation.prj) (channelling constraint) Capacity: Berlin London Madrid Paris Rome (instance data) 1 4 2 1 3 SupplyCost: Berlin London Madrid Paris Rome Store 1 20 24 11 25 30 … … … … … … Supply: Store 1 Store 2 … Store 10 (decision variable) ∈Whs ∈Whs … ∈Whs OpenWhs ( ⊆ Whs): Berlin London Madrid Paris Rome (redundant variables) ∈{0,1} ∈{0,1} ∈{0,1} ∈{0,1} ∈{0,1} minimise SupplyCost[s,Supply[s]] OpenWhs[w]

w Whs ∈

MaintCost ⋅ +

s Stores ∈∑

subject to s Stores ∈ ∀ OpenWhs[Supply[s]] ⋅ 1 = and w Whs ∈ ∀ (Supply[s]=w)

s Stores ∈∑

Capacity[w] ≤ ⋅

slide-8
SLIDE 8

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 8 of 29

A Second Matrix Model of the Warehouse Location Problem (wlocation2.prj) Drop the matrix OpenWhs of redundant decision variables as well as the channelling constraint, and reformulate the second term of the cost function as the following third-order term: This model is an order of magnitude more efficient, in OPL on the considered instance data. Redundancy elimination may pay off, but it may just as well be the converse. But this is hard to guess, as human intuition may be weak here. Disadvantages of OPL (Matrix) Modelling – No set variables: need for 0/1-modelling of subsets. – No relation variables: only total-function variables (as matrices of decision variables); hence awkward formulation of constraints referring to their inverses, which are relations. – Frequent need for higher-order constraints. Supply[s]=w ( ) >

s Stores ∈∑

   

w Whs ∈

MaintCost ⋅

slide-9
SLIDE 9

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 9 of 29

Problem Statement Revisited, in Mathematical Terms:

  • The sought supply relationship is a total function (or: mapping)

from the set of stores into the set of candidate warehouses.

  • The set of warehouses to be opened is the range of that function.

A Relational Model of the Warehouse Location Problem This relational model can be implemented into various matrix models, not unlike the ones above. Relational models are more concise as well as easier to formulate, maintain, analyse, and verify, as there is a closer conceptual correspondence with the informal statement of the problem. Supply Stores Warehouses 1…1 0…sup minimise SupplyCost s w ( , )

s w ( , ) Supply ∈

Supply MaintCost ⋅ + such that w Warehouses ∈ ∀ Supply 1

w ( ) Capacity w ( ) ≤ ⋅

slide-10
SLIDE 10

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 10 of 29

Implementation of Relational Models (as Matrix Models) Decision variables of high-level abstract datatypes, such as relations, and the constraints thereon can be implemented in terms of the usual datatypes in CP, namely integers, lists, matrices, and sets. This implementation relationship is one-to-many. Example: A total function f : V → W can be represented by matrices: A[i]=j whenever f(i) = j B[i,j]=1 whenever f(i) = j A: v1 v2 … vm ∈W ∈W … ∈W B: w1 w2 … wn v1 ∈{0,1} ∈{0,1} … ∈{0,1} … … … … … … vm ∈{0,1} ∈{0,1} … ∈{0,1} B 1 j [ , ]

j 1…n ∈∑

1 = B m j [ , ]

j 1…n ∈∑

1 =

slide-11
SLIDE 11

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 11 of 29

i ∈C[j] whenever f(i) = j etc. Benefit: For different constraints on a relation variable r , different representations of r may lead to easier formulation or better propagation. Having redundant decision variables for r and linking them via channelling constraints such as ∀ i ∈ V: ∀ j ∈ W: A[i]=j ⇔ B[i,j]=1 may pay off, despite the increased numbers of decision variables and constraints. Expert modellers have a bag of tricks for high-level concepts, resulting in recurring low-level best-practice idioms that can be captured. Relational modelling need not result in an efficiency loss while solving: see the next slide. C: w1 w2 … wn ⊆V ⊆V … ⊆V …

slide-12
SLIDE 12

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 12 of 29

Efficiency of Model Implementations For a given solver and model, it is impossible to figure out which is the best implementation, as it varies with the instances of the problem. It would be interesting to automatically generate alternative implementations and figure out which one is the most suitable:

  • Heuristic approach, based on an analysis of the model constraints and on formalised insights

about when a (possibly redundant) representation of a high-level ADT is preferred, thereby automating current best practice and making it available to the non-expert (or lazy).

  • Empirical approach, based on training instances, so that the resulting program is only claimed

to be the most suitable for instances within the distribution underlying the training instances. In the extreme case where no training instances are provided, such a compiler would be non-deterministic, leaving the final choice to the human. Premise: Compilation time is irrelevant and will be recovered through many instance runs. Model Maintenance

  • Problem change: Maintenance is much easier with a high-level modelling language, as the

model is not encumbered by ADT representation details and efficiency-related formulations. Indeed, these issues are only dealt with during compilation into an implementation.

  • Instance distribution change: Maintenance is avoided by the envisaged compiler,

namely by providing a new set of training instances.

slide-13
SLIDE 13

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 13 of 29

  • 6. Implied Constraints and Redundant Constraints

Definition: An implied constraint logically follows from the problem constraints. Benefit: Constraint propagation may be improved, without losing any solutions. Example: Magic Series (magic2.mod) for the range 0…n−1, for instance (1,2,1,0) for n = 4: (implied constraint) (implied constraint) Benefit: For n = 80, only 7 backtracks instead of 302, and a 3 orders-of-magnitude speed-up. Definition: A redundant constraint is an implied constraint that does not improve propagation. Adding implied constraints is usually done manually. Doing so automatically is rather straightforward with standard automated theorem provers, so the goal (and largely open question) is to detect the non-redundant implied constraints. Series: 1 … n − 1 ∈ 0…n ∈ 0…n … ∈ 0…n i Range ∈ ∀ Series i [ ] Series j [ ] i = ( )

j Range ∈∑

= Series i [ ]

i Range ∈ ∑

n = Series i [ ] i ⋅

i Range ∈ ∑

n =

slide-14
SLIDE 14

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 14 of 29

  • 7. Breaking Symmetries

Definition: A symmetry is a bijection on values or decision variables that preserves solutions. Example: Graph Colouring (map.mod, mapgr.mod, and mapSym.pl): Use n colours to colour the vertices of a graph such that no two adjacent vertices have the same colour. A model assigning colours to the vertices has n! value symmetries because any permutation of the colours of a solution transforms that solution into another solution. The values (that is, the colours here) are not distinguished. See the remedy on slide 26. Example: Suppose a cardinality n subset of a given set has to be found. A model encoding the subset as a list of n distinct decision variables has n! variable symmetries because the order of the elements does not matter in a set, but does matter in a list. A remedy is to impose a < order across the list of decision variables. Difficulty: A solver may waste a lot of effort exploring symmetric assignments. Benefit: The breaking of symmetries may lose symmetric, that is uninteresting, solutions. Definition: A partial symmetry is a symmetry where only strict subsets of related values or decision variables are involved. Example: Partitioned Graph Colouring: The available colours are partitioned into subsets, such that only colours of the same subset are not distinguished.

slide-15
SLIDE 15

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 15 of 29

Example: Sports Schedule in Periods × Weeks → Teams × Teams for:

  • Teams = n
  • Weeks = n − 1
  • Periods = n / 2

subject to the following constraints:

  • Every team plays every other team once.
  • Every team plays exactly once per week.
  • Every team plays at most twice per period.

Intuitive idea for a matrix model and a solution for n = 8: Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Period 1 0 vs 1 0 vs 2 1 vs 5 2 vs 4 3 vs 6 3 vs 7 4 vs 7 Period 2 2 vs 3 1 vs 7 0 vs 6 5 vs 6 5 vs 7 1 vs 4 0 vs 3 Period 3 4 vs 5 3 vs 5 2 vs 7 0 vs 7 0 vs 4 2 vs 6 1 vs 6 Period 4 6 vs 7 4 vs 6 3 vs 4 1 vs 3 1 vs 2 0 vs 5 2 vs 5

slide-16
SLIDE 16

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 16 of 29

The periods, weeks, and teams of a sports schedule are not distinguished: (1) The periods (rows) can be permuted (variable symmetries). (2) The weeks (columns) can be permuted (variable symmetries). (3) The teams of any game can be permuted (variable symmetries). (4) The teams can be permuted (value symmetries). All these permutations do not affect whether any given assignment is a solution or not. Definition: A symmetry class (or orbit, in group theory) is an equivalence class of assignments under all the symmetries (including their compositions). In each orbit of assignments, it suffices to enumerate only one member during search. This may make a problem “more tractable”. Week 1 Week 2 Week 3 Week 4 Week 5 Week 6 Week 7 Period 1 0 vs 1 0 vs 2 1 vs 5 2 vs 4 3 vs 6 3 vs 7 4 vs 7 Period 2 2 vs 3 1 vs 7 0 vs 6 5 vs 6 5 vs 7 1 vs 4 0 vs 3 Period 3 4 vs 5 3 vs 5 2 vs 7 0 vs 7 0 vs 4 2 vs 6 1 vs 6 Period 4 6 vs 7 4 vs 6 3 vs 4 1 vs 3 1 vs 2 0 vs 5 2 vs 5

slide-17
SLIDE 17

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 17 of 29

Lexicographic Ordering Definition: A sequence X is lexicographically smaller than or equal to a sequence Y

  • f the same type T and the same size

if “X would precede Y in a dictionary that is based on a total order ≤ over T ”. Notation: X ≤ lex Y Example: [c,o,n,s,t,r,a,i,n,t] ≤ lex [c,o,n,s,t,r,u,c,t,s] because ‘a’ precedes ‘u’ in the alphabet. Example: [1,2,34,5,678] ≤ lex [1,2,36,45,78] because 34 ≤ 36 among the natural numbers. Example: Consider a type T of cardinality n and order ≤. Then: [x1, x2, x3, x4] ≤ lex [y1, y2, y3, y4] ≡ x1 ≤ y1 ∧ x1 = y1 → x2 ≤ y2 ∧ x1 = y1 ∧ x2 = y2 → x3 ≤ y3 ∧ x1 = y1 ∧ x2 = y2 ∧ x3 = y3 → x4 ≤ y4 ≡ x1 n3 + x2 n2 + x3 n1 + x4 n0 ≤ y1 n3 + y2 n2 + y3 n1 + y4 n0 The second, linear encoding of ≤ lex works fine for sequences of size s when ns is not too large;

  • therwise: the first, Boolean encoding may have to be performed.

The finite-domain solver of SICStus Prolog, for instance, has very efficient global constraints for the lexicographic ordering of (chains of) sequences of decision variables.

slide-18
SLIDE 18

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 18 of 29

Symmetry-Breaking via Constraints Added Before Search

Add (lexicographic) ordering constraints so that (ideally) each orbit has exactly one element. Example: Breaking all the variable symmetries of the matrix model for sports scheduling: (1) Every row is lexicographically smaller than or equal to (denoted ≤lex) the next, if any. (2) Every column is lexicographically smaller than or equal to the next, if any. (3) The first team of every game has a smaller number than the second team of the game. This breaks all the symmetries here because the matrix entries are all different. When lexicographically ordering a matrix along every dimension with non-distinguished indices:

  • No orbit is of size 0.
  • However, in general, not all orbits are of size 1, except if all the matrix values are distinct, etc.

Counterexample: Symmetric matrices with lexicographically ordered rows and columns: 0 0 1 0 1 1 1 0 0 swap rows 2 & 3 swap columns 1 & 2 0 0 1 0 1 0 1 0 1 → swap rows 1 & 2 swap columns 2 & 3 0 0 1 0 1 0 1 1 0 → ← ←

slide-19
SLIDE 19

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 19 of 29

The Crawford et al. Method for Breaking All the Symmetries (Proceedings of KR’96) Example: Consider a 2 × 3 matrix with total row and column symmetry: Group Sym of 12 symmetries (permutations): Cycle notation: (1,2,3)(4,5) denotes the function {x1→x2, x2→x3, x3→x1, x4→x5, x5→x4, x6→x6}. Permutation Name Order (1,2)(4,5) Pc12 2 (2,3)(5,6) Pc23 2 (1,4)(2,5)(3,6) Pr12 2 ( ) id 1 (1,6,2,4,3,5) Pδ 6 (1,5,3,4,2,6) Pσ 6 (1,4)(2,6)(3,5) Pα1 2 (1,5)(2,4)(3,6) Pα2 2 (1,6)(2,5)(3,4) Pα3 2 (1,3)(4,6) Pc13 2 (1,2,3)(4,5,6) Pc123 3 (1,3,2)(4,6,5) Pc132 3 x1 x2 x3 x4 x5 x6

slide-20
SLIDE 20

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 20 of 29

Illustration x1 x2 x3 x4 x5 x6 x3 x1 x2 x6 x4 x5 x6 x4 x5 x3 x1 x2 x4 x6 x5 x1 x3 x2 Pc132 Pα1 Pδ id

slide-21
SLIDE 21

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 21 of 29

Induced Symmetry-Breaking Constraints (SBCs) (1) Pick a variable ordering m of the matrix. (2) Add the constraint m ≤ lex σ (m) for each σ ∈Sym \ {id}. Example: Take m = (1,2)(4,5) x1 x2 x3 x4 x5 x6 ≤ lex x2 x1 x3 x5 x4 x6 (c12) (2,3)(5,6) x1 x2 x3 x4 x5 x6 ≤ lex x1 x3 x2 x4 x6 x5 (c23) (1,4)(2,5)(3,6) x1 x2 x3 x4 x5 x6 ≤ lex x4 x5 x6 x1 x2 x3 (r12) (1,6,2,4,3,5) x1 x2 x3 x4 x5 x6 ≤ lex x6 x4 x5 x3 x1 x2 (δ) (1,5,3,4,2,6) x1 x2 x3 x4 x5 x6 ≤ lex x5 x6 x4 x2 x3 x1 (σ) (1,4)(2,6)(3,5) x1 x2 x3 x4 x5 x6 ≤ lex x4 x6 x5 x1 x3 x2 (α1) (1,5)(2,4)(3,6) x1 x2 x3 x4 x5 x6 ≤ lex x5 x4 x6 x2 x1 x3 (α2) (1,6)(2,5)(3,4) x1 x2 x3 x4 x5 x6 ≤ lex x6 x5 x4 x3 x2 x1 (α3) (1,3)(4,6) x1 x2 x3 x4 x5 x6 ≤ lex x3 x2 x1 x6 x5 x4 (c13) (1,2,3)(4,5,6) x1 x2 x3 x4 x5 x6 ≤ lex x2 x3 x1 x5 x6 x4 (c123) (1,3,2)(4,6,5) x1 x2 x3 x4 x5 x6 ≤ lex x3 x1 x2 x6 x4 x5 (c132) x1 x2 x3 x4 x5 x6

slide-22
SLIDE 22

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 22 of 29

Internal Simplifications, Based on the Definition of ≤ lex Example: (1,3)(4,6) = (1,3)(2)(4,6)(5) induces [x1, x2, x3, x4, x5, x6] ≤ lex [x3, x2, x1, x6, x5, x4] ≡ (x1≤x3) ∧ (x1=x3 → x2≤x2) ∧ (x1=x3 ∧ x2=x2 → x3≤x1) ∧ (x1=x3 ∧ x2=x2 ∧ x3=x1 → x4≤x6) ∧ … ≡ (x1≤x3) ∧ (x1=x3 → x4 ≤ x6) ∧ … ≡ [x1, x4] ≤ lex [x3, x6] The elements at the positions corresponding to the last indices in each cycle can be deleted! (1,2)(4,5) x1 x4 ≤ lex x2 x5 (c12) (2,3)(5,6) x2 x5 ≤ lex x3 x6 (c23) (1,4)(2,5)(3,6) x1 x2 x3 ≤ lex x4 x5 x6 (r12) (1,6,2,4,3,5) x1 x2 x3 x4 x5 ≤ lex x6 x4 x5 x3 x1 (δ) (1,5,3,4,2,6) x1 x2 x3 x4 x5 ≤ lex x5 x6 x4 x2 x3 (σ) (1,4)(2,6)(3,5) x1 x2 x3 ≤ lex x4 x6 x5 (α1) (1,5)(2,4)(3,6) x1 x2 x3 ≤ lex x5 x4 x6 (α2) (1,6)(2,5)(3,4) x1 x2 x3 ≤ lex x6 x5 x4 (α3) (1,3)(4,6) x1 x4 ≤ lex x3 x6 (c13) (1,2,3)(4,5,6) x1 x2 x4 x5 ≤ lex x2 x3 x5 x6 (c123) (1,3,2)(4,6,5) x1 x2 x4 x5 ≤ lex x3 x1 x6 x4 (c132)

slide-23
SLIDE 23

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 23 of 29

Elimination of Logically Implied SBCs The first two SBCs logically imply the last three SBCs which can thus be eliminated:

  • The last three SBCs rule out some permutations of the three columns.
  • But c12 ∧ c23 imposes a particular permutation and also rules out those permutations.

In general:

  • An m × n matrix with total row and column symmetry has m! ⋅ n! symmetries.
  • There are (at least) m! - m + n! - n logically implied SBCs, due to the transitivity of ≤ lex .
  • Open question: When does a polynomial number of SBCs suffice

to break all, or most, symmetries (given the domain size)?! (1,2)(4,5) x1 x4 ≤ lex x2 x5 (c12) (2,3)(5,6) x2 x5 ≤ lex x3 x6 (c23) (1,3)(4,6) x1 x4 ≤ lex x3 x6 (c13) (1,2,3)(4,5,6) x1 x2 x4 x5 ≤ lex x2 x3 x5 x6 (c123) (1,3,2)(4,6,5) x1 x2 x4 x5 ≤ lex x3 x1 x6 x4 (c132)

slide-24
SLIDE 24

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 24 of 29

Contextual Simplifications in δ and σ Elimination of Domain-Dependent Implied SBCs (1,2)(4,5) x1 x4 ≤ lex x2 x5 (c12) (2,3)(5,6) x2 x5 ≤ lex x3 x6 (c23) (1,4)(2,5)(3,6) x1 x2 x3 ≤ lex x4 x5 x6 (r12) (1,6,2,4,3,5) x1 x2 x3 ≤ lex x6 x4 x5 (δ) (1,5,3,4,2,6) x1 x2 x3 x4 ≤ lex x5 x6 x4 x2 (σ) (1,4)(2,6)(3,5) x1 x2 x3 ≤ lex x4 x6 x5 (α1) (1,5)(2,4)(3,6) x1 x2 x3 ≤ lex x5 x4 x6 (α2) (1,6)(2,5)(3,4) x1 x2 x3 ≤ lex x6 x5 x4 (α3) Domain size c12 c23 r12 δ σ α1 α2 α3 2 Implied SBCs ✓ ✓ ✓ ✓ ✓ Minimum set ✗ ✗ ✗ ✗ Minimum set ✗ ✗ ✗ ✗ 3 Implied SBCs ✓ ✓ ✓ ✓ Minimum set ✗ ✗ ✗ ✗ ✗ ≥ 4 Implied SBCs Minimum set ✗ ✗ ✗ ✗ ✗ ✗ ✗ ✗

slide-25
SLIDE 25

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 25 of 29

Experimental Results Encouraging results even when only using row and column lexicographic ordering as SBCs, due to the action of the actual problem constraints. Example: Enumerating all the 3 × 3 matrices modulo total row and column symmetry, in the absence of any actual problem constraints:

  • 35 SBCs, of which 6 are implied constraints, by the transitivity of ≤ lex ;
  • 9 further implied SBCs, for domain sizes from 4 to at least 6, which can all be eliminated.

Run-times in seconds, under GNU Prolog, on a Sun SPARC Ultra station 10: with all the 35 constraints without 15 implied constraints before internal simplifications after internal simplifications domain size = 4 (8,240 matrices) Boolean ≤ lex 11.0” 5.8” 2.1” linear ≤ lex 8.3” 4.5” 1.6” domain size = 5 (57,675 matrices) Boolean ≤ lex 61.0” 31.8” 12.4” linear ≤ lex 49.6” 26.7” 10.0” domain size = 6 (289,716 matrices) Boolean ≤ lex 269.0” 139.0” 56.1” linear ≤ lex 227.0” 122.6” 46.5”

slide-26
SLIDE 26

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 26 of 29

Symmetry-Breaking During Search

Symmetry-breaking without adding constraints before search:

  • Via heuristics.

(beyond the scope of this course)

  • Via the addition of constraints by the search procedure.

(beyond the scope of this course)

  • Via a problem-specific search procedure.

(see below) Careful: Symmetry-breaking methods rarely compose without losing orbits. Example: Graph Colouring (map.mod, mapgr.mod, and mapSym.pl): Use n colours to colour the vertices of a graph such that no two adjacent vertices have the same colour. Given a partial colouring with i colours, only i+1 colours need to be considered for the next vertex v:

  • Colour v with one of the i colours that are already used.
  • Colour v with an arbitrary colour that is not already used.

In practice: The already used colours are 1…i, so that the new colour to be considered is i+1. This breaks all the n! value symmetries in constant time and space.

slide-27
SLIDE 27

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 27 of 29

Symmetry Detection and Introduction

Detecting symmetries is graph-isomorphism complete in general. Symmetries are often introduced while modelling in today’s rather low-level CP languages. Example: A Steiner triple system has a set X of v points and a set B of 3-element subsets Bi of X, called triples, such that every pair of distinct elements of X appears in exactly one triple Bi of B. Inherent symmetries:

  • Any permutation of X gives rise to a symmetry (value symmetries).

Introduced symmetries by matrix modelling:

  • The elements of each triple Bi are indistinguishable (variable symmetries).
  • The triples Bi are indistinguishable (column variable symmetries).

In our example, this introduces 3!7 ⋅ 7! = 1,410,877,440 symmetries… B1 B2 B3 B4 B5 B6 B7 Element 1 1 2 3 4 5 6 7 Element 2 2 3 4 5 6 7 1 Element 3 4 5 6 7 1 2 3 A matrix model and a solution for |X| = |B| = 7 1 2 6 3 4 7 5

slide-28
SLIDE 28

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 28 of 29

  • 8. Over-Constrained Problems

Definition: A problem is over-constrained when its formalisation leads to an inconsistent model. Remedies (unless the problem cannot be modified):

  • Drop some constraints.
  • Relax the requirement that all the constraints must be satisfied:

+ Declare some of the constraints as hard constraints, which must be satisfied. + Declare the other constraints as soft constraints, which may be violated. + Define the (possibly additional) objective regarding the soft constraints. For example: Maximise the number of the actually satisfied soft constraints. This can be done via reifying the soft constraints and maximising the sum of the introduced Boolean decision variables, provided truth is represented by a positive integer. More generally: Assign numeric utilities to the soft constraints, and maximise the sum of the utilities of the actually satisfied soft constraints.

slide-29
SLIDE 29

Pierre Flener, IT Dept, Uppsala University Constraint Technology: Modelling Slide 29 of 29

  • 9. Exercises

Model the following problems in several ways in a language of your choice, so as to experiment with the concepts of these two modelling lectures: (1) Sports Schedule (on slide 15) (2) Steiner Triple Systems (on slide 27) The number of triples is b = v (v −1) / 6, so that v mod 6 must be 1 or 3. An implied constraint is that each point occurs in exactly r = (v −1) / 2 triples. In addition to the model on slide 27, model this problem with a v × b matrix of 0/1 integers, such that the sum of each column is 3. For v =3, there is one non-isomorphic solution, namely {{1,2,3}}. For v =7, there is one non-isomorphic solution, namely the one on slide 27. For larger v, and more details, see mathworld.wolfram.com/SteinerTripleSystem.html. Careful: Without proper care, your model may be very slow…