6.5 Partial-Order Planning

The forward and regression planners enforce a total ordering on actions at all stages of the planning process. The CSP planner commits to the particular time that the action will be carried out. This means that those planners have to commit to an ordering of actions when adding them to a partial plan, even if there is no particular reason to put one action before another.

A partial-order planner maintains a partial ordering between actions and only commits to an ordering between actions when forced. This is sometimes also called a nonlinear planner, which is a misnomer because such planners often produce a linear plan.

Because the same action may be used a number of times in the same plan, for example, the robot may need to move clockwise a number of times, the partial ordering will be between action instances, where an action instance is just a pair of an action and an integer, which we will write as a⁢c⁢t⁢#⁢i. By the preconditions and effects of the action instance, we mean the precondition and the effects of the action.

A partial ordering is a binary relation that is transitive and asymmetric. A partial-order plan is a set of action instances together with a partial ordering between them, representing a “before” relation on action instances. Write a⁢c⁢t0<a⁢c⁢t1 if action instance a⁢c⁢t0 is before action instance a⁢c⁢t1 in the partial order. This means that the action of a⁢c⁢t0 must occur before the action of a⁢c⁢t1. The aim of the planner is to produce a partial ordering of the action instances so that any total ordering that is consistent with the partial ordering will solve the goal from the initial state.

There are two special action instances, s⁢t⁢a⁢r⁢t, that achieves the relations that are true in the initial state, and f⁢i⁢n⁢i⁢s⁢h, whose precondition is the goal to be solved. Every other action instance is after s⁢t⁢a⁢r⁢t and before f⁢i⁢n⁢i⁢s⁢h in the partial ordering. The use of these as action instances means that the algorithm does not require special cases for the initial situation and for the goals. When the preconditions of f⁢i⁢n⁢i⁢s⁢h are achieved, the goal is solved.

Any action instance, other than s⁢t⁢a⁢r⁢t or f⁢i⁢n⁢i⁢s⁢h, will be in a partial-order plan to achieve a precondition of an action instance in the plan. Each precondition P of an action instance a⁢c⁢t1 in the plan is either true in the initial state, and so achieved by s⁢t⁢a⁢r⁢t, or there will be an action instance a⁢c⁢t0 in the plan that achieves P. The action instance a⁢c⁢t0 that achieves P must be before a⁢c⁢t1; that is, a⁢c⁢t0<a⁢c⁢t1. To be correct, the algorithm must also ensure that nothing makes P false in between a⁢c⁢t0 and a⁢c⁢t1.

A causal link is a triple ⟨a⁢c⁢t0,P,a⁢c⁢t1⟩, where a⁢c⁢t0 and a⁢c⁢t1 are action instances and P is a V⁢a⁢r=v⁢a⁢l assignment that is in the precondition of a⁢c⁢t1, and in the effect of a⁢c⁢t0. This means that a⁢c⁢t0 makes P hold for a⁢c⁢t1. With this causal link, any other action instance that makes P false must either be before a⁢c⁢t0 or after a⁢c⁢t1.

Informally, a partial-order planner works as follows. Begin with the action instances s⁢t⁢a⁢r⁢t and f⁢i⁢n⁢i⁢s⁢h and the partial order s⁢t⁢a⁢r⁢t<f⁢i⁢n⁢i⁢s⁢h. The planner maintains an agenda that is a set of ⟨P,A⟩ pairs, where A is an action instance in the plan and P is a variable-value assignment that is a precondition of A that remains to be achieved. Initially, the agenda contains pairs ⟨G,f⁢i⁢n⁢i⁢s⁢h⟩, where G is an assignment that must be true in the goal state.

At each stage in the planning process, a pair ⟨G,a⁢c⁢t1⟩ is chosen from the agenda, where P is in the precondition for action instance a⁢c⁢t1. Then an action instance, a⁢c⁢t0, is chosen to achieve P. That action instance is either already in the plan – it could be the s⁢t⁢a⁢r⁢t action, for example – or it is a new action instance that is added to the plan. Action instance a⁢c⁢t0 must happen before a⁢c⁢t1 in the partial order. The planner adds a causal link that records that a⁢c⁢t0 achieves P for action a⁢c⁢t1. Any action in the plan that makes P false must happen either before a⁢c⁢t0 or after a⁢c⁢t1. If a⁢c⁢t0 is a new action, its preconditions are added to the agenda, and the process continues until the agenda is empty.

The algorithm P⁢a⁢r⁢t⁢i⁢a⁢l⁢_⁢o⁢r⁢d⁢e⁢r⁢_⁢p⁢l⁢a⁢n⁢n⁢e⁢r is given in Figure 6.6. This is a non-deterministic procedure. The “choose” and the “either …or …” form choices that must be searched over. There are two choices that require search:

  • •

    which action is chosen to achieve P

  • •

    whether an action instance that deletes P happens before a⁢c⁢t0 or after a⁢c⁢t1.

