CP course, lecture 4

5 downloads 352 Views 792KB Size Report
Propagators. • Are the workhorses of a CP system. • Implement constraints through domain reduction + checking. • Compute on a Constraint Store ...
Propagators CP course, lecture 4

Recapitulation • Formal model: CSP (X,C) with X = {x1 : D1 , . . . , xn : Dn }

• Domain reduction + Search

we will present ado system inference rules for revisedThis algorithm. as possible—to betterof when we actually can the do better. requires two changes: First, we need to eliminate inconsistent values before finding an assignment—this is what wedetection will call a propagation we need to obvious use a control strategy that Failure The first rulerule. that Second, we will use detects inconsistencies: a ensures that guessinginconsistent is done onlyifas a last resort. In the remainder thisreduced section, problem is obviously one of the involved domains hasof been wethe willempty present system of inference rules for any the revised algorithm. to set.a In this case, we cannot build assignment, save one that satis-

Recapitulation

fies all the constraints.

!X ∪ {x : ∅} ; C$ Failure detection The first rule that we will use detects obvious inconsistencies: (1)a problem is obviously inconsistent if onefail of the involved domains has been reduced to the empty set. In this case, we cannot build any assignment, save one that satisBranching The second rule captures the ‘generate’ aspect of the generate-and-test fies all the constraints. {x yet : ∅}determined, ; C$ algorithm: To reduce a CSP P that!X is∪not we can take any variable (1) x : D from P , partition its domain into disjoint sets D1 , . . . , Dk , guess an 1 ≤ i ≤ k, fail and continue the reduction with the problem obtained from P by replacing D by Di . This rule is known as branching: Branching The second rule captures the ‘generate’ aspect of the generate-and-test

check failure

check failure

split algorithm: To reduce a CSP P that is not yet determined, we can take any variable

!X ∪ {x : D} ; C$ |D| > 1 D = D & · · · & Dk x : D from P , partition its domain into disjoint sets D11 , . . . , Dk , guess an 1 ≤ i ≤(2) k, thatcontinue satisfy Cthe (rather in∪the map x toDd.by If D that !Xthan ∪ {xall : Dthe ;constraints Cproblem $ | · · · | !X {xproblem) :D 1} k} ; C and reduction with the obtained from P$and by replacing i. testrule fails,iswe can eliminate d as a potential value for x. A rule of this type is called This known as branching: a constraint propagation rule: Constraint propagation Finally, we need a rule to eliminate inconsistent values ∪ {x D} ; C$ |D| >1 Dwhat = D1we & ·could ·· & D k to test the confor the variables. !X From an: extensional perspective, do !X ∪ {x : D} ; C ∪ {C}# d∈D sat(C) ∩ { α ∈ ass(X) | αx = d } = ∅ (2) sistency of a candidate whether !Xassignment ∪ {x : D1 } is ; Cto $ |check · · · | !X ∪ {x :itDappears k } ; C$ in the intersection(3) ∪ {x : DFrom − {d}} ∪ {C}# of all the constraints in the!X problem. an; C intensional perspective, this is not generally possible anymore,Finally, since (a)we the CSP aunder consideration may still allow an Constraint propagation need rule to eliminate inconsistent values Notice that, if we would apply this rule only to assignments, it would—together with exponential number of possible assignments and (b)what it may verydo hard to compute for the variables. From an extensional perspective, webe could to test the conthe rule for failure—have the same effect as the ‘testing’ part of the generate-andthe ‘intersection’ of a set of intensional Weitmake the in compromise that sistency of a candidate assignment is toconstraints. check whether appears the intersection test algorithm: if fail cannot be derived, the current problem defines a solution. we only consider one constraint at a time, and test the local consistency of potential

narrowing

Recapitulation • Algorithm, specified by inference rules: check failure split domains reduce domains

This makes it efficient!

Propagators • Are the workhorses of a CP system • Implement constraints through domain reduction + checking

• Compute on a Constraint Store

Constraint Store • Mapping from variables to current domain •

Store s corresponds to domain dom Store s1 stronger than s2 (s1 ≤ s2): written: {x 1: D1,...,xn: Dn} x X: s1(x) s2(x)

Constraint Store • Mapping from variables to current domain •

Store s corresponds to domain dom Store s1 stronger than s2 (s1 ≤ s2): x X: s1(x) s2(x) Store s1 strictly stronger than s2 (s1 < s1):



s1 ≤ s2 and s1 ≠ s2 (S,