77
CSC2512 Advanced Propositional Reasoning

QBF - Department of Computer Science - University of Toronto

  • Upload
    others

  • View
    5

  • Download
    0

Embed Size (px)

Citation preview

Page 1: QBF - Department of Computer Science - University of Toronto

CSC2512Advanced Propositional

Reasoning

Page 2: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 2

CSC2512: SoftCSPs and MaxSAT

• SoftCSPs• A set of variables X1, X2, …, Xn each with a finite domain of values

Dom[Xi].• A set of cost functions C1, …, Cm (like constraints).• Each cost function is a mapping from a subset of the variables Xi

to real valued costs, e.g.,

Cj(X1, X2, X3) : Ci(X1=a, X2=b, X3=c) = 0.5

• The cost of a complete assignment to the variables π is the sum of the weights of incurred cost function weights

• A solution is a complete assignment of minimum cost.• Again hard constraints (settings of subsets of variables that are not

permitted) can be encoded with ∞ weights.

Page 3: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 3

CSC2512: Branch and Bound• A popular way of solving a soft CSP is via backtracking search,

using Branch and Bound.

• Let A be a set of variable assignments, e.g., {X=1, Y=a, Z=10}

• P|A will denote the reduction of P by A.

• P|A is itself a SoftCSP over a reduced set of variables where the objectives of P have been reduced by the assignments in A

Page 4: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 4

CSC2512: Branch and Bound• mincost(P|A) is the minimal cost solution to this reduced SoftCSP

• Let ∆(A) denote the immediate cost of the assignment A. This is the sum of the costs of all objectives completely instantiated by A.

• ∆(A) + mincost(P|A) is the minimal cost for P in the part of the solution space that extends A.

• mincost(P) ≤ ∆(A) + mincost(P|A) for any assignment A.

• Equality only if A can be extended to an optimal solution of P.

Page 5: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 5

CSC2512: Branch and Bound• B&B relies on two bounds• UB:

mincost(P) ≤ UB.

• LB: A lower bound function. This function must be able to supply a lower bound on any reduction of P (that will be encountered during search). Thus for any reduction (including the null reduction) we require

LB(P|A) ≤ mincost(P|A)

Page 6: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 6

CSC2512: Branch and BoundUB• Initially we can set UB by finding any low cost solution, e.g., via

local search or a greedy solution. • If there are many hard constraints may need to find a feasible

solution, any feasible solution will provide an upper bound. If feasible solution to the hard constraints then all complete assignments have infinite cost.

LB• Various techniques are used for computing LB including• Linear programming relaxations. • Soft ARC consistency.

Page 7: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 7

CSC2512: Branch and Bound

X=a X≠a

P

LB(P|X=a) + ∆(X=a) ≥ UB Backtrack

If all variables assigned Found better solutionReset UB.

Page 8: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 8

CSC2512: Soft Arc Consistency

• Soft Arc Consistency is used to compute lower bounds• Two soft CSPs are equivalent when the cost of every

complete assignment is identical.• Soft Arc Consistency is an equivalence transformation

of the problem, achieved by moving weights between cost functions.

Page 9: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 9

CSC2512: Soft Arc ConsistencyC(X,Y,Z)X=a,Y=a,Z=a 15X=a,Y=a,Z=b 8X=a,Y=a,Z=c 7X=a,Y=a,Z=d 6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 6X=b,Y=a,Z=b 4X=b,Y=a,Z=c 11X=b,Y=a,Z=d 19

X=b,Y=b,Z=a 7

X=b,Y=b,Z=b 4

X=b,Y=b,Z=c 8

X=b,Y=b,Z=d 7

All assignments with X=b cost a minimum of 4All assignments with X=a,Y=a cost a minimum of 6All assignments with Z=d cost a minimum of 6

Page 10: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 10

