The estimation of the distance
between each fact and the Goals and the computation of the lists of the
related facts for each facts of a problem are performed through the following
algorithm:
The Pre-Processing Algorithm
Input: The action and predicate definitions
of a domain and the objects of a problem.
Output: The distance estimate from the goals
dist(p) and the related facts rel(p) for each ground fact p of a problem.
1. Let Actions be the set of all inverted
ground actions in the given problem. For each a Î Actions,
set dist(a)=+₯.
2. Let Agenda
be a list of inverted actions. Set Agenda=Æ.
3. Let Facts be the set of all problem's ground
facts. For each f Î Facts set dist(f)= +₯.
4. For each f Î Goals set dist(f)=0 and rel(f)=Goals.
5. For each action a Î Actions,
if Aggregate(Pre(a))<+₯, then set dist(a)=Aggregate(Pre(a))+1 and add a at the end of
the Agenda.
6. While Agenda
¹ Æ do:
a) Extract the
first action from the Agenda, say a.
b) For every fact f
Î Add(a), if dist(f)>dist(a), then:
dist(f)=dist(a)
rel(f) = Pre(a) È rel(Pre(a)) È Add(a)\Del(a)
For every action b Î Actions,
such that f Î Pre(b),
if Aggregate(Pre(b))+1<dist(b),
then dist(b)=Aggregate(Pre(b))+1
and push action b at the end of the Agenda.
The Agenda
works on a FIFO basis. An action can be re-inserted in the Agenda if its
cost becomes smaller. Thus, each fact can be achieved several times, each time
with a smaller cost. The cost of applying the Pre-Processing Algorithm is
polynomial in the number of problem ground facts and ground actions.
Proposition 5. The Pre-Processing Algorithm
preserves Axiom 2.
Proof: In step 6b, the cost of applying an action is
set to be equal to the cost of achieving simultaneously the preconditions of
the action plus one. This cost is assigned to the add effects of the action,
except if lower costs have already been assigned to them. Thus, Axiom 2 is
preserved. n
Proposition 6. Function Aggregate preserves Axiom 1.
Proof: We will prove Proposition 6 by induction.
Axiom 1 holds for the Goals, which have zero distances from themselves and
are related to each other. Besides, Propositions 3 and 4 and Corollaries 1, 2
and 3 hold also for them. Suppose next that Axiom 1 and all the induced
Propositions and Corollaries hold for the currently achieved facts Facts.
It suffices to prove that for any action a, such that Pre(a)
Í Facts, Axiom 1 holds for the new set of
achieved facts Facts'=Facts È Add(a).
Consider a set of
facts P Í Facts'. We will prove that
function Aggregate preserves
Axiom 1, with regard to the randomly selected set P. Let p be the
fact with the maximum distance among the facts of P. According to the
definition of Aggregate function,
it suffices to prove that p or another fact of equal distance is
included in M2.
If p Î P\Add(a), then for every
other fact qÎP\Add(a), if pq, then dist(q)³dist(p) (according to Proposition 3, which
holds for Facts) and finally dist(q)=dist(p),
because p has the maximum distance among the facts of P (the same
rationale can be used in the case where there is a sequence of facts q1,
q2, ..., qN, such that p
q1 and qi
qi+1, i=1, 2, ..., N-1). If q ÎAdd(a) and p
q, p would be a precondition of a, or a
related fact of a precondition of a. However, in that case it would not
be possible that p
q, because the distance of q would be greater than
the cost of p (according to Axiom 2, which holds for the preconditions
of action a) and this is in contradiction with the hypothesis that p
has the maximum distance among the facts of P.
Let us consider the
case where p Î Add(a). If p
has just been firstly achieved, then the only facts q, for which pq hold, are certainly the other just achieved or
re-achieved add effects of action a, which have the same application
cost. If p has been re-achieved by a with smaller cost, then it
is impossible to hold p
q for another fact q Î P\Add(a).
Actually, in this hypothetical case we would have dist(q)³distOLD(p), since Proposition 3 holds for q
and the previous distance of p, and distOLD(p)>distNEW(p),
so dist(q)>distNEW(p), which is in
contradiction with the hypothesis that p has the maximum distance among
the facts of P. Therefore, in any case, p or another fact of
equal cost is included in M2 and the cost of achieving
simultaneously the facts of P is equal to or higher than their maximum
distance. n
We close this section
by mentioning the two types of facts, the static facts and the dynamic
facts, that can be found in a problem. The first type concerns the facts
that are neither added nor deleted by any action, while the second concerns the
rest of the facts. Grt classifies
automatically the facts, by analyzing the action schemas of the domain. All the
procedures presented in Section 2, i.e. the distance estimates and the related
facts, concern only the dynamic facts.
Ioannis
Refanidis
14-8-2001