3. Propositional Representation STRIPS and FDR

Exercise 1: Blocks World belongs to the oldest planning domain. There are several blocks on a table, and we can build piles out of those blocks. I simplified the domain a bit so that it has only two action schemata: stack and unstack. stack takes a block lying on the table (there cannot be any other block above it) and puts it on the top of any pile (even a single block forms a pile). unstack is a reversed action schema. It removes a block on top of a pile and places it on the table. Consider the following problem instance:

Model this problem in STRIPS.

Solution

Exercise 2: Model the above planning task as an FDR task $\Pi=\langle V,A,s_0,g\rangle$.

Solution

Note that we use names of the facts and variable values like $on(A,B)$. We did so to make it more readable for humans as it has a clear meaning. However, when we code a planner, numbers usually index the facts or variable values, and the planner works only with the numbers.

In the second homework assignment, you will implement a planner for FDR tasks. The input for your planner will be a SAS file created by the Fast Downward planner from PDDL. This file is just the equivalent FDR representation of the PDDL task. If you want to create this file, execute the following command:

./fast-downward.sif domain.pddl problem.pddl
It creates a file called output.sas. Its syntax is described here.

Consider a PDDL formulation of the above-described Blocks World domain. The domain file:

(define (domain BLOCKS)
  (:requirements :strips)
  (:predicates (on ?x ?y)
               (clear ?x)
               (ontable ?x)
               )
 
  (:action stack
             :parameters (?x ?y)
             :precondition (and (clear ?x) (clear ?y) (ontable ?x) (not (= ?x ?y)))
             :effect
             (and
                   (not (clear ?y))
                   (not (ontable ?x))
                   (on ?x ?y)))
 
  (:action unstack
             :parameters (?x ?y)
             :precondition (and (on ?x ?y) (clear ?x))
             :effect
             (and  (clear ?y)
                   (ontable ?x)
                   (not (on ?x ?y)))))

The problem file:

(define (problem p01)
(:domain BLOCKS)
(:objects A B C)
(:init (clear C)
       (clear B)
       (ontable A)
       (ontable B)
       (on C A))
(:goal (and (on A B) (on B C)))
)

If we ask Fast Downward to create the FDR representation, it generates a SAS file built from several sections. The header contains a version (always 3 for us) and the metric expressing whether the task uses action costs.

begin_version
3
end_version
begin_metric
0
end_metric

Next, the file defines FDR variables and their domains. The first number 6 says that there are six variables. For each variable, there is a name like var0, you can ignore the value -1, the number of its values, and the values themselves.

6
begin_variable
var0
-1
3
Atom on(c, a)
Atom on(c, b)
Atom ontable(c)
end_variable
begin_variable
var1
-1
2
Atom clear(a)
NegatedAtom clear(a)
end_variable

... other variables

Next, there could be several sections with identified mutex groups. You can safely ignore them in your planner.

The sections with the initial state and goal follow. The initial state is just a sequence of numbers indexing the values of all variables starting from 0. The goal section tells us that goal states must assign to var4 the value from its domain indexed by 0 and to var5 the value indexed by 1.

begin_state
0
1
0
0
2
2
end_state
begin_goal
2
4 0
5 1
end_goal

Finally, there is a section defining actions (called operators). The first number tells us that there are 12 operators. Each operator has its name, like stack a b. The last number before end_operator is the cost of the action. The remaining numbers encode the precondition and effect; explained below.

12
begin_operator
stack a b
1
1 0
2
0 2 0 1
0 4 2 0
1
end_operator
begin_operator
stack a c
1
1 0
2
0 3 0 1
0 4 2 1
1
end_operator

... other operators

Due to historical reasons, the SAS file splits the variables into two parts. The first defines prevailing variables, i.e., variables whose values must have a certain value to execute the action, but the action does not change the value. The second part consists of the variables whose values are changed by the action. Consider again the action stack a b above. The rows

1
1 0
tell us that there is one prevailing variable, the variable var1 whose value must be 0. If you check the variable var1 and its values above, you can see that this means that the block a must be clear.

The remaining rows

2
0 3 0 1
0 4 2 1
tell us that there are two variables whose values are changed by the action, namely var3 and var4. The initial zeros on the second and third rows can be ignored. It expresses the number of conditional effects we will not consider in the homework assignment. The remaining numbers define that the value of var3 must be 0, which will be changed to 1. Analogously, the value of var4 must be 2 and will be changed to 1. Sometimes, the number on the right of the number of the variable can be -1. In that case, the variable's value can be arbitrary but will be changed based on the last number on the row.

courses/pui/tutorials/tutorial03.txt · Last modified: 2024/02/26 22:42 by xhorcik