• No results found

Binary and Higher-Dimensional Potential Heuristics

With higher-dimensional potential heuristics, we grouped the set of features into three sets: irrelevant, context-independent, and context-dependent features. We can do the same for unrestricted SAS+ tasks. However, in the general case, we also have to con- sider a feature f context-dependent for an operator o if o sometimes produces or some- times consumes f , i.e. if o has an effect but no precondition on a variable mentioned in f . With this extended definition, irrelevant features and context-independent features behave just like in the TNF case.

B.4. Binary and Higher-Dimensional Potential Heuristics

Context-dependent features are harder to handle in general. For them, we have to find a compact characterization of solutions to the following equation (see Section 15.3.2).

Zo ≥ max s|=pre(o) X f ∈Fctx o w(f )∆o(f, s)

In Section 15.3.2 we did this by transforming the maximum into a function maximiza- tion problem over the functions

ψof(p) = Wf([pre(o)∪ p |= f] − [eff (o) ∪ p |= f])

where p is a partial variable assignment over variables mentioned by f but not by o. Since the context can now depend on variables mentioned in the effect of o but not in the precondition, we have to extend this definition.

LetVf \o be the variables mentioned by f but not by o, and letVf \pre(o) be the vari-

ables mentioned by f and o, but not in the precondition of o. Further, let post(o) be the partial state with post(o)[V ] = eff (o)[V ] if V ∈ vars(eff (o)) and post(o)[V ] = pre(o)[V ] if V ∈ vars(pre(o)) \ vars(eff (o)), i.e. the effect of o together with all prevail conditions of o. We can then change the definition of ψ to a function from Vf \o∪ Vf \pre(o) to{Wf,−Wf,0}:

ψ0fo(p) = Wf([pre(o)∪ p |= f] − [post(o) ∪ p|Vf \o |= f])

The function maximization problem over those functions can be combined with the remaining constraint as in Section 15.3.2 to get a general definition of higher- dimensional potential heuristics.

Appendix C.

Maximizing a Sum of Functions

We now leave the planning formalism and consider a technique from constraint op- timization called bucket elimination (Dechter, 1999, 2003). We will generalize the technique and show how linear programming can be used to solve the generalization.

First, we need some basic notation. Let X be a set of finite-domain variables and dom(X) the domain of each X ∈ X . We extend the definition of dom to sets S ⊆ X such that dom(S) is the set of variable assignments that map each variable in S to a value in its domain. Let V be a set of values. For now, think of V as the set of real numbers R. We will consider more general sets later. We only require that maximization and addition is defined on values in V, that both operations are commutative and associative, and thatmax{a + c, b + c} ≡ c + max {a, b} for all a, b, c ∈ V. We use the common extensions of sums and maxima from binary functions to functions of arbitrary arity and use common mathematical abbreviations likeP

x∈{1,...,n}f(x) = f (1) +· · · + f(n) and

maxx∈{1,...,n}f(x) = max{f(1), . . . , f(n)}. As corner cases, the sum and maximum

over the singleton set{x} are x.

LetΨ be a set of scoped functions, i.e. tupleshS, fi containing a scope S ⊆ X and a function f : S → V. For a scope S and a variable assignment ν ∈ dom(X ) we use ν|S

to denote the projection of ν to the variables in S.

We are interested in a maximal object that the sum of all functions in Ψ can take under a common variable assignment:

Max(Ψ) = max

ν∈dom(X )

X

hS,f i∈Ψ

f(ν|S).

Example Consider the setX = {x, y} of two binary variables and the scoped func- tionsΨ ={h{x}, fi, h{x, y}, gi} of the two functions f and g with:

f (x) x = 0 x = 1

3 2

g(x, y) x = 0 x = 1

y = 0 2 −5

y = 1 0 4

In this case, the variable assignment ν = {x 7→ 1, y 7→ 1} achieves the highest value and Max(Ψ) = 2 + 4 = 6.

C.1. Bucket Elimination

