0% found this document useful (0 votes)
8 views9 pages

A13 Solved

The document contains a series of problems related to planning and heuristics in robotics and artificial intelligence. It discusses admissible heuristics for a robot moving balls between rooms, partial order planning with causal links, STRIPS planning for moving and painting objects, and encoding the Tower of Hanoi task in PDDL. Additionally, it includes a STRIPS planning problem involving a road map of Australia, requiring visits to specific cities starting from Sydney.

Uploaded by

dis cord
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

A13 Solved

The document contains a series of problems related to planning and heuristics in robotics and artificial intelligence. It discusses admissible heuristics for a robot moving balls between rooms, partial order planning with causal links, STRIPS planning for moving and painting objects, and encoding the Tower of Hanoi task in PDDL. Additionally, it includes a STRIPS planning problem involving a road map of Australia, requiring visits to specific cities starting from Sydney.

Uploaded by

dis cord
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Assignment13 – Planning

Problem 13.1 (Admissible Heuristics in Gripper)


Consider a problem where we have two rooms, A and B, one robot initially lo-
cated in room A, and 𝑛 balls that are also initially located in room A. The goal de-
mands that all balls be located in room B. The robot can move between the rooms,
it can pick up balls provided its gripper hand is free (see below), and it can drop a
ball it is currently holding.
Answer the following questions with yes/no. Justify your answer.
1. Say that the robot has only one gripper, so that it can only hold one ball at a
time. Is the number of balls not yet in room B an admissible heuristic?

Solution: Yes: The solution must contain at least one separate drop action
for each ball that is not yet currently in room B.

2. Say that the robot has only one gripper, so that it can only hold one ball at a
time. Is the number of balls still in room A, multiplied by 4, an admissible
heuristic?

Solution: No: For example, in the initial state for 𝑛 = 1, the length of an
optimal solution is 3 (pick, move A B, drop), whereas the value of this heuristic
is 4.

3. Say now the robot has two grippers, and it takes only one action to pick up
two balls, and only one action to drop two balls. Is the number of balls not
yet in room B an admissible heuristic?

Solution: No: For example, if all but 2 balls are already in room B, and the
robot is in room B and holds the 2 remaining balls, then the length of an
optimal solution is 1, whereas the value of this heuristic is 2.

4. Say now the robot has two grippers, but picks up/drops each ball individually,
so that it needs two actions to take two balls, and two actions to drop two balls.
Is the number of balls not yet in room B an admissible heuristic?

Solution: Yes, for the same reason as in (a).

1
Problem 13.2 (Partial Order Planning)
Consider the planning task (𝑃, 𝐴, 𝐼, 𝐺) where
• facts 𝑃 = {𝑝, 𝑞, 𝑟, 𝑠}
• actions 𝐴 = {𝑋, 𝑌, 𝑍} where the preconditions (above the box) and effects
(below the box) of the actions are given by

𝑝 𝑞 𝑝
X Y Z
𝑞 ¬𝑝, 𝑟 ¬𝑝, 𝑠

• initial state 𝐼 = {𝑝}


• goal 𝐺 = {𝑟, 𝑠}
Our goal is to build a partially ordered plan. Recall that the steps consist of the
actions plus the start and finish step; and that the effect of an action consists of the
added facts and the negations of the deleted facts.
1. Give the start step and finish step.

𝑟, 𝑠
Solution: Start
Finish
𝑝

2. Give all causal links between the steps.

𝑝 𝑝 𝑞 𝑟 𝑠
Solution: 𝑆𝑡𝑎𝑟𝑡 → 𝑋, 𝑆𝑡𝑎𝑟𝑡 → 𝑍, 𝑋 → 𝑌, 𝑌 → 𝐹𝑖𝑛𝑖𝑠ℎ, 𝑍 → 𝐹𝑖𝑛𝑖𝑠ℎ

3. Give an example where a step clobbers a link.

𝑝
Solution: Both steps 𝑌 and 𝑍 clobber both of the links →.

4. Give the temporal ordering that yields a partially ordered plan that solves the
task.

Solution: 𝑋 ≺ 𝑍 and 𝑍 ≺ 𝑌

Problem 13.3 (STRIPS)