1: non-deterministic procedure Partial_order_planner(A⁢s,G⁢s)
2:   Inputs
3:    A⁢s: possible actions
4:    G⁢s: goal, a set of variable-value assignments to achieve   
5:   Output
6:    linear plan to achieve G⁢s
7:   Local
8:    A⁢g⁢e⁢n⁢d⁢a: set of ⟨P,A⟩ pairs where P is an atom and A an action instance
9:    A⁢c⁢t⁢i⁢o⁢n⁢s: set of action instances in the current plan
10:    C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s: set of temporal constraints on action instances
11:    C⁢a⁢u⁢s⁢a⁢l⁢L⁢i⁢n⁢k⁢s: set of ⟨a⁢c⁢t0,P,a⁢c⁢t1⟩ triples   
12:   A⁢g⁢e⁢n⁢d⁢a:=⁢{⟨G,f⁢i⁢n⁢i⁢s⁢h⟩:G∈G⁢s}
13:   A⁢c⁢t⁢i⁢o⁢n⁢s:=⁢{s⁢t⁢a⁢r⁢t,f⁢i⁢n⁢i⁢s⁢h}
14:   C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s:=⁢{s⁢t⁢a⁢r⁢t<f⁢i⁢n⁢i⁢s⁢h}
15:   C⁢a⁢u⁢s⁢a⁢l⁢L⁢i⁢n⁢k⁢s:=⁢{}
16:   repeat
17:    select and remove ⟨G,a⁢c⁢t1⁢#⁢i⟩ from A⁢g⁢e⁢n⁢d⁢a
18:    either
19:      choose a⁢c⁢t0⁢#⁢j∈A⁢c⁢t⁢i⁢o⁢n⁢s such that a⁢c⁢t0 achieves G
20:    Or
21:      choose a⁢c⁢t0∈A⁢s such that a⁢c⁢t0 achieves G
22:      select unique integer j
23:      A⁢c⁢t⁢i⁢o⁢n⁢s:=⁢A⁢c⁢t⁢i⁢o⁢n⁢s∪{a⁢c⁢t0⁢#⁢j}
24:      C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s:=⁢a⁢d⁢d⁢_⁢c⁢o⁢n⁢s⁢t⁢(s⁢t⁢a⁢r⁢t<a⁢c⁢t0⁢#⁢j,C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s)
25:      for each C⁢L∈C⁢a⁢u⁢s⁢a⁢l⁢L⁢i⁢n⁢k⁢s do
26:       C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s:=⁢p⁢r⁢o⁢t⁢e⁢c⁢t⁢(C⁢L,a⁢c⁢t0⁢#⁢j,C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s)      
27:      Agenda:=Agenda∪{⟨P,act0#j⟩:P is a precondition of act0}    
28:    C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s:=⁢a⁢d⁢d⁢_⁢c⁢o⁢n⁢s⁢t⁢(a⁢c⁢t0⁢#⁢j<a⁢c⁢t1⁢#⁢i,C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s)
29:    n⁢e⁢w⁢_⁢c⁢l:=⁢⟨a⁢c⁢to⁢#⁢j,G,a⁢c⁢t1⁢#⁢i⟩
30:    C⁢a⁢u⁢s⁢a⁢l⁢L⁢i⁢n⁢k⁢s:=⁢C⁢a⁢u⁢s⁢a⁢l⁢L⁢i⁢n⁢k⁢s∪{n⁢e⁢w⁢_⁢c⁢l}
31:    for each A∈A⁢c⁢t⁢i⁢o⁢n⁢s do
32:      C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s:=⁢p⁢r⁢o⁢t⁢e⁢c⁢t⁢(n⁢e⁢w⁢_⁢c⁢l,A,C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s)    
33:   until A⁢g⁢e⁢n⁢d⁢a={}
34:   return total ordering of A⁢c⁢t⁢i⁢o⁢n⁢s consistent with C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s
Figure 6.6: Partial-order planner

The function a⁢d⁢d⁢_⁢c⁢o⁢n⁢s⁢t⁢(A0<A1,C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s) returns the constraints formed by adding the constraint A0<A1 to C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s, and it fails if A0<A1 is incompatible with C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s. There are many ways this function can be implemented. See Exercise 6.11.

The function p⁢r⁢o⁢t⁢e⁢c⁢t⁢(⟨A0,G,A1⟩,A) checks whether A≠A0, A≠A1, and the effect of A is inconsistent with G. If so, either A<A0 is added to the set of constraints or A1<A is added to the set of constraints. This is a non-deterministic choice that is searched over.

Example 6.18.

Consider the goal of Sam not wanting coffee and no mail waiting (i.e., ¬s⁢w⁢c∧¬m⁢w), where in the initial state Rob is in the lab, Sam wants coffee, Rob does not have coffee, there is mail waiting, and Rob does not have mail, i.e., R⁢L⁢o⁢c=l⁢a⁢b, s⁢w⁢c, ¬r⁢h⁢c, m⁢w, ¬r⁢h⁢m.

In the following, instances of action A⁢c⁢t are written as A⁢c⁢t⁢#⁢n, where n is a unique integer.

Initially, the agenda is

{⟨¬s⁢w⁢c,f⁢i⁢n⁢i⁢s⁢h⟩,⟨¬m⁢w,f⁢i⁢n⁢i⁢s⁢h⟩}.

Suppose ⟨¬s⁢w⁢c,f⁢i⁢n⁢i⁢s⁢h⟩ is chosen and removed from the agenda. One action can achieve ¬s⁢w⁢c, namely deliver coffee, d⁢c, with preconditions o⁢f⁢f and r⁢h⁢c. So it inserts an instance, say d⁢c⁢#⁢6, into the plan. After the first time through the repeat loop, A⁢g⁢e⁢n⁢d⁢a contains

{⟨o⁢f⁢f,d⁢c⁢#⁢6⟩,⟨r⁢h⁢c,d⁢c⁢#⁢6⟩,⟨¬m⁢w,f⁢i⁢n⁢i⁢s⁢h⟩}.

At this stage, the value of C⁢o⁢n⁢s⁢t⁢r⁢a⁢i⁢n⁢t⁢s is {s⁢t⁢a⁢r⁢t<f⁢i⁢n⁢i⁢s⁢h,s⁢t⁢a⁢r⁢t<d⁢c⁢#⁢6,d⁢c⁢#⁢6<f⁢i⁢n⁢i⁢s⁢h}. There is one causal link, ⟨d⁢c⁢#⁢6,¬s⁢w⁢c,f⁢i⁢n⁢i⁢s⁢h⟩. This causal link means that no action that undoes ¬s⁢w⁢c is allowed to happen between d⁢c⁢#⁢6 and f⁢i⁢n⁢i⁢s⁢h.

Suppose ⟨¬m⁢w,f⁢i⁢n⁢i⁢s⁢h⟩ is chosen from the agenda. One action can achieve this, p⁢u⁢m, with precondition {m⁢w,R⁢L⁢o⁢c=m⁢r}. The algorithm constructs a new action instance, say p⁢u⁢m⁢#⁢7. The causal link ⟨p⁢u⁢m⁢#⁢7,¬m⁢w,f⁢i⁢n⁢i⁢s⁢h⟩ is added to the set of causal links; ⟨m⁢w,p⁢u⁢m⁢#⁢7⟩ and ⟨m⁢r,p⁢u⁢m⁢#⁢7⟩ are added to the agenda.

Suppose ⟨m⁢w,p⁢u⁢m⁢#⁢7⟩ is chosen from the agenda. The action s⁢t⁢a⁢r⁢t achieves m⁢w, because m⁢w is true initially. The causal link ⟨s⁢t⁢a⁢r⁢t,m⁢w,p⁢u⁢m⁢#⁢7⟩ is added to the set of causal links. Nothing is added to the agenda.

At this stage, there is no ordering imposed between d⁢c⁢#⁢6 and p⁢u⁢m⁢#⁢7.

Suppose ⟨o⁢f⁢f,d⁢c⁢#⁢6⟩ is removed from the agenda. There are two actions that can achieve o⁢f⁢f: m⁢c⁢_⁢c⁢s with preconditions c⁢s, and m⁢c⁢c⁢_⁢l⁢a⁢b with preconditions l⁢a⁢b. The algorithm searches over these choices. Suppose it chooses the action instance m⁢c⁢_⁢c⁢s⁢#⁢9. The causal link ⟨m⁢c⁢_⁢c⁢s⁢#⁢9,o⁢f⁢f,d⁢c⁢#⁢6⟩ is added.

The first violation of a causal link occurs when a move action is used to achieve ⟨m⁢r,p⁢u⁢m⁢#⁢7⟩. This action violates the causal link ⟨m⁢c⁢_⁢c⁢s⁢#⁢9,o⁢f⁢f,d⁢c⁢#⁢6⟩, and so must happen after d⁢c⁢#⁢6 (the robot goes to the mail room after delivering coffee) or before m⁢c⁢_⁢c⁢s⁢#⁢9.

Eventually, it finds a plan of action instances, such as

s⁢t⁢a⁢r⁢t;m⁢c⁢_⁢l⁢a⁢b⁢#⁢15;p⁢u⁢m⁢#⁢7;m⁢c⁢_⁢m⁢r⁢#⁢40;p⁢u⁢c⁢#⁢11;m⁢c⁢_⁢c⁢s⁢#⁢9;d⁢c⁢#⁢6;f⁢i⁢n⁢i⁢s⁢h.

This is the only total ordering consistent with the partial ordering.

A partial-order planner works particularly well when no ordering of actions can achieve a goal, as it does not need to search over all permutations of the actions. It also works well when many orderings can solve the goal, in which case it can find a flexible plan for the robot.