Computing Max(Ψ) is the goal of constraint optimization for extensional constraints (Dechter, 2003), an important problem in AI. It is challenging because the number of variable assignments in dom(X ) is exponential in the number of variables. Bucket elim- ination(Dechter, 2003) is a well-known algorithm to calculate Max(Ψ). For reasons that will become clear later, we describe the bucket elimination algorithm in a slightly unusual way: in our formulation, the algorithm generates a system of equations, and its output can be extracted from the (uniquely defined) solution to these equations. The system of equations makes use of auxiliary variables Aux1, . . . , Auxm that take values

from V. The generated equations have the form Auxi = maxj∈{1,...,ki}ei,j, where ei,j is

a sum that contains only values from V or the variables Aux1, . . . , Auxi−1. Solutions to

the system of equations guarantee that Auxm ≡ Max(Ψ).

C.1. Bucket Elimination

We now describe the general algorithm and prove its correctness. Its execution depends on an order σ = hX1, . . . , Xni of the variables in X . The algorithm maintains a set

of |X | + 1 buckets B0, . . . , Bn. Bucket Bi for1 ≤ i ≤ n contains scoped functions

hS, fi such that Xi is the largest variable in S according to σ. Bucket B0 contains

functions with an empty scope. The algorithm operates in stages which are enumerated in a decreasing manner, starting at stage n+ 1 and ending at stage 0:

• Stage n + 1 (Initialization). Start with a set {Bi}ni=0of empty buckets. Place each

hS, ψi ∈ Ψ into the bucket Bi if Xiis the largest variable in S, according to σ, or

into the bucket B0 if S =∅. The resulting system of equations is initialized to an

empty system.

• Stages i = n, . . . , 1 (Elimination). Stage i eliminates variable Xi from the func-

tions in bucket Bi.

LethSj, ψji for j ∈ {1, . . . , ki} be the scoped functions currently in bucket Bi.

Construct the scope SXi = (

S

j∈{1,...,ki}Sj)\ {Xi} that contains all variables

relevant to Xi. Then construct the new function ψXi : SXi → V that represents

the contribution of all functions that depend on Xi. The definition of ψXiis added

to the generated system of equations by adding one auxiliary variable AuxXi,ν for

every ν ∈ dom(SXi) which represents the value ψXi(ν):

AuxXi,ν = max

xi∈dom(Xi)

X

j∈{1,...,ki}

ψj(νxi|Sj)

where νxi = ν ∪ {Xi 7→ xi} extends the variable assignment ν with Xi 7→ xi.

If ψj is a function in Ψ, then ψj(νxi|Sj) is an element of V. Otherwise ψj is

a previously defined function ψXi0 for i

0 > i and its value for ν0 = ν xi|Sj is

Appendix C. Maximizing a Sum of Functions

The newly defined function ψXi no longer depends on Xi but depends on all

variables in SXi, sohSXi, ψXii is added to bucket Bj if Xj is the largest variable

in SXi according to σ or to B0 if SXi =∅. Observe that j < i because SXi only

contains variables from scopes where Xiis the largest variable and SXi does not

contain Xi.

Finally, clear bucket Bi.

• Stage 0 (Termination). Let hSj, ψji for j ∈ {1, . . . , k} be the scoped functions

that currently are in bucket B0. Add the auxiliary variable AuxΨand the equation

AuxΨ=Pj∈{1,...,k}ψj, then clear bucket B0. This is analogous to the elimination

step. (All Sj are empty and the maximum is over dom(∅) = {∅}.)

Example Consider the functions f and g from the previous example again. Bucket elimination generates the following equations for the variable order σ=hX, Y i.

Aux1 = AuxY,{X7→0} = max

y∈{0,1}g(0, y)

= max{g(0, 0), g(0, 1)} Aux2 = AuxY,{X7→1} = max

y∈{0,1}g(1, y)

= max{g(1, 0), g(1, 1)} Aux3 = AuxX,∅= max

x∈{0,1}(f (x) + AuxY,{X7→x})

= max{f(0) + Aux1, f(1) + Aux2}

Aux4 = AuxΨ = AuxX,∅= Aux3

Plugging in the values of f and g gives the system of equations Aux1 = max{2, 0}

Aux2 = max{−5, 4}

Aux3 = max{3 + Aux1,2 + Aux2}