2
Consider a set of objects 𝑂𝑏𝑗 = {1, 2, 3, 4, 5, 6} that can be at location A or B.
Currently all objects are at location 𝐴 and unpainted. Eventually all objects are
needed in location 𝐴 and painted. At location 𝐵, a painting station is available that
can paint up to 3 objects at a time. A robot is available (currently at location 𝐴) that
can move up to 2 objects at a time from one location to another.

Robot
OO Painter
𝐴 𝐵 O
123456 O
O

We formalize this problem as a STRIPS task (𝑃, 𝐴, 𝐼, 𝐺) where the set 𝑃 of facts
contains
• at(𝑙, 𝑜) for 𝑙 ∈ {𝐴, 𝐵} and 𝑜 ∈ (𝑂𝑏𝑗 ∪ {𝑅𝑜𝑏𝑜𝑡})
• painted(𝑜) for 𝑜 ∈ 𝑂𝑏𝑗
and the set 𝐴 of actions contains
• move(𝑙, 𝑚, 𝑂) for 𝑙, 𝑚 ∈ {𝐴, 𝐵}, 𝑂 ⊆ 𝑂𝑏𝑗, #(𝑂) ≤ 2 given by
– precondition: at(𝑙, 𝑜) for all 𝑜 ∈ (𝑂 ∪ {𝑅𝑜𝑏𝑜𝑡})
– add list: at(𝑚, 𝑜) for all 𝑜 ∈ (𝑂 ∪ {𝑅𝑜𝑏𝑜𝑡})
– delete list: same as precondition
• paint(𝑂) for 𝑂 ⊆ 𝑂𝑏𝑗, #(𝑂) ≤ 3 given by
– precondition: at(𝐵, 𝑜) for all 𝑜 ∈ 𝑂
– add list: painted(𝑜) for all 𝑜 ∈ 𝑂
– delete list: nothing
1. Give the initial state 𝐼 and the goal 𝐺.

Solution: at(𝐴, 𝑜) for all 𝑜 ∈ (𝑂𝑏𝑗 ∪ {𝑅𝑜𝑏𝑜𝑡}), goal: at(𝐴, 𝑜), painted(𝑜) for
all 𝑜 ∈ 𝑂𝑏𝑗

2. After applying move(𝐴, 𝐵, {1, 2}) in 𝐼, multiple actions are applicable. Give
two of them.

Solution: The applicable actions are move(𝐵, 𝐴, 𝑂) and paint(𝑂) for any
𝑂 ⊆ {1, 2}. Note: Among those, move(𝐵, 𝐴, ∅) and paint({1, 2}) are the not-
obviously-suboptimal ones and pondering those helps with the next subques-
tion.

3
3. Give the value ℎ∗ (𝐼).

Solution: 9. An optimal plan is move(𝐴, 𝐵, 𝑂), paint(𝑂), move(𝐵, 𝐴, 𝑂), re-


peated 3 times for disjoint sets 𝑂. move(𝐴, 𝐵, {1, 2}), move(𝐵, 𝐴, ∅), move(𝐴, 𝐵, {3, 4}),
paint({1, 2, 3}), move(𝐵, 𝐴, {1, 2}), move(𝐴, 𝐵, {5, 6}), paint({4, 5, 6}), move(𝐵, 𝐴, {3, 4}),
move(𝐴, 𝐵, ∅), move(𝐵, 𝐴, {5, 6}) takes 10 steps and is not optimal, but in-
duces an optimal relaxed plan, in which some moves actions can be dropped.

4. Give the value ℎ+ (𝐼).

Solution: 5. An optimal relaxed plan moves 2 objects 3 times, paints twice.

5. Let 𝑈𝑠 (𝑙) and 𝑃𝑠 (𝑙) be the numbers of unpainted and painted objects at loca-
tion 𝑙 in state 𝑠. For each of the following heuristic ℎ(𝑠), say if it is admissible.
1. 2 ⋅ 𝑈𝑠 (𝐴) + 𝑈𝑠 (𝐵)
2. 0
3. 𝑈𝑠 (𝐴)+roundDown((𝑈𝑠 (𝐴)+𝑈𝑠 (𝐵))∕3)+roundDown((𝑃𝑠 (𝐵)+𝑈𝑠 (𝐵))∕2)