CSC2512: Soft Arc ConsistencyMore generally, if we have a cost function C(X1, X2, .., Xm) and we fix an assignment to any subset of its scope A={X1=a1, …, Xk=ak}. Then we can compute the minimum value w of C(X1, X2, .., Xk) over all settings to the other variables (i.e., those not assigned in A. Then we can see that any assignment that extends A must incur cost w.

To capture this information so that can be used in other inferences, we can install a new cost function over the variables in A, C’(X1, …, Xk) such that C(X1=a1, …, Xk=ak) = w. Or if a cost function already exists over these variables we can add w to the cost of the assignment A.

Page 11: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 11

CSC2512: Soft Arc ConsistencyC(X,Y,Z)X=a,Y=a,Z=a 15X=a,Y=a,Z=b 8X=a,Y=a,Z=c 7X=a,Y=a,Z=d 6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 6X=b,Y=a,Z=b 4X=b,Y=a,Z=c 11X=b,Y=a,Z=d 19

X=b,Y=b,Z=a 7

X=b,Y=b,Z=b 4

X=b,Y=b,Z=c 8

X=b,Y=b,Z=d 7

• All assignments with X=b cost a minimum of 4

• All assignments with X=a,Y=a cost a minimum of 6

• All assignments with Z=d cost a minimum of of 6

• C1(X): C1(X=b) = 4• C2(X,Y): C2(X=a,Y=a) = 6• C3(Z): C3(Z=d) = 6

Page 12: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 12

CSC2512: Soft Arc Consistency• However if we add these cost functions to the problem and retain

the old cost functions, we have not preserved equivalence. C1(X): C1(X=b) = 4; C2(X,Y): C2(X=a,Y=a) = 6; C3(Z): C3(Z=d) = 6. Plus the original cost function makes, e.g., A={X=b, Y=b, Z=d} cost 7+4+6 instead of 7.

C(X,Y,Z)X=a,Y=a,Z=a 15X=a,Y=a,Z=b 8X=a,Y=a,Z=c 7X=a,Y=a,Z=d 6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 6X=b,Y=a,Z=b 4X=b,Y=a,Z=c 11X=b,Y=a,Z=d 19

X=b,Y=b,Z=a 7

X=b,Y=b,Z=b 4

X=b,Y=b,Z=c 8

X=b,Y=b,Z=d 7

Page 13: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 13

CSC2512: Soft Arc Consistency

• Soft Consistency involves moving weights between cost functions. So for every new cost function we add we subtract an equivalent value from the old cost function.

• Soft arc consistency is an EPT (equivalence preserving transformation)

Page 14: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 14

CSC2512: Soft Arc ConsistencyC(X,Y,Z)X=a,Y=a,Z=a 15X=a,Y=a,Z=b 8X=a,Y=a,Z=c 7X=a,Y=a,Z=d 6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 6X=b,Y=a,Z=b 4X=b,Y=a,Z=c 11X=b,Y=a,Z=d 19

X=b,Y=b,Z=a 7

X=b,Y=b,Z=b 0

X=b,Y=b,Z=c 8

X=b,Y=b,Z=d 7

• C1(X): C1(X=b) = 4

C(X,Y,Z)X=a,Y=a,Z=a 15X=a,Y=a,Z=b 8X=a,Y=a,Z=c 7X=a,Y=a,Z=d 6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 2X=b,Y=a,Z=b 0X=b,Y=a,Z=c 7X=b,Y=a,Z=d 15

X=b,Y=b,Z=a 3

X=b,Y=b,Z=b 0

X=b,Y=b,Z=c 4

X=b,Y=b,Z=d 3

Page 15: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 15

CSC2512: Soft Arc ConsistencyC(X,Y,Z)X=a,Y=a,Z=a 15X=a,Y=a,Z=b 8X=a,Y=a,Z=c 7X=a,Y=a,Z=d 6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 2X=b,Y=a,Z=b 0X=b,Y=a,Z=c 7X=b,Y=a,Z=d 15

X=b,Y=b,Z=a 3

X=b,Y=b,Z=b 0

X=b,Y=b,Z=c 4

X=b,Y=b,Z=d 3

C(X,Y,Z)X=a,Y=a,Z=a 9X=a,Y=a,Z=b 2X=a,Y=a,Z=c 1X=a,Y=a,Z=d 0

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 2X=b,Y=a,Z=b 0X=b,Y=a,Z=c 7X=b,Y=a,Z=d 15

X=b,Y=b,Z=a 3

X=b,Y=b,Z=b 0

X=b,Y=b,Z=c 4

X=b,Y=b,Z=d 3

• C2(X,Y): C2(X=a,Y=a) = 6

Page 16: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 16

CSC2512: Soft Arc ConsistencyC(X,Y,Z)X=a,Y=a,Z=a 9X=a,Y=a,Z=b 2X=a,Y=a,Z=c 1X=a,Y=a,Z=d 0

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 8

C(X,Y,Z)X=b,Y=a,Z=a 2X=b,Y=a,Z=b 0X=b,Y=a,Z=c 7X=b,Y=a,Z=d 15

X=b,Y=b,Z=a 3

X=b,Y=b,Z=b 0

X=b,Y=b,Z=c 4

X=b,Y=b,Z=d 3

C(X,Y,Z)X=a,Y=a,Z=a 9X=a,Y=a,Z=b 2X=a,Y=a,Z=c 1X=a,Y=a,Z=d -6

X=a,Y=b,Z=a 0

X=a,Y=b,Z=b 4

X=a,Y=b,Z=c 6

X=a,Y=b,Z=d 2

C(X,Y,Z)X=b,Y=a,Z=a 2X=b,Y=a,Z=b 0X=b,Y=a,Z=c 7X=b,Y=a,Z=d 9

X=b,Y=b,Z=a 3

X=b,Y=b,Z=b 0

X=b,Y=b,Z=c 4

X=b,Y=b,Z=d -3

• C3(Z): C3(Z=d) = 6We can’t add this cost function after the others, as then we would have a negative weight (changes the logic of the optimization problem.

Page 17: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 17

CSC2512: Soft Arc Consistency

• We can also move weight from a low arity cost function to a higher arity cost function.

• Summing two cost functions corresponds to kind of a weight move.

Page 18: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 18

CSC2512: Summing two constraintsC1(X,Y) X=a X=b

Y=a 50 40

Y=b 30 50

C2(Y,Z) Y=a Y=b

Z=a 100 40

Z=b 30 60

Z=c 20 80

C4(Y,Z,X) X=a,Y=a X=a,Y=b X=b,Y=a X=b,Y=b

Z=a 5+10=15 3+4=7 4+10=14 5+4=9

Z=b 5+3=8 3+6=9 4+3=7 5+6=11

Z=c 5+2=7 3+8=11 4+2=6 5+8=13

Page 19: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 19

CSC2512: Soft Arc Consistency

• In this case we can remove the two old cost-functions as they now only have zero values.

• Moving weight to the zero-ary cost function (whose scope is empty) corresponds to subtracting the weight of the minimum weight tuple from the cost function and moving it to C∅.

• Since C∅ has no variables, its cost is incurred by every complete assignment to the variables.

• C∅ is a lower bound!

Page 20: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 20

CSC2512: Min Tuple C∅C4(Y,Z,X) X=a,Y=a X=a,Y=b X=b,Y=a X=b,Y=bZ=a 15 7 14 9Z=b 8 9 7 11Z=c 7 11 6 13

C4(Y,Z,X) X=a,Y=a X=a,Y=b X=b,Y=a X=b,Y=bZ=a 9 1 8 3Z=b 2 3 1 5Z=c 1 5 0 7

Add 6 to C∅

Page 21: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 21

CSC2512: Propagation in SoftCSPs

Soft Arc Consistency (SAC)• This is a restricted application of weight shifting, as

general weight shifting is complex to control (what weights do we shift where, what new cost functions do we generate, etc.)

• Each operation of SAC preserves equivalence and is restricted to shifting weight between a subset of the problems cost functions C that contains only one cost function of arity > 1.

• Since we need to record the weight shifts, we assume that for each X we have a unary cost function over it, and that we have a 0-ary cost function C∅.

Page 22: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 22

CSC2512: Propagation in SoftCSPs

Let there be only one cost-fn with scope S (we can replace multiple cost-fns by their sum). We use S to denote the cost-fn.

Let ℓ(S) be the set of all assignments to the variables in S. S assigns each of these a weight.

Let ℓ(S)[X=a] be the subset of ℓ(S) in which variable X has been assigned the value a (X ∈ S)

Page 23: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 23

CSC2512: Propagation in SoftCSPsThere are three weight shifting rules used in Soft Arc Consistency 1. Project: Move weight from the higher arity cost function S to a

unary cost function over the variable X such that X ∈ S.

Let W be the maximum weight among all assignments ℓ(S)[X=a]. Let α be a real value 0 < α ≤ W.

Then, we modify S by subtracting α from the weight it gives to every assignment in ℓ(S)[X=a]. And we increase the weight of X=a by α

Before every complete assignment with X=a incurred a cost w from S and a cost w’ from X=a. Now it incurs cost w-α plus w’+α

Note, that all weights remain greater than 0

Page 24: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 24

CSC2512: Propagation in SoftCSPsThere are three weight shifting rules used in Soft Arc Consistency 2. Extend: Move weight from a unary cost function over a variable X

to a higher arity cost function S such that X ∈ S.

Let W be the weight of X=a, let α be a real value 0 < α ≤ W.

Then, we modify S by adding α to the weight of every assignment in ℓ(S)[X=a]. And we decrease the weight of X=a by α

Before every complete assignment with X=a incurred the a cost w from S and a cost w’ from X=a. Now it incurs cost w+α plus w’-α

Extend is Project with negative weights. It also never generates a negative weight.

Page 25: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 25

CSC2512: Propagation in SoftCSPs

Different forms of consistency can be established by using these three rules 1. Node Consistency (no longer possible to flow cost from a

unary constraint to C∅)2. GAC (Soft) Consistency (no longer possible to flow cost

from a k-ary constraint to a unary constraint). 3. Full Directional Arc Consistency (FDAC) (binary SoftCSPs)4. Existential Arc Consistency (EAC)5. Existential Directional Arc Consistency (EDAC =

FDAC+EAC)6. Optimal Soft Arc Consistency (OSAC, via a linear program)

Page 26: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 26

CSC2512: Propagation in SoftCSPsThere are three weight shifting rules used in Soft Arc Consistency 3. UnaryProject: Move weight from a unary cost-fn to C∅.

Let W be minimum weight of assignments in the unary cost function over X: {X}. Let α be a real value 0 < α ≤ W.

Then, we modify {X} by subtracting α from the weight of every assignment to X and then adding α to the weight of C∅.

Before every complete assignment with X=a incurred the a cost w from {X} and a cost w’ from C∅. Now it incurs cost w-α plus w’+α

Never generates a negative weight.

Page 27: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 27

CSC2512: Propagation in SoftCSPs

With these three equivalence preserving rules we can define different notions of consistency and apply the rules until we achieve the consistency we desire

Node consistency: For every variable X there exists some value a for X such that {X} assigns zero weight to X=a.

If the problem is not Node Consistency, then there exists a variable Y with only non-zero weights in its unary constraint {Y}. We apply UnaryProject with α equal to the minimum weight W and this makes Y node consistent. Achieving Node Consistency increases the lower bound C∅

Page 28: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 28

CSC2512: Propagation in SoftCSPs

Generalized Arc consistency: For every constraint S,variable X ∈ S and for all values a ∈ Dom[X] there exists some assignment in ℓ(S)[X=a] to which S assigns zero weight.

If the problem is not GAC there exists some constraint S, variable X ∈ S, and value a ∈ Dom[X], such that every assignment in ℓ(S)[X=a] has non-zero weight. We then take the minimum of these weights and project it on to X=a. We can then if necessary re-establish Node Consistency.

Page 29: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 29

CSC2512: Propagation in SoftCSPs

GAC can be achieved in different ways (the resulting problem depends on which transformations are applied).

C(X,Y)X=a, Y=a 1X=a, Y=b 0X=b, Y=a 1X=b, Y=b 1

Project to X=b, or Project to Y=a

C(X,Y)X=a, Y=a 1X=a, Y=b 0X=b, Y=a 0X=b, Y=b 0

C(X)X=a 0X=b 1

C(X,Y)X=a, Y=a 0X=a, Y=b 0X=b, Y=a 0X=b, Y=b 1

C(Y)Y=a 1Y=b 0

Page 30: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 30

CSC2512: Propagation in SoftCSPs

• In this example the lower bound C∅ is the same for both ways of achieving GAC. But this need not be the case.

• In general, different ways of achieving GAC can yield different lower bounds.

• In some cases, we may have to use extend as well as project.

Page 31: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 31

CSC2512: Propagation in SoftCSPs

Already GAC and Node consistent.

C(X,Y)X=a, Y=a 0X=a, Y=b 0X=b, Y=a 0X=b, Y=b 1

C(X)X=a 1X=b 0

C(Y)Y=a 1Y=b 0

C∅ 0

Page 32: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 32

CSC2512: Propagation in SoftCSPs

Extend X=a to C(X,Y).

C(X,Y)X=a, Y=a 0X=a, Y=b 0X=b, Y=a 0X=b, Y=b 1

C(X)X=a 1X=b 0

C(Y)Y=a 1Y=b 0

C∅ 0

C(X,Y)X=a, Y=a 1X=a, Y=b 1X=b, Y=a 0X=b, Y=b 1

C(X)X=a 0X=b 0

C(Y)Y=a 1Y=b 0

C∅ 0

Page 33: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 33

CSC2512: Propagation in SoftCSPs

Project C(X,Y) to Y=b

C(X,Y)X=a, Y=a 1X=a, Y=b 1X=b, Y=a 0X=b, Y=b 1

C(X)X=a 0X=b 0

C(Y)Y=a 1Y=b 0

C∅ 0

C(X,Y)X=a, Y=a 1X=a, Y=b 0X=b, Y=a 0X=b, Y=b 0

C(X)X=a 0X=b 0

C(Y)Y=a 1Y=b 1

C∅ 0

Page 34: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 34

CSC2512: Propagation in SoftCSPs

UnaryProject C(Y) to C∅

C(X,Y)X=a, Y=a 1X=a, Y=b 0X=b, Y=a 0X=b, Y=b 0

C(X)X=a 0X=b 0

C(Y)Y=a 1Y=b 1

C∅ 0

C(X,Y)X=a, Y=a 1X=a, Y=b 0X=b, Y=a 0X=b, Y=b 0

C(X)X=a 0X=b 0

C(Y)Y=a 0Y=b 0

C∅ 1

Page 35: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 35

CSC2512: Propagation in SoftCSPs

This sequence increases C∅

In general, extend is required to achieve the highest lower bound

C(X,Y)X=a, Y=a 1X=a, Y=b 0X=b, Y=a 0X=b, Y=b 0

C(X)X=a 0X=b 0

C(Y)Y=a 0Y=b 0

C∅ 1

Page 36: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 36

CSC2512: Propagation in SoftCSPs

• We want to execute a sequence of these three transformations so as to obtain a maximum value for C∅

• This can be accomplished in polynomial time via a linear program, but it is expensive if we want to solve the problem exactly.

• Other attempts have been made to define specific versions of GAC that tend to achieve a larger lower bound.

• These extensions introduce the notion of an ordering over the variables.

Page 37: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 37

CSC2512: Propagation in SoftCSPs

For a binary SoftCSP where the arity of all cost-functions is no larger than 2. We can define directional arc consistency (DAC).

A binary SoftCSP is DAC with respect to a particular ordering < on the variables if for all constraints {X,Y}, where (without loss of generality) X < Y we haveFor all d ∈ Dom[X],there exists a b ∈ Dom[Y] such that {X,Y} assigns zero to {X=d, Y=b} and the unary constraint {Y} assigns zero to Y=b.

Page 38: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 38

CSC2512: Propagation in SoftCSPs

If we don’t have DAC there exists a {X,Y} and X=d such that for all values b of Y either {X=d,Y=b} > 0 or {Y=b} > 0

For all values b of Y such that {Y=b} > 0 we can extend its cost to {X=*, Y=b} for all values of X. This makes {Y=b}=0 for every value of Y.

Then if {X=d, Y=b} > 0 for all values of b, we can project its cost to {X=d} making it zero for some value of b. This will achieve DAC on {X,Y}, X=d

Page 39: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 39

CSC2512: Propagation in SoftCSPs

DAC tends to move weight from Y to X where X < Y. So in general it tends to shift weight towards variables earlier in the ordering. This tends to make all of their values > 0, enabling a UnaryProject.

DAC however does not ensure GAC. On the cost function {X,Y} we do not require, e.g., that for all values b ∈ Dom[Y],there exists a a ∈ Dom[X] such that {X,Y} assigns zero to {X=d, Y=b} as is required by GAC.

Page 40: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 40

CSC2512: Propagation in SoftCSPs

Full Directional Arc Consistency (FDAC). A binary SoftCSPis FDAC with respect to a particular ordering < on the variables if it is GAC and DAC with respect to <.

No constraints can project on to any unary constraint, and we can’t extend any unary constraint in such a way that we enable a projection on to another variable higher up in the ordering (less then wrt <)

Page 41: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 41

CSC2512: Propagation in SoftCSPs

Existential Arc Consistency (EAC). A binary SoftCSP is EAC if for every variable X there exists a value d ∈ Dom[X] such that the weight of X=d is zero, and for all other constraints {X,Y} there exists a b ∈ Dom[Y] such that the cost of {X=d, Y=b} is zero as is {Y=b}.

That is, the problem is node consistent and there is at least one value in the domain of every variable that satisfies a stronger than GAC condition. However, we do not require that every value of X has a zero-cost tuple in {X,Y}, as required by GAC.

Page 42: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 42

CSC2512: Propagation in SoftCSPs

Existential Directional Arc Consistency (EDAC). A binary SoftCSP is EDAC if it is both FDAC and EAC.

Algorithms exists for converting the SoftCSP via project, extend, and unary project so that it becomes FDAC, EAC, and EDAC.

These forms of consistency tend to yield a better lower bound than simply enforcing GAC and node consistency. But the algorithms are limited to binary SoftCSPs.

Page 43: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 43

CSC2512: Propagation in SoftCSPs

• How do we make the lower bound as large as possible?

• This can be done with a linear program. But in practice this is quite expensive.• Too expensive to do at every node of a branch and

bound search tree.• But it can be worth doing at the root of the tree.

Page 44: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 44

CSC2512: Propagation in SoftCSPs

• An Arc consistency closure of a SoftCSP P is any equivalent SoftCSP P’ that is node consistent and GAC.

• All arc consistency closures can be found by applying some sequence of Project, Extend, and UnaryProject(but one might require arbitrary weights to be shifted at each stage).

• An arc consistency closure of P is optimal if it has the maximum lower bound C∅ among all arc consitencyclosures of P.

Page 45: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 45

CSC2512: Propagation in SoftCSPs

• We can compute an optimal arc-closure by setting up the following linear program (LP).Variables of the LP.

1. Ui = total weight projected by UnaryProject from the unary cost-function over Xi to C∅.

2. p(S,Xi,a) = total weight projected by Projected from cost-function S to the Unary cost-function Xi=a where X ∈ S. There is one such variable for every cost function, variable in the cost function and value for the variable. This weight can be negative indicating that there was an Extension

There are O(mnd) variables, m = number of cost functions, n = number of variables, d = maximum domain size..

Page 46: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 46

CSC2512: Propagation in SoftCSPs

Maximize SUMi ui

Subject to :a) For all Xi, d ∈ Dom[Xi]

the cost of {Xi = d} minus uiplus the sum over all cost functions S over Xi of p(S,Xi,d) is greater than zero

b) For all cost functions S with arity > 1 and for all assignments A ∈ ℓ(S) The cost of A given by S minus the sum over all variable assignments Xj = a in A of p(S,Xj,a) is greater than zero

Page 47: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 47

CSC2512: Propagation in SoftCSPs

Maximize SUMi ui

This maximizes the weight flow into the lower bound C∅

Page 48: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 48

CSC2512: Propagation in SoftCSPs

a) For all Xi, d ∈ Dom[Xi] the cost of {Xi = d} minus uiplus the sum over all cost functions S over Xi of p(S,Xi,d) is greater than zero

p(S,Xi,d) is the weight flow into {Xi = d}. ui is the weight flow out, and cost of {Xi = d} is the initial weight. This constraint insures that there are no negative costs in any of the unary constraints (given that we started off with no negative costs).

Page 49: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 49

CSC2512: Propagation in SoftCSPs

b) For all cost functions S with arity > 1 and for all assignments A ∈ ℓ(S) The cost of A given by S minus the sum over all variable assignments Xj = a in A of p(S,Xj,a) is greater than zero

Each assignment in S has an initial weight. From that assignment we have had a net flow of p(S,Xj,a) of out of that assignment for every individual assignment Xj = a in it. We constrain the sum of these net flows to be no greater than the weight we started off with.

This ensures that no assignment in any constraint ends up with a negative weight.

Page 50: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 50

CSC2512: VAC

VAC—Virtual Arc Consistency.

Let P be a SoftCSP. P has a set of cost functions, including a unary cost function over each of its variables. It also has an empty cost function C∅ (P might or might not satisfy some form of Soft Arc Consistency)

Define Bool(P) to be a standard CSP 1. Same variables as P2. Domain of each variable is the set of assignments given zero cost by

the unary constraints of P3. Every soft constraint Cs is converted to a hard constraint Ch in Bool(P)

with the same scope.4. Ch is satisfied by tuples of assignments that have zero cost in Cs

Page 51: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 51

CSC2512: SoftCSP P

C1(X,Y) X=a X=b

Y=a 0 4

Y=b 3 5

C2(Y,Z) Y=a Y=b

Z=a 0 4

Z=b 3 6

Z=c 2 8C3(X,Z) X=a X=b

Z=a 0 3

Z=b 2 8

Z=c 3 9

C(X)

X=a 0

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 0

Z=c 1C∅ 5

Page 52: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 52

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a T F

Y=b F F

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b F F

Z=c F FC3(X,Z) X=a X=b

Z=a T F

Z=b F F

Z=c F F

Dom[X]

X=a

X=b

Dom[Y]

Y=a

Y=b

Dom[Z]

Z=a

Z=b

Page 53: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 53

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a T F

Y=b F F

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b F F

Z=c F FC3(X,Z) X=a X=b

Z=a T F

Z=b F F

Z=c F F

Dom[X]X=a

X=b

Dom[Y]Y=a

Y=b

Dom[Z]Z=a

Z=b

This hard CSP has a solution.X=aY=aZ=a

Page 54: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 54

CSC2512: VAC

Any solution of Bool(P) is an optimal solution of P with cost C∅

A solution of Bool(P) incurs zero cost from every k-ary and unary cost function of P. It only incurs the cost of C∅

Since C∅ is a lower bound, each solution of Bool(P) is a minimum cost assignment to the variables of P.

Page 55: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 55

CSC2512: SoftCSP P

C1(X,Y) X=a X=b

Y=a 0 4

Y=b 3 5

C2(Y,Z) Y=a Y=b

Z=a 0 4

Z=b 3 6

Z=c 2 8C3(X,Z) X=a X=b

Z=a 0 3

Z=b 2 8

Z=c 3 9

C(X)

X=a 0

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 0

Z=c 1C∅ 5

Page 56: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 56

CSC2512: VAC

Say that Bool(P) has no solution. Then any assignment to P must incur some additional cost (at least one unary or k-arycost function must return a non-zero value).

A weaker condition that testing if Bool(P) has a solution is to determine if it is GAC (Hard GAC). If enforcing GAC yields an empty domain, then Bool(P) has no solution and cost(P) > C∅, if it is GAC then it might still have cost greater than C∅ but to determine that we would have to solve Bool(P) with a complete method rather than just applying GAC.

SoftCSP P is Virtual Arc Consistent (VAC) iff Bool(P) can be made GAC without creating any empty domains.

Page 57: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 57

CSC2512: VACGAC on Bool(P) is an application of two inferences:1. If a variable value X=a has no supporting tuples in a constraint C, we

prune ‘a’ from Dom[X]2. If we prune ‘a’ from Dom[X] we remove all supporting tuples (i.e., all

tuples containing X=a) in all constraints that contain X.2 enables more applications of 1.Consider these operations on the original SoftCSP P.1. No supporting tuples ⇔ all tuples in C with X=a, i.e., all tuples in

ℓ(C)[X=a] have cost > 0 ⇔ we can apply a project from C moving a non-zero cost to X=a.

2. X=a is inconsistent in Bool(P) ⇔ X=a has greater than zero cost in P or via 1 we made its cost > 0 ⇔ we can extend some non-zero cost from X=a to each tuple in each constraint containing X.

Page 58: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 58

CSC2512: VACEnforcing VAC:1. Enforce GAC on Bool(P).2. If there is no domain wipe out, P is VAC.3. If there is a domain wipe out, compute a sequence of soft arc

consistency propagation steps (extend, project, unary-project) that shift some more weight to C∅. This transforms P, create Bool(P) again and repeat steps 1-3.

Computing a sequence of soft arc consistency propagation steps.a) Find a sequence of Hard GAC operations that yields a Domain Wipe

Out. b) Propagate weights along that sequence.

Page 59: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 59

CSC2512: P

C1(X,Y) X=a X=b

Y=a 0 4

Y=b 0 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a 0 0

Z=b 0 2

C(X)

X=a 1

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 0

C∅ 0

Page 60: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 60

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a T F

Y=b T T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b T T

C3(X,Z) X=a X=b

Z=a T T

Z=b T F

C(X)

X=a F

X=b T

C(Y)

Y=a T

Y=b T

C(Z)

Z=a T

Z=b T

1. C1, prune all tuples with X=a

Page 61: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 61

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a F F

Y=b F T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b T T

C3(X,Z) X=a X=b

Z=a T T

Z=b T F

C(X)

X=a F

X=b T

C(Y)

Y=a T

Y=b T

C(Z)

Z=a T

Z=b T

1. C1, prune all tuples with X=a2. Prune Y=a (has no support any more on C1

Page 62: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 62

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a F F

Y=b F T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b T T

C3(X,Z) X=a X=b

Z=a T T

Z=b T F

C(X)

X=a F

X=b T

C(Y)

Y=a F

Y=b T

C(Z)

Z=a T

Z=b T

1. C1, prune all tuples with X=a2. Prune Y=a (has no support any more on C13. C3, prune all tuples with X=a

Page 63: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 63

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a F F

Y=b F T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b T T

C3(X,Z) X=a X=b

Z=a F T

Z=b F F

C(X)

X=a F

X=b T

C(Y)

Y=a F

Y=b T

C(Z)

Z=a T

Z=b T

1. C1, prune all tuples with X=a2. Prune Y=a (has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b (has no support any more on C3,

Page 64: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 64

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a F F

Y=b F T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b T T

C3(X,Z) X=a X=b

Z=a F T

Z=b F F

C(X)

X=a F

X=b T

C(Y)

Y=a F

Y=b T

C(Z)

Z=a T

Z=b F

1. C1, prune all tuples with X=a2. Prune Y=a (has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b (has no support any more on C3,5. C2, prune all tuples with Z=b

Page 65: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 65

CSC2512: Bool(P)C1(X,Y) X=a X=b

Y=a F F

Y=b F T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b F F

C3(X,Z) X=a X=b

Z=a F T

Z=b F F

C(X)

X=a F

X=b T

C(Y)

Y=a F

Y=b T

C(Z)

Z=a T

Z=b F1. C1, prune all tuples with X=a2. Prune Y=a (has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b (has no support any more on C3,5. C2, prune all tuples with Z=b6. Prune Y=b (has no support any more on C2

Page 66: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 66

CSC2512: Bool(P)C1(X,Y) X=a X=b

Y=a F F

Y=b F T

C2(Y,Z) Y=a Y=b

Z=a T F

Z=b F F

C3(X,Z) X=a X=b

Z=a F T

Z=b F F

C(X)

X=a F

X=b T

C(Y)

Y=a F

Y=b F

C(Z)

Z=a T

Z=b F1. C1, prune all tuples with X=a2. Prune Y=a (has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b (has no support any more on C3,5. C2, prune all tuples with Z=b6. Prune Y=b (has no support any more on C27. DWO of Y

Page 67: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 67

CSC2512: VAC1. C1, prune all tuples with X=a

• Extend X=a onto all tuples in ℓ(C1)[X=a] giving them non-zero weight (pruned in Bool(P))

2. Prune Y=a (has no support any more on C1)• Project weight from ℓ(C1)[Y=a] on to Y=a giving it non-zero weight (pruned in

Bool(P))3. C3, prune all tuples with X=a

• Extend X=a onto all tuples in ℓ(C3)[X=a] giving them non-zero 4. Prune Z=b (has no support any more on C3)

• Project weight from ℓ(C3)[Z=b] on to Z=b giving it non-zero5. C2, prune all tuples with Z=b

• Extend weight from Z=b onto all tuples in ℓ(C2)[Z=b]6. Prune Y=b (has no support any more on C2)

• Project weight from ℓ(C2)[Y=b] onto Y=b giving it non-zero weight7. DWO of Y

• Unary project weight from Y to C∅

Page 68: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 68

CSC2512: VACb. Propagate weights along that sequence.

Note we have to move weight out of X=a twice!

Page 69: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 69

CSC2512: P

C1(X,Y) X=a X=b

Y=a 0 4

Y=b 0 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a 0 0

Z=b 0 2

C(X)

X=a 1

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 0

C∅ 0

Page 70: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 70

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a 0 4

Y=b 0 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a 0 0

Z=b 0 2

C(X)

X=a 1

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 0

1. C1, prune all tuples with X=a

Page 71: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 71

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a ½ 4

Y=b ½ 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a 0 0

Z=b 0 2

C(X)

X=a ½

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 0

1. C1, prune all tuples with X=a2. Prune Y=a--has no support any more on C1

Page 72: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 72

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a 0 3½

Y=b ½ 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a 0 0

Z=b 0 2

C(X)

X=a ½

X=b 0

C(Y)

Y=a ½

Y=b 0

C(Z)

Z=a 0

Z=b 0

1. C1, prune all tuples with X=a2. Prune Y=a--has no support any more on C13. C3, prune all tuples with X=a

Page 73: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 73

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a 0 3½

Y=b ½ 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a ½ 0

Z=b ½ 2

C(X)

X=a 0

X=b 0

C(Y)

Y=a ½

Y=b 0

C(Z)

Z=a 0

Z=b 0

1. C1, prune all tuples with X=a2. Prune Y=a—has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b—has no support any more on C3,

Page 74: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 74

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a 0 3½

Y=b ½ 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b 0 0

C3(X,Z) X=a X=b

Z=a ½ 0

Z=b 0 1½

C(X)

X=a 0

X=b 0

C(Y)

Y=a ½

Y=b 0

C(Z)

Z=a 0

Z=b ½

1. C1, prune all tuples with X=a2. Prune Y=a—has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b—has no support any more on C3,5. C2, prune all tuples with Z=b

Page 75: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 75

CSC2512: Bool(P)

C1(X,Y) X=a X=b

Y=a 0 3½

Y=b ½ 0

C2(Y,Z) Y=a Y=b

Z=a 0 3

Z=b ½ ½

C3(X,Z) X=a X=b

Z=a ½ 0

Z=b 0 1½

C(X)

X=a 0

X=b 0

C(Y)

Y=a ½

Y=b 0

C(Z)

Z=a 0

Z=b 01. C1, prune all tuples with X=a2. Prune Y=a—has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b—has no support any more on C3,5. C2, prune all tuples with Z=b6. Prune Y=b (has no support any more on C2

Page 76: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 76

CSC2512: Bool(P)C1(X,Y) X=a X=b

Y=a 0 3½

Y=b ½ 0

C2(Y,Z) Y=a Y=b

Z=a 0 2½

Z=b ½ 0

C3(X,Z) X=a X=b

Z=a ½ 0

Z=b 0 1½

C(X)

X=a 0

X=b 0

C(Y)

Y=a 0

Y=b 0

C(Z)

Z=a 0

Z=b 01. C1, prune all tuples with X=a2. Prune Y=a—has no support any more on C13. C3, prune all tuples with X=a4. Prune Z=b—has no support any more on C3,5. C2, prune all tuples with Z=b6. Prune Y=b (has no support any more on C27. DWO of Y

C∅ ½

Page 77: QBF - Department of Computer Science - University of Toronto

Fahiem Bacchus, University of Toronto, 77

CSC2512: VAC

1. We repeat this process until Bool(P) is GAC. 2. This process might become numerically unstable since the

incremental weights we can pass around might become too smaller, we can treat all weights < ε as being zero. For fixed ε this tends to converge more quickly.

3. VAC closure does not yield as high a lower bound as OSAC.

4. We split the weight from X=a equally between the two places we need it. Unknown if an equal split always yield the highest increase in the lower bound.

5. There may be many different GAC refutations. Unknown if different ones might yield better increases in the lower bound.