AuxΨ = Aux3

which has a unique solution with AuxΨ = 6.

Let us convince ourselves that the output of the algorithm always has the desired form:

Proposition C.1. Let Ψ be a set of scoped functions with codomain V. The system of equations generated by bucket elimination on the problemΨ has the form

Auxi = max j∈{1,...,ki}

ei,j for alli∈ {1, . . . , m},

C.1. Bucket Elimination

Proof: It is easy to see that all generated equations are maxima over sums (the definition in the termination phase can be seen as a maximum over all variables assignments for the empty scope, i.e.{∅}).

The elements of ei,j are values of functions ψj that are in the bucket Bi when Xi is

eliminated. If ψj was added to the bucket in the initialization stage, then it is a function

from Ψ and its values are from V. Otherwise the function was added by a previous elimination stage i0 > i and its definition is already part of the generated system of equations. Its value for evaluation ν is represented by Auxj,ν which was added to the

system in stage i0. 

To show that the algorithm is correct, we first show that the function introduced when eliminating a bucket is equivalent to the functions contained in the bucket.

Proposition C.2. Let Ψ be a set of scoped functions andhS1, f1i, . . . , hSn, fni be the

subset of functions whose scope includes a variableX. Let SX = (

Sn

j=1Sj)\ {X} and

ψX(ν) = maxx∈dom(X)

P

j∈{1,...,n}fj(νx|Sj) for all variable assignments ν ∈ dom(SX).

Then

Max(Ψ) ≡ Max((Ψ \ {hS1, f1i, . . . , hSn, fni}) ∪ {hSX, ψXi}).

Proof: For the maximization over values of X all functions that do not depend on X are constant and can be moved out of the maximum. Evaluations of all other variables can be restricted to the scope SX if only functions f1, . . . , fnare considered.

Max(Ψ) = max ν∈dom(X ) X hS,f i∈Ψ f(ν|S) = max

ν0∈dom(X \{X}) x∈dom(X)max

X hS,f i∈Ψ f(ν0 x|S) ≡ max ν0∈dom(X \{X})     X hS,f i∈Ψ f /∈{f1,...,fn} f(ν0|S) + max x∈dom(X) n X j=1 fj(νx0|Sj)     = max ν0∈dom(X \{X})     X hS,f i∈Ψ f /∈{f1,...,fn} f(ν0|S) + ψX(ν0|SX)    

= Max((Ψ\ {hS1, f1i, . . . , hSn, fni}) ∪ {hSX, ψXi})

 With Proposition C.2 we can show the correctness of a single elimination stage. Proposition C.3. LetΨ1 be the set of scoped functions in all buckets just before elimi-

nating bucketBi, where the value ofψXj(ν) is defined as equivalent to AuxXj,ν in the

system of equations generated so far forj > i. LetΨ2 be the analogous set after the

Appendix C. Maximizing a Sum of Functions

Proof: The functions in Ψ1 \ Ψ2 are exactly the functions whose scope includes Xi.

Only one function is added and the generated equations together with Proposition C.1 guarantee that its definition is equivalent to

ψXi(ν) = max

xi∈dom(Xi)

X

hS,f i∈Ψ1\Ψ2

f(νxi|S).

Proposition C.2 then shows the equivalence. 

We can now show correctness of the bucket elimination algorithm:

Theorem C.1. In the system of equations generated by the bucket elimination algorithm for a set of scoped functions Ψ the final variable generated (AuxΨ) is equivalent to

Max(Ψ).

Proof: For i ∈ {n, . . . , 1} let Ψi be the set of scoped functions in all buckets before

eliminating Xi, where functions ψXj for j > i are defined as equivalent to AuxXj,ν in

the system of equations so far. LetΨ0be the analogous set after eliminating X1, i.e. the

set of functions left in B0 after the elimination stage.

The initialization stage adds all elements of Ψ to the buckets, so Ψn = Ψ. An

inductive proof using Proposition C.3 shows Max(Ψ) = Max(Ψn) ≡ Max(Ψ0). Since

those functions all have the empty scope, the maximum over their sum is just their sum, which is the definition of AuxΨgenerated in the termination stage.