Solution: 2 and 3.
1. too pessimistic, e.g., two unpainted objects in location 𝐴 need 3 steps,
heuristic yields 4
2. trivially admissible but useless
3. a good heuristic: unpainted objects in location 𝐴 (resp. any objects in
location 𝐵) need to be moved at least twice (resp. once) in groups of at
most 2; unpainted objects must be painted in groups of at most 3.

Problem 13.4
Encode the Tower of Hanoi task below into PDDL. There are five discs and the
goal is to move them from left to right according to the rules of Tower of Hanoi.
Solve the PDDL encoding using FF. As your solution, submit a print-out of the
following 3 files: The PDDL domain file “towersofhanoi-domain.pddl”; the PDDL
problem file “towersofhanoi-problem.pddl”, as well as a file “towersofhanoi-output.txt”
containing FF’s output.

4
Solution: PDDL Domain file:
(define (domain hanoi)
(:requirements :strips)
(:predicates (clear ?x)
(on ?x ?y)
(smaller ?x ?y)
)
(:action move
:parameters (?disc ?from ?to)
:precondition (and (smaller ?disc ?to)
(on ?disc ?from)
(clear ?disc)
(clear ?to)
)
:effect (and (clear ?from)
(on ?disc ?to)
(not (on ?disc ?from))
(not (clear ?to))
)
)
)
PDDL Problem file:
(define (problem hanoi)
(:domain hanoi)
(:objects p1 p2 p3 d1 d2 d3 d4 d5)
(:init
(smaller d1 p1)(smaller d1 p2)(smaller d1 p3)
(smaller d2 p1)(smaller d2 p2)(smaller d2 p3)
(smaller d3 p1)(smaller d3 p2)(smaller d3 p3)
(smaller d4 p1)(smaller d4 p2)(smaller d4 p3)
(smaller d5 p1)(smaller d5 p2)(smaller d5 p3)
(smaller d1 d2)(smaller d1 d3)(smaller d1 d4)(smaller d1 d5)
(smaller d2 d3)(smaller d2 d4)(smaller d2 d5)
(smaller d3 d4)(smaller d3 d5)
(smaller d4 d5)

5
(clear p2)(clear p3)(clear d1)
(on d1 d2)(on d2 d3)(on d3 d4)
(on d4 d5)(on d5 p1)
)
(:goal
(and (on d1 d2)(on d2 d3)(on d3 d4)(on d4 d5)(on d5 p3) )
)
)
The output of FF: (some white spaces removed)
parsing domain file
domain 'HANOI' defined
... done.
ff: parsing problem file
problem 'HANOI' defined
... done.

Cueing down from goal distance: 5 into depth [1]


4 [1][2][3][4]
3 [1]
Enforced Hill-climbing failed !
switching to Best-first Search now.
advancing to distance : 5
4
3
2
1
0
ff: found legal plan as follows
step 0: MOVE D1 D2 P3
1: MOVE D2 D3 P2
2: MOVE D1 P3 D2
3: MOVE D3 D4 P3
4: MOVE D1 D2 D4
5: MOVE D2 P2 D3
6: MOVE D1 D4 D2
7: MOVE D4 D5 P2
8: MOVE D1 D2 D4
9: MOVE D2 D3 D5
10: MOVE D1 D4 D2
11: MOVE D3 P3 D4
12: MOVE D1 D2 P3
13: MOVE D2 D5 D3
14: MOVE D1 P3 D2
15: MOVE D5 P1 P3
16: MOVE D1 D2 P1
17: MOVE D2 D3 D5
18: MOVE D1 P1 D2
19: MOVE D3 D4 P1
20: MOVE D1 D2 D4
21: MOVE D2 D5 D3
22: MOVE D1 D4 D2

6
23: MOVE D4 P2 D5
24: MOVE D1 D2 D4
25: MOVE D2 D3 P2
26: MOVE D1 D4 D2
27: MOVE D3 P1 D4
28: MOVE D1 D2 P1
29: MOVE D2 P2 D3
30: MOVE D1 P1 D2

