Constraint Propagation and Implied Constraints in Constraint Solving, Study notes of Computer Numerical Control

The concept of constraint propagation in constraint solving, focusing on the incompleteness of arithmetic constraint propagation and the benefits of enforcing generalized arc consistency (gac) on conjunctions of constraints. The text also introduces global constraints and their role in replacing sets of constraints, as well as the use of auxiliary variables and implied constraints. Examples of different types of implied constraints and methods for deriving them automatically.

Typology: Study notes

2010/2011

Uploaded on 09/10/2011

myohmy
myohmy 🇬🇧

4.8

(10)

297 documents

1 / 40

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Handbook of Constraint Programming
Francesca Rossi, Peter van Beek, Toby Walsh
Elsevier
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28

Partial preview of the text

Download Constraint Propagation and Implied Constraints in Constraint Solving and more Study notes Computer Numerical Control in PDF only on Docsity!

Handbook of Constraint Programming

Francesca Rossi, Peter van Beek, Toby Walsh

Elsevier

Part I

First part

Handbook of Constraint Programming 3 Francesca Rossi, Peter van Beek, Toby Walsh ©c 2006 Elsevier All rights reserved

Chapter 1

Modelling

Barbara M. Smith

Constraint programming can be a successful technology for solving practical problems; however, there is abundant evidence that how the problem to be solved is modelled as a Constraint Satisfaction Problem (CSP) can have a dramatic effect on how easy it is to find a solution, or indeed whether it can realistically be solved at all. The importance of modelling in constraint programming has long been recognized e.g. in invited talks by Freuder [14] and Puget [34].

In this chapter, it will be assumed that the problem to be solved can be represented as a CSP whose domains are finite; infinite domains are discussed in Chapter 16, “Continuous and Interval Constraints”. In most of the examples, the variable domains will be sets of integers; see Chapter 17, “Constraints over Structured Domains”, for more on set variables and other variable types.

A complicating factor in modelling is the interaction between the model, the search algorithm and the search heuristics. To simplify matters, it will be assumed that, having modelled the problem of interest as a CSP, the CSP will be solved using a constraint solver such as ILOG Solver, ECLiPSe, Choco, SICStus Prolog, or the like. The default com- plete search algorithms provided by these solvers are sufficiently similar that they provide a common context for discussing modelling. Furthermore, they are designed to solve large problems of practical significance, and for such problems, it is worth the effort of develop- ing the best model of the problem that we can find. Some of what follows will also apply to other search techniques such as local search (covered in Chapter 8) or to other com- plete search algorithms, but much will not, because the search algorithm has a profound influence on modelling decisions.

In this chapter, it will be assumed that the problem to be solved is well-defined; al- though eliciting a correct and full problem description can be a significant proportion of the problem-solving effort, it will be assumed here that that step has been done. It will also be assumed that the problem does not involve preferences or uncertainty, which are covered in Chapters 9 and 21.

4 1. Modelling

1.1 Preliminaries

In this section, the concepts needed in the rest of the chapter are defined. A Constraint Satisfaction Problem (CSP) is a triple 〈X, D, C〉 where: X is a set of variables , {x 1 , ..., xn}; D is a set of domains , D 1 , ..., Dn associated with x 1 , ..., xn re- spectively; and C is a set of constraints. Each constraint c ∈ C is a pair c = 〈σ, ρ〉 where σ, the constraint scope , is a list of variables, and ρ, the constraint relation , is a subset of the Cartesian product of their domains. The domain of a variable is the set of possible values that can be assigned to it. In this chapter, it will be assumed that the domain of a variable is a finite set. An assignment is a pair (xi, a), which means that variable xi ∈ X is assigned the value a ∈ Di. A^ compound assignment^ is a set of assignments to distinct variables in^ X. A complete assignment is a compound assignment to all variables in X. The relation of a constraint c = 〈σc, ρc〉 specifies the acceptable assignments to the variables in its scope. That is, if the constraint scope σc is {xi 1 , xi 2 , ..., xik } and 〈a 1 , a 2 , ..., ak〉 ∈^ ρc, the compound assignment assigning^ ai to^ xik ,^1 ≤^ i^ ≤^ k, is an acceptable assignment; we say that the assignment satisfies the constraint c. A solution to the CSP instance 〈X, D, C〉 is a complete assignment such that for every constraint c ∈ C, the restriction of the assignment to the scope σc satisfies the constraint. The relation of a constraint may be specified extensionally by listing its acceptable (satisfying) tuples, or intensionally by giving an expression involving the variables in the constraint scope such as x < y from which it can be determined whether or nor a given tuple satisfies the constraint. The arity of a constraint is the size of its scope. A unary constraint is defined on a single variable, a binary constraint on two variables. There is no requirement that different constraints must have different scopes. Given a constraint c = 〈σc, ρc〉, the projection of c onto τ ⊂ σc is a constraint c′^ whose scope is τ and whose relation is the set of tuples derived by taking each tuple in ρ (^) c and selecting only those components corresponding to the variables in τ. Many forms of consistency have been defined for CSPs and individual constraints. Here, only those commonly used by constraint solvers are defined. Consistency and con- straint propagation are covered fully in Chapter 3. A binary constraint is arc consistent if for every value in the domain of either variable, there exists a value in the domain of the other such that the pair of values satisfies the constraint. A non-binary constraint is generalized arc consistent or hyper-arc consistent iff for any value for a variable in its scope, there exists a value for every other variable in the scope such that the tuple satisfies the constraint. Domain propagation on a constraint removes unsupported values (i.e. values which cannot be extended to a pair of tuple of values satisfying the constraints) from the domains of the variables in its scope until the constraint is (generalized) arc consistent. A constraint c on variables with ordered domains (such as integers) is bounds consis- tent if for every variable x in its scope, there exists a value dj for every other variable xj ( 1 ≤ j ≤ k) in the scope of c, with minDj ≤ dj ≤ maxDj , such that the com- pound assignment {(x, l), (x 1 , d 1 ), ..., (xk , dk)} satisfies c, where l is the minimum of the domain of x, and similarly, values d′ j can be found with minDj ≤ d′ j ≤ maxDj , such that {(x, u), (x 1 , d′ 1 ), ..., (xk , d′ k)} satisfies c, where u is the maximum of the domain of x. (For arithmetic constraints, the values dj , d′ j can be real values rather than integers.)

6 1. Modelling

{xi = 1, xi = 0} (when the variables are Boolean); {xi ≤ a, xi > a} (domain split- ting); {xi = v 1 , xi = v 2 , ..., xi = vk }, where v 1 , v 2 , ..., vk are the values currently available in Di (k-way branching). Choices can involve more than one variable, e.g. {xi ≤ xj , xi > xj }; this is common in scheduling, for instance, where the choices might represent the two possible orders for the starting times of two activities (see Chapter 22). Although all these types of choice, and more, are possible, in the examples quoted in this chapter binary branching has been used. The search pursues each choice in turn, first adding the constraint defining the choice to the existing constraints and propagating it, until local consistency is restored in the resulting subproblem. Typically, each type of constraint in the problem has an associ- ated propagation algorithm, achieving the level of consistency specified for that constraint. Constraint propagation continues until no further propagation can be done, and every con- straint is again in its target state of consistency. Given a target level of consistency for each constraint in C, the CSP 〈X, D, C〉 is locally consistent if every constraint achieves its tar- get consistency level. If, at any stage during the search, constraint propagation results in an empty domain for some future (not-yet-assigned) variable, the search backtracks, restoring the domains to their state before the last choice was made, and exploring another of the choices created at the last choice point; if no further choices remain, the search backtracks to a previous choice point, and so on, until either a solution is found or all possible choices have been explored. This form of search is used by default in commercial constraint solvers. It has a pro- found influence on the modelling process, because in taking many modelling decisions, the user needs to consider their effect on constraint propagation. Typically, constraint solvers will enforce arc consistency (AC) on some, but not all, binary constraints and bounds consistency (BC) on arithmetic constraints. They will not usually maintain generalized arc consistency (GAC) on non-binary constraints, except for global constraints for which an efficient propagation algorithm exists. For some global constraints, the user may be able to choose the level of consistency to be maintained. For some complex constraints, the default may be to do very little consistency checking; the propagation algorithm may take action only when all but one or two of the variables in its scope have been instantiated. These decisions in designing constraint solvers stem from a trade-off between the time and space required to maintain generalized arc consistency on all constraints and the reduc- tion in search that could result. Puget has explained the decision to maintain only bounds consistency on arithmetic constraints in ILOG Solver by saying: “Solver is a compro- mise between efficiency and completeness...In the example... [of constraint propagation of arithmetic constraints] the incompleteness comes from the fact that arithmetic expressions only propagate bounds.. This is an example of the choice we made. Propagating holes in expressions would require much more memory and time than the current implementation. From tests made on a very large set of examples, we found that the current compromise is by far better.” Even if we start from the assumption that the CSP will be solved using this general search algorithm, the form of the choices made at choice points, as well as the specific variable and value choices, will also affect the solution time. Beacham, Chen, Sillito and van Beek [2] investigate the interaction between constraint models, search algorithms and search heuristics, using crossword puzzle problems. They compare three constraint models and two well-known search heuristics (minimum domain

B. M. Smith 7

and domain/degree); the search algorithms are forward checking and a search algorithm that maintains generalized arc consistency, with three different ways of enforcing GAC. They conclude that the three choices of model, algorithm and heuristic interact, and that for the most efficient problem solving, none of the decisions can be made independently of the others. It is a moot point whether the choice of search heuristics is part of modelling or not. It is certainly true that the performance of a model will be affected by the search heuristics, but for the purposes of this chapter, choosing the search heuristics will be excluded. However, for some types of model, there is a choice of which of the variables in the model should be used to drive the search, i.e. which variables should participate in choice points, and this will be considered as part of modelling.

1.4 Viewpoints

Different models of a problem P may result from viewing the problem P from different angles or perspectives. The term viewpoint was introduced informally by Geelen [19], in discussing permutation problems, and was subsequently adopted and formally defined by Law and Lee [29]. A viewpoint is a pair 〈X, D〉, where X = {x 1 ,... , xn} is a set of vari- ables, and D is a set of domains; for each xi ∈ X, the associated domain Di is the set of possible values for x. It must be possible to ascribe a meaning to the variables and values of the CSP in terms of the problem P , and so to say what an assignment in the viewpoint 〈X, D〉 is intended to represent in terms of P. The complete assignments defined by the viewpoint are intended to include all possible solutions of P. The constraints must then en- sure that every solution to the CSP is a valid solution to P , and so are largely determined by that requirement. Hence, it is different viewpoints that give rise to fundamentally different models of a problem. In principle, the values in the domain can be of any type. In practice, the types com- monly supported by constraint solvers include integers, Booleans (perhaps only as a sub- type of integers) and sets of integers. Other types have been proposed, e.g. multisets and tuples; constraint solvers may directly support these, or provide facilities to allow new types to be defined. Some of what follows may also apply to modelling using real-valued variables, and since the domains of integer variables are sometimes represented as inter- vals, the boundary can be blurred. Except for some very small problems, the variables of a CSP are usually implemented using some data structure such as a list or an array. Flener, Frisch, Hnich, Kiziltan and Walsh [12] suggest that matrix models , based on matrices of variables, are a natural way to model many problems; indeed, almost all the examples given in this chapter use 1- or 2-dimensional matrices of variables. For some applications, other structures are important; for instance, models based on graphs are used in the network applications discussed in Chapter 25. There are usually different viewpoints that could be chosen in modelling a problem. Although viewpoints can be combined, as will be described in section 1.9, it will be as- sumed for now that only one will be used. Having chosen a viewpoint, the next step is to express the constraints to ensure that the solutions to the CSP are correct, i.e. are solutions to P. However, although correctness is a minimum requirement, it is not sufficient if we are also concerned with how efficiently the CSP can be solved. A good rule of thumb

B. M. Smith 9

(x + y = z) and c 3 ≡ (2y = z), where x, y and z are integer variables. If C = {c 1 , c 2 } and C′^ = {c 1 , c 3 }, C and C′^ are equivalent, in the sense that they have the same solutions. However, if C and C ′^ are made locally consistent, then in C ′, the domain of z (using AC) or its upper and lower bounds (using BC) will be even integers, but this is not necessarily true of C. Unfortunately, to arrive at a good model of P , it is essential to be aware of the range of constraints supported by the constraint solver and the level of consistency enforced on each and to have some idea of the complexity of the corresponding propagation algorithms. This is, of course, a long way from the declarative ideal. In this section, some of the choices available when writing constraints are discussed.

1.5.1 Combining Constraints

Combining constraints with the same scope can be a way of expressing them more con- cisely. The conjunction of two constraints with the same scope allows only the tuples that are allowed by both. Enforcing the same level of local consistency on a conjunction c 1 ∧c 2 as on c 1 and c 2 separately will remove at least as many domain values. However, it may or may not reduce the run-time, depending on how time-consuming it is to enforce local consistency on the conjunction and on the separate constraints. An example can be found in the n-queens problem. Using the first viewpoint listed earlier (the standard CSP model for this problem), the variables x 1 , x 2 , ..., xn representing rows 1 to n of the board, and the values are { 1 , 2 , ..., n}, representing the columns. The rule that two queens cannot be on the same column or diagonal can most simply be written using more than one constraint between each pair of variables x (^) i and xj , i < j. For instance:

  • xi = xj
  • xi − xj = j − i
  • xj − xi = j − i

Figure 1.1 shows a state that might be arrived at during search, when n = 6. Two variables, x 1 and x 2 , have already been assigned, and the crossed squares are no longer available, because queens placed there would conflict with the two already placed; the corresponding values will have been removed from the domains of the remaining variables x 3 , x 4 , x 5 , x 6. A queen cannot now be placed in row 5, column 3, because it would conflict

Q

Q

Figure 1.1: A search state in the 6-queens problem

10 1. Modelling

with both remaining places for a queen in the 3rd row. However, the three constraints between x 3 and x 5 are arc consistent; the value 3 for x 5 is supported by the value 1 for x 3 as far as the first constraint is concerned, and by the value 3 for x 3 as far as the second constraint is concerned. If the conjunction of the three constraints were expressed as a single constraint, domain propagation would delete 3 from the domain of x 5. (However, since the conjunction is unlikely to be expressible as a single constraint using the standard constraints provided by constraint solvers, it might require writing a special constraint or forcing AC in some other way. Simply writing a single constraint as a conjunction of the separate constraints will not guarantee that the solver will enforce GAC on it, and it may in fact do less consistency checking than on the separate constraints.) Katsirelos and Bacchus [28] discuss improving constraint propagation by enforcing GAC on conjunctions of constraints, rather than the individual constraints. If c 1 and c 2 are two constraints in a CSP, domain propagation on their conjunction c 1 ∧ c 2 removes at least as many domain values as domain propagation on c 1 and c 2 separately. If the scopes of c 1 and c 2 are disjoint, then domain propagation on the conjunction is equivalent to domain propagation on the separate constraints, but the larger the overlap in the scopes, the larger the potential domain pruning from conjoining the constraints. Katsirelos and Bacchus use Bessi`ere and R´egin’s GAC-schema algorithm [4] in their experiments: for that algorithm, if the scope of c 1 is a subset of the scope of c 2 , it is less time-consuming to enforce GAC on the conjunction than on the individual constraints. They propose, as a heuristic, to combine constraints which share all or most of their variables. They use the Golomb ruler problem, discussed in more detail in section 1.9, as an example. They model the problem as a CSP by using the positions of the m ‘ticks’ on the ruler as the variables x 1 , ..., xm. The constraints are that |xj − xi|  = |xl − xk |, for 1 ≤ i, j, k, l ≤ m. In this model, there are seven constraints of this kind over any set of four variables (four quaternary and three ternary). They show that combining the quaternary and ternary constraints on each set of four such variables reduces the number of backtracks slightly and the run-time a lot, compared to using the individual constraints; they maintain GAC on constraints in either case. (Note that this is not the model usually used for the Golomb ruler problem, so that their results are not comparable with others.)

1.5.2 Eliminating Variables

Harvey and Stuckey [22] give a number of theorems on rewriting linear constraints and how bounds propagation or domain propagation will be affected. For instance, one theorem concerns using a two-variable linear equation to substitute for one of these variables in a linear constraint: suppose c 1 ≡ (

∑n i=1 aixi^ op^ d), where op^ ∈ {=,^ ≤,^ =}^ and^ c^2 ≡ (bj xj + bkxk = e), j = k, bj = 0, bk = 0. Let c 3 be the constraint resulting from using c 2 to remove xj in c 1. Then bounds propagation on {c 3 , c 2 } is stronger than bounds propagation on {c 1 , c 2 }. (i.e. each variable domain in the first case is a subset of its domain in the second case). The same is true for domain propagation.

1.5.3 Global Constraints

Constraint solvers provide a range of global constraints , developed to replace particular sets of constraints that occur frequently. Global constraints are the subject of Chapter 7.

12 1. Modelling

is { 1 , .., 52 }, representing the cards, where the values 1 to 13 represent the ace to king of spades respectively, 14 to 26 represent the ace to king of hearts, and so on. To ensure a correct sequence, there must be a binary constraint between x (^) i and xi+1 for 1 ≤ i ≤ 51 ; for instance, if xi is assigned the value 15 (representing the two of hearts), the possible values for xi+1 are 1, 3, 14, 16, 27, 29, 40, 42, representing the aces and threes. The constraint is expressed extensionally by listing the possible values for xi+1 for each possible value of xi, using the table constraint in ILOG Solver, which maintains AC on the constraint.

1.5.5 Reified Constraints and Meta-constraints

A reified constraint associates a 0/1 variable x with a constraint c, so that x takes the value 1 if the constraint c is satisfied and 0 otherwise. More or less equivalently, in terms of expressivity, a meta-constraint is a constraint over constraints. Fernandez and Hill [11] discuss representing a self-referential puzzle introduced by Henz [23] in a variety of con- straint programming languages, using reified constraints and meta-constraints. More significantly, they can be used to express disjunctions of constraints. For instance, the condition that constraint c 1 or constraint c 2 (or both) must be satisfied can be expressed by associating the constraints with the variables x 1 and x 2 respectively and adding the constraint that x 1 + x 2 ≥ 1. Van Hentenryck and Deville [48] introduced the cardinality operator to express such disjunctive conditions; it allows upper and lower bounds to be stated on the number of constraints in a set that must be satisfied. Of course, it is not sufficient simply to allow disjunctive conditions to be expressed; changes to the domains of the variables involved must also be propagated efficiently. The implementation of reified constraints in constraint logic programming is discussed in Chapter 12.

1.6 Auxiliary Variables

In the last section, different ways of writing constraints on the variables in the chosen viewpoint were discussed. However, more choices are available, and the potential for more efficient models, if other variables can be introduced. Auxiliary variables are variables introduced into a model, either because it is difficult to express the constraints at all in terms of the existing variables, or to allow the constraints to be expressed in a form that would propagate better, i.e. lead to more domain reductions. An early example appears in a paper on the car sequencing problem (problem 1 in CSPLib) by Dincbas, Simonis and van Hentenryck [9]. A number of cars are to be made on a production line: each of them may require one or more options which are installed at different stations on the line. The option stations have lower capacity than the rest of the production line, e.g. a station may be able to cope with at most one car out of every two. The cars are to be arranged in a production sequence so that these capacities are not exceeded. In [9], the initial viewpoint has variables si, 1 ≤ i ≤ n, where n is the number of cars to be produced, and therefore the length of the production sequence. The value of s (^) i represents the car to be produced in position i in the sequence, or more precisely the class of car, since cars requiring the same set of options can be considered as identical. It is straightforward to express some of the constraints required to model the problem in this viewpoint, for instance, that the number of variables assigned a specific value is

B. M. Smith 13

equal to the number of cars in the corresponding class. However, the option capacities are difficult to express using these variables alone. Dincbas et al. introduce auxiliary Boolean variables oij , 1 ≤ i ≤ n, 1 ≤ j ≤ m, such that oij = 1 iff the car in the ith slot in the sequence requires option j. The constraints expressing the option capacities are expressed in terms of these variables; suppose that the capacity of option 1 is one car in every two. Then the capacity of the option can be enforced using the constraints:

oi, 1 + oi+1, 1 ≤ 1 for 1 ≤ i < n

Constraints are also needed to express the relationship between the auxiliary vari- ables and the original variables. In this case, this could be done by the constraints o (^) ij = λsi ,j , 1 ≤ i ≤ n, 1 ≤ j ≤ m, where the constant λkj = 1 iff car class k requires option j. Usually, auxiliary variables are not sufficient to define a viewpoint, i.e. it would not be possible to build a model of the problem using only the auxiliary variables. However, the auxiliary variables in the car sequencing problem could constitute a viewpoint; every valid production sequence can be specified as a complete assignment to these variables. It is sometimes worthwhile to use auxiliary variables as search variables, alongside the original variables. An example occurs in a network design problem arising from the de- ployment of synchronous optical networks (SONET) [43]. The network contains a number of client nodes and a number of SONET rings. A SONET ring joins a number of nodes; a node is installed on a ring using an add-drop multiplexer (ADM). There are known de- mands (in terms of numbers of channels) between pairs of nodes; in a simplified version of the problem, the level of demand is ignored, but if there is a traffic demand between two nodes, there must be a ring that they are both installed on. Each node can be installed on more than one ring, and there is a maximum number of nodes that can be installed on each ring. The objective is to minimise the total number of ADMs required, while satisfying all the demands. The viewpoint used in [43] has variables xik , 1 ≤ i ≤ n, 1 ≤ k ≤ m, where n is the number of nodes and m is the number of available rings. x (^) ik = 1 if node i is assigned to ring k, 0 otherwise. A number of auxiliary variables are introduced, representing for instance the number of rings that each node is on. It was found to be a successful search strategy to assign this last set of variables first, before assigning the variables xik. In terms of the underlying problem, although deciding how many rings each node is not sufficient to specify the network, it greatly simplifies the remaining problem of deciding which rings each node is on. Note that if the auxiliary variables would constitute a viewpoint in their own right, and we assign values to these variables as well as the viewpoint variables, the resulting model might be more appropriately considered as combining two viewpoints, as in section 1.9.

1.7 Implied constraints

Implied constraints, also called redundant constraints, are constraints which are implied by the constraints defining the problem. They do not change the set of solutions, and hence are logically redundant. The aim in adding implied constraints to the CSP is to reduce the search effort to solve the problem.

B. M. Smith 15

valid constraints. Overall, there are potentially very many implied constraints imposing a lower limit on the number of cars requiring a particular option in any sub-sequence of length k. However, if the search builds up the sequence of cars consecutively from slot 1, only the implied constraints on the first k cars affect the search. The other possible implied constraints would always be consistent, but checking this whenever one of the variables involved is assigned a value would slow down the search. On the other hand, if the variables were assigned in a different order, a different set of implied constraints would be useful.

1.7.2 Implied Constraints v. Global Constraints

Following the work of Dincbas et al. on the car sequencing problem, R´egin and Puget [35] later developed a global constraint specifically for sequence problems, using the car sequencing problem as a test case. They noted that “our filtering algorithm subsumes all the implied constraints” used by Dincbas et al. The global constraint makes the effort of devising and implementing implied constraints redundant, in this case. It may often be true that implied constraints are only useful because a suitable global constraint does not (yet) exist. On the other hand, many implied constraints are simple and cheap to propagate, whereas global constraints are often time-consuming to propagate. Moreover, it is only worth the effort of implementing a global constraint if it can be used for a significant class of problems; for a one-off problem, where good implied constraints can be found, the implied constraints are likely to be more cost-effective.

1.7.3 Implied Constraints from Subproblems

Van Beek and Wilken [46] use implied constraints in finding minimum length instruction schedules for the object code produced by a compiler. The implied constraints are lower bounds on the number of steps between a pair of instructions, found by considering sub- problems; if a consistency check in the subproblem shows that the current lower bound on the distance between two instructions cannot be achieved, a constraint increasing the bound can be added. Van Beek and Wilken comment that generating powerful implied con- straints in this way was the key to being able to solve very large real instruction scheduling problems. In the SONET problem, described in section 1.6, implied constraints were also derived (in that case by hand) from considering subproblems; the SONET constraints are lower bounds on the auxiliary variables that represent the number of times that each node is installed on a ring. These examples suggest that subproblems might also be a useful source of tighter variable bounds in other cases.

1.7.4 Finding Implied Constraints

Implied constraints can often be explained as projections of a conjunction of a few of the problem constraints onto a subset of the variables in the union of their scopes. These con- straints can be seen as partially enforcing some higher level of consistency in the problem. Although the search algorithm only enforces consistency on single constraints, there are forms of consistency that take all the constraints on a subset of the variables and find in- consistent tuples. Enforcing consistency on subsets of the constraints is computationally expensive, even if only done before search; if it generated the equivalent of useful implied

16 1. Modelling

constraints, it would likely also generate a much larger number that would not be useful during the search. Furthermore, consistency enforcing generates sets of forbidden tuples; these would be presented to the constraint solver as extensional non-binary constraints, which are time-consuming to propagate. This does not at present appear a promising route to generating implied constraints automatically; it is not sufficiently selective, and implied constraints need to be expressed in form that can propagate efficiently, like other problem constraints. Alternatively, adding implied constraints to a CSP is often inspired by a search taking an unacceptably long time to solve a problem, and discovering on examining the search tree in detail that assignments that are obviously incorrect are being considered; implied constraints are generalizations that state explicitly what is incorrect about these assign- ments and other potential failed assignments of the same kind. On this view, implied constraints are akin to nogoods (inconsistent compound assignments) that are uncovered during search. However, individual nogoods have little effect on the search, and if there are enough of them to be useful, checking them will hinder the constraint solver. An advan- tage is that they do take account of the search heuristics. Again, automatically generating implied constraints from nogoods identified during the search would require some means of expressing the constraints in a form that can propagate efficiently. Some attempts have been made to generate implied constraints automatically, by look- ing for logical consequences of the existing constraints. Hnich, Richardson and Flener [26] classify implied constraints, and discuss automatically generating implied constraints of each type. Some of the types that they identify have been discussed separately here; for instance, one of the types is a global constraint (such as an allDifferent constraint) used to replace a set of constraints (a clique of = constraints). Other types require introducing new variables. However, two of their types fit closely the implied constraints discussed in this section: variable elimination (using one constraint to eliminate a variable in its scope from other constraints involving that variable) and constraints over a new scope (using a set of constraints to derive a new constraint over a subset of the union of their scopes). Hnich et al. describe using PRESS (PRolog Equation Solving System) to try to derive implied constraints from linear and nonlinear arithmetic constraints; in their test cases, it can find some implied constraints of the variable elimination type, and also implied linear constraints derived from nonlinear constraints, but not the other types. Frisch, Miguel and Walsh [18] also make some initial steps towards automating the generation of implied constraints by developing methods (analogous to methods in proof planning) that can be applied to the set of constraints in a CSP to derive new constraints. One is the eliminate method, which attempts to eliminate variables or terms from a non-linear constraint, to give a constraint of lower arity that may propagate better. For example:

A

BC

D

EF

G

HI

= 1 with

A

BC

D

EF

G

HI

yield: 3

A

BC

Neither of these approaches addresses the interaction of the search heuristics and the implied constraints, but if a class of implied constraints can be identified for a type of prob- lem, such as the car sequencing problem, it would be possible to identify the constraints that are useful during search, and discard the rest. Simonis et al. [38] discuss using visual- ization tools in a constraint solver to assess the value of implied constraints, by examining