time spent: 0.00 seconds instantiating 200 easy, 0 hard action templates
0.00 seconds reachability analysis, yielding 33 facts and 135 actions
0.00 seconds creating final representation with 32 relevant facts
0.00 seconds building connectivity graph
0.00 seconds searching, evaluating 101 states, to a max depth of 4
0.00 seconds total time

Problem 13.5 (STRIPS Planning)


Consider the road map of Australia given below. The task here is to visit Darwin,
Brisbane and Perth, starting from Sydney.

The task is formalized in STRIPS as follows. Facts are 𝑎𝑡(𝑥) and 𝑣𝑖𝑠𝑖𝑡𝑒𝑑(𝑥)
where 𝑥 ∈ {𝐴𝑑𝑒𝑙𝑎𝑖𝑑𝑒, 𝐵𝑟𝑖𝑠𝑏𝑎𝑛𝑒, 𝐷𝑎𝑟𝑤𝑖𝑛, 𝑃𝑒𝑟𝑡ℎ, 𝑆𝑦𝑑𝑛𝑒𝑦}. The initial state is {𝑎𝑡(𝑆𝑦𝑑𝑛𝑒𝑦), 𝑣𝑖𝑠𝑖𝑡𝑒𝑑(𝑆𝑦𝑑𝑛𝑒𝑦)},
the goal is {𝑣𝑖𝑠𝑖𝑡𝑒𝑑(𝐵𝑟𝑖𝑠𝑏𝑎𝑛𝑒), 𝑣𝑖𝑠𝑖𝑡𝑒𝑑(𝐷𝑎𝑟𝑤𝑖𝑛), 𝑣𝑖𝑠𝑖𝑡𝑒𝑑(𝑃𝑒𝑟𝑡ℎ)}. The actions move
along the roads, i.e., they are of the form
𝑑𝑟𝑖𝑣𝑒(𝑥, 𝑦) ∶ ({𝑎𝑡(𝑥)}, {𝑎𝑡(𝑦), 𝑣𝑖𝑠𝑖𝑡𝑒𝑑(𝑦)}, {𝑎𝑡(𝑥)})
where 𝑥 and 𝑦 have a direct connection according to the road map. Each road
can be driven in both directions, except for the road between Adelaide and

7
Perth, which can only be driven from Adelaide to Perth, not in the opposite
direction. In your answers to the following questions, use the abbreviations “v”
for “visited”, and “Ad”, “Br”, “Da”, “Pe”, “Sy” for the cities.
1. Give an optimal (shortest) plan for the initial state, if one exists; if no plan
exists, argue why that is the case. Give an optimal (shortest) relaxed plan for
the initial state, if one exists; if no relaxed plan exists, argue why that is the
case. What is the ℎ∗ value and the ℎ+ value of the initial state? (When writing
up a plan or relaxed plan, it suffices to give the sequence of action names.)

Solution: Optimal plan: 𝑑𝑟𝑖𝑣𝑒(𝑆𝑦, 𝐵𝑟), 𝑑𝑟𝑖𝑣𝑒(𝐵𝑟, 𝑆𝑦), 𝑑𝑟𝑖𝑣𝑒(𝑆𝑦, 𝐴𝑑), 𝑑𝑟𝑖𝑣𝑒(𝐴𝑑, 𝐷𝑎),
𝑑𝑟𝑖𝑣𝑒(𝐷𝑎, 𝐴𝑑), 𝑑𝑟𝑖𝑣𝑒(𝐴𝑑, 𝑃𝑒). Optimal relaxed plan: 𝑑𝑟𝑖𝑣𝑒(𝑆𝑦, 𝐵𝑟), 𝑑𝑟𝑖𝑣𝑒(𝑆𝑦, 𝐴𝑑),
𝑑𝑟𝑖𝑣𝑒(𝐴𝑑, 𝐷𝑎), 𝑑𝑟𝑖𝑣𝑒(𝐴𝑑, 𝑃𝑒). ℎ∗ = 6, ℎ+ = 4.

2. Do the same in the modified task where the road between Sydney and Bris-
bane is also one-way, i.e., it can only be driven from Sydney to Brisbane, not
in the opposite direction.

Solution: Optimal plan: Does not exist because we must visit both Brisbane
and Perth, but once we moved to either of these two, we cannot get back out
again. Optimal relaxed plan: 𝑑𝑟𝑖𝑣𝑒(𝑆𝑦, 𝐵𝑟), 𝑑𝑟𝑖𝑣𝑒(𝑆𝑦, 𝐴𝑑), 𝑑𝑟𝑖𝑣𝑒(𝐴𝑑, 𝐷𝑎),
𝑑𝑟𝑖𝑣𝑒(𝐴𝑑, 𝑃𝑒). ℎ∗ = ∞, ℎ+ = 4.

3. Write up, in STRIPS notation, all states reachable from the initial state in
at most two steps. Start at the initial state, and insert successors. Indicate
successor states by edges. Annotate the states with their ℎ∗ values as well as
their ℎ+ values.
4. Do the same in the modified task where the road between Sydney and Bris-
bane is one-way, i.e., it can only be driven from Sydney to Brisbane, not in the
opposite direction.

Problem 13.6 (Relaxation)


We want to solve a STRIPS planning task.

1. Explain (in about 2 sentences) the purpose of relaxed planning.

Solution: A relaxed problem is easier to solve than the original problem. Then
the length of its optimal plan of the relaxed problem can be used as a heuristic
for the original problem.

8
2. Explain (in about 2 sentences) why it is bad to relax too much or too little.

Solution: If we relax too little, the relaxed problem is still too difficult to solve.
If we relax too much, the relaxed problem is so easy that it does not induce a
useful heuristic.

Now consider a concrete task given by a finite set 𝐵 of size 𝑛 and


• facts: 𝑖𝑛𝐴(𝑏), 𝑖𝑛𝐵(𝑏), ℎ𝑒𝑙𝑑(𝑏) for 𝑏 ∈ 𝐵, 𝑅𝑓𝑟𝑒𝑒, 𝑅𝑖𝑛𝐴, 𝑅𝑖𝑛𝐵
• actionss

action precondition add list delete list


𝑚𝑜𝑣𝑒𝐴 𝑅𝑖𝑛𝐵 𝑅𝑖𝑛𝐴 𝑅𝑖𝑛𝐵
𝑚𝑜𝑣𝑒𝐵 𝑅𝑖𝑛𝐴 𝑅𝑖𝑛𝐵 𝑅𝑖𝑛𝐴
𝑝𝑖𝑐𝑘𝑢𝑝(𝑏) 𝑅𝑖𝑛𝐴, 𝑅𝑓𝑟𝑒𝑒, 𝑖𝑛𝐴(𝑏) ℎ𝑒𝑙𝑑(𝑏) 𝑅𝑓𝑟𝑒𝑒, 𝑖𝑛𝐴(𝑏)
𝑟𝑒𝑙𝑒𝑎𝑠𝑒(𝑏) 𝑅𝑖𝑛𝐵, ℎ𝑒𝑙𝑑(𝑏) 𝑖𝑛𝐵(𝑏), 𝑅𝑓𝑟𝑒𝑒 ℎ𝑒𝑙𝑑(𝑏)

• initial state 𝐼: 𝑖𝑛𝐴(𝑏) for 𝑏 ∈ 𝐵, 𝑅𝑓𝑟𝑒𝑒, 𝑅𝑖𝑛𝐴

• goal state: 𝑖𝑛𝐵(𝑏) for 𝑏 ∈ 𝐵


3. Let ℎ+ be the heuristic obtained from the delete relaxation. Give the value of
ℎ+ (𝐼).

Solution: 2𝑛 + 1 (𝑚𝑜𝑣𝑒𝐵 , 𝑝𝑖𝑐𝑘𝑢𝑝(1), 𝑟𝑒𝑙𝑒𝑎𝑠𝑒(1), … , 𝑝𝑖𝑐𝑘𝑢𝑝(𝑛), 𝑟𝑒𝑙𝑒𝑎𝑠𝑒(𝑛))

4. Let ℎ+ be the heuristic obtained from the only-adds relaxation. Give the value
of ℎ+ (𝐼).

Solution: 𝑛 (𝑟𝑒𝑙𝑒𝑎𝑠𝑒(1), … , 𝑟𝑒𝑙𝑒𝑎𝑠𝑒(𝑛))

You might also like