Subject: Artificial Intelligence
5. Planning
Faculty Name : Anita Patil
Mrs. Jyoti Joshi
Index
Lecture 40 – Introduction to Planning
Lecture 41 – Planning with State Space Search
Lecture 42 -Partial Ordered planning and Hierarchical Planning
Lecture 43 – Conditional Planning and STRIP
2
5. Introduction to Planning
Lecture No. 40 – Introduction
to Planning
What is Planning
Generate sequences of actions to perform tasks and achieve objectives.
States, actions and goals
Search for solution over abstract space of plans.
Assists humans in practical applications
Design and manufacturing
Military operations
Games
Space exploration
4 Lecture 39 - Introduction to Planning
Difficulty of real world problems
Assume a problem-solving agent using some search method …
• Which actions are relevant?
o Exhaustive search vs. backward search
• What is a good heuristic functions?
o Good estimate of the cost of the state?
o Problem-dependent vs -independent
• How to decompose the problem?
o Most real-world problems are nearly decomposable.
5 Lecture 39 - Introduction to Planning
Planning language
What is a good language?
Expressive enough to describe a wide variety of problems.
Restrictive enough to allow efficient algorithms to operate on it.
Planning algorithm should be able to take advantage of the logical
structure of the problem.
STRIPS and ADL
6 Lecture 39 - Introduction to Planning
General language features
Representation of states
Decompose the world in logical conditions and represent a state as a conjunction
of positive literals.
Propositional literals: Poor Unknown
FO-literals (grounded and function-free): At(Plane1, Melbourne) At(Plane2,
Sydney)
Closed world assumption
Representation of goals
Partially specified state and represented as a conjunction of positive ground literals
A goal is satisfied if the state contains all literals in goal.
7 Lecture 39 - Introduction to Planning
Language semantics?
The result of executing action a in state s is the state s’
s’ is same as s except
Any positive literal P in the effect of a is added to s’
Any negative literal ¬P is removed from s’
At(P1,SFO) At(P2,SFO) Plane(P1) Plane(P2) Airport(JFK)
Airport(SFO)
STRIPS assumption: (avoids representational frame problem)
every literal NOT in the effect remains unchanged
8 Lecture 39 - Introduction to Planning
Example: air cargo transport
Init(At(C1, SFO) At(C2,JFK) At(P1,SFO) At(P2,JFK) Cargo(C1) Cargo(C2) Plane(P1)
Plane(P2) Airport(JFK) Airport(SFO))
Goal(At(C1,JFK) At(C2,SFO))
Action(Load(c,p,a)
PRECOND: At(c,a) At(p,a) Cargo(c) Plane(p) Airport(a)
EFFECT: ¬At(c,a) In(c,p))
Action(Unload(c,p,a)
PRECOND: In(c,p) At(p,a) Cargo(c) Plane(p) Airport(a)
EFFECT: At(c,a) ¬In(c,p))
Action(Fly(p,from,to)
PRECOND: At(p,from) Plane(p) Airport(from) Airport(to)
EFFECT: ¬ At(p,from) At(p,to))
[Load(C1,P1,SFO), Fly(P1,SFO,JFK), Load(C2,P2,JFK), Fly(P2,JFK,SFO)]
9 Lecture 39 - Introduction to Planning
5. Introduction to Planning
Lecture No.41 Planning with
State Space Search
Planning with state-space search
Both forward and backward search possible
Progression planners
forward state-space search
Consider the effect of all possible actions in a given state
Regression planners
backward state-space search
To achieve a goal, what must have been true in the previous state.
Lecture 41 - Planning with State Space
11
Search
Progression algorithm
Formulation as state-space search problem:
Initial state = initial state of the planning problem
Literals not appearing are false
Actions = those whose preconditions are satisfied
Add positive effects, delete negative
Goal test = does the state satisfy the goal
Step cost = each action costs 1
No functions … any graph search that is complete is a complete planning
algorithm.
Inefficient: (1) irrelevant action problem (2) good heuristic required for
efficient search
Lecture 41 - Planning with State Space
12
Search
Regression algorithm
How to determine predecessors?
What are the states from which applying a given action leads to the goal?
Goal state = At(C1, B) At(C2, B) … At(C20, B)
Relevant action for first conjunct: Unload(C1,p,B)
Works only if pre-conditions are satisfied.
Previous state= In(C1, p) At(p, B) At(C2, B) … At(C20, B)
Subgoal At(C1,B) should not be present in this state.
Actions must not undo desired literals (consistent)
Main advantage: only relevant actions are considered.
Often much lower branching factor than forward search.
Lecture 41 - Planning with State Space
13
Search
Heuristics for state-space search
Neither progression or regression are very efficient without a good
heuristic.
How many actions are needed to achieve the goal?
Exact solution is NP hard, find a good estimate
Two approaches to find admissible heuristic:
The optimal solution to the relaxed problem.
Remove all preconditions from actions
The subgoal independence assumption:
The cost of solving a conjunction of subgoals is approximated by
the sum of the costs of solving the subproblems independently.
Lecture 41 - Planning with State Space
14
Search
5. Planning
Lecture No:42
Partial Ordered and
Hierarchical planning
Partial-order planning
Progression and regression planning are totally ordered plan search
forms.
They cannot take advantage of problem decomposition.
Decisions must be made on how to sequence actions on all the
subproblems
Least commitment strategy:
Delay choice during search
16 Lecture No:42Partial Ordered and Hierarchical planning
Shoe example
Goal(RightShoeOn LeftShoeOn)
Init()
Action(RightShoe, PRECOND: RightSockOn EFFECT: RightShoeOn)
Action(RightSock, PRECOND: EFFECT: RightSockOn)
Action(LeftShoe, PRECOND: LeftSockOn EFFECT: LeftShoeOn)
Action(LeftSock, PRECOND: EFFECT: LeftSockOn)
Planner: combine two action sequences (1)leftsock, leftshoe (2)rightsock,
rightshoe
17 Lecture No:42 Partial Ordered and Hierarchical planning
Partial-order planning
Any planning algorithm that can place two actions into a plan without
which comes first is a POL.
18 Lecture No:42 Partial Ordered and Hierarchical planning
POL as a search problem
States are (mostly unfinished) plans.
The empty plan contains only start and finish actions.
Each plan has 4 components:
A set of actions (steps of the plan)
A set of ordering constraints: A < B
Cycles represent contradictions.
A set of causal links
The plan may not be extended by adding a new action C that
conflicts with the causal link. (if the effect of C is ¬p and if C could
come after A and before B)
A set of open preconditions.
If precondition is not achieved by action in the plan.
19 Lecture No:42 Partial Ordered and Hierarchical planning
POL as a search problem
A plan is consistent iff there are no cycles in the ordering constraints and
no conflicts with the causal links.
A consistent plan with no open preconditions is a solution.
A partial order plan is executed by repeatedly choosing any of the
possible next actions.
This flexibility is a benefit in non-cooperative environments.
20 Lecture No:42 Partial Ordered and Hierarchical planning
Solving POL
Assume propositional planning problems:
The initial plan contains Start and Finish, the ordering constraint
Start < Finish, no causal links, all the preconditions in Finish are open.
Successor function :
picks one open precondition p on an action B and
generates a successor plan for every possible consistent way of
choosing action A that achieves p.
Test goal
21 Lecture No:42 Partial Ordered and Hierarchical planning
Example: Spare tire problem
Init(At(Flat, Axle) At(Spare,trunk))
Goal(At(Spare,Axle))
Action(Remove(Spare,Trunk)
PRECOND: At(Spare,Trunk)
EFFECT: ¬At(Spare,Trunk) At(Spare,Ground))
Action(Remove(Flat,Axle)
PRECOND: At(Flat,Axle)
EFFECT: ¬At(Flat,Axle) At(Flat,Ground))
Action(PutOn(Spare,Axle)
PRECOND: At(Spare,Groundp) ¬At(Flat,Axle)
EFFECT: At(Spare,Axle) ¬Ar(Spare,Ground))
Action(LeaveOvernight
PRECOND:
EFFECT: ¬ At(Spare,Ground) ¬ At(Spare,Axle) ¬ At(Spare,trunk) ¬
At(Flat,Ground) ¬ At(Flat,Axle) )
22 Lecture No:42 Partial Ordered and Hierarchical planning
Solving the problem
• Initial plan: Start with EFFECTS and Finish with PRECOND.
23 Lecture No:42 Partial Ordered and Hierarchical planning
Solving the problem
Intial plan: Start with EFFECTS and Finish with PRECOND.
Pick an open precondition: At(Spare, Axle)
Only PutOn(Spare, Axle) is applicable
Add causal link:
Add constraint : PutOn(Spare, Axle) < Finish
24 Lecture No:42 Partial Ordered and Hierarchical planning
Solving the problem
• Pick an open precondition: At(Spare, Ground)
• Only Remove(Spare, Trunk) is applicable
• Add causal link:
• Add constraint : Remove(Spare, Trunk) < PutOn(Spare,Axle)
25 Lecture No:42 Partial Ordered and Hierarchical planning
Hierarchical task network planning
Reduce complexity hierarchical decomposition
At each level of the hierarchy a computational task is reduced to a
small number of activities at the next lower level.
The computational cost of arranging these activities is low.
Hierarchical task network (HTN) planning uses a refinement of actions
through decomposition.
e.g. building a house = getting a permit + hiring a contractor + doing
the construction + paying the contractor.
Refined until only primitive actions remain.
Pure and hybrid HTN planning.
26 Lecture No:42 Partial Ordered and Hierarchical planning
Representation decomposition
General descriptions are stored in plan library.
Each method = Decompos(a,d); a= action and d= PO plan.
See build house example
Start action supplies all preconditions of actions not supplied by other
actions.
=external preconditions
Finish action has all effects of actions not present in other actions
=external effects
Primary effects (used to achieve goal) vs. secondary effects
27 Lecture No:42 Partial Ordered and Hierarchical planning
Buildhouse example
External precond
28 Lecture No:42 Partial Ordered and Hierarchical planning
Properties of decomposition
Should be correct implementation of action a
Correct if plan d is complete and consistent PO plan for the problem
of achieving the effects of a given the preconditions of a.
A decomposition is not necessarily unique.
Performs information hiding:
STRIPS action description of higher-level action hides some
preconditions and effects
Ignore all internal effects of decomposition
Does not specify the intervals inside the activity during which
preconditions and effects must hold.
Information hiding is essential to HTN planning.
29 Lecture No:42 Partial Ordered and Hierarchical planning
Abstract example
Initial state = <chair,table, cans of paint, unknown colors>, goal
state=<color(table) = color(chair)>
Sensorless planning (conformant planning)
Open any can of paint and apply it to both chair and table.
Conditional planning (Contingency planning)
Sense color of table and chair, if they are the same then finish else
sense labels paint if color(label) =color(Furniture) then apply color to
othe piece else apply color to both
Execution monitoring and replanning
Same as conditional and can fix errors (missed spots)
Continuous planning
Can revise goal when we want to first eat before painting the table
and the chair.
30 Lecture No:42 Partial Ordered and Hierarchical planning
5. Planning
Lecture No: 43 – Conditional
Planning and STRIPS
Conditional planning
Deal with uncertainty by checking the environment to see what is really
happening.
Used in fully observable and nondeterministic environments:
The outcome of an action is unknown.
Conditional steps will check the state of the environment.
How to construct a conditional plan?
32 Lecture No: 43 – Conditional Planning and STRIPS
Example: the vacuum-world
33 Lecture No: 43 – Conditional Planning and STRIPS
Conditional planning
Actions: left, right, suck
Propositions to define states: AtL, AtR, CleanL, CleanR
How to include indeterminism?
Actions can have more than one effect
E.g. moving left sometimes fails
Action(Left, PRECOND: AtR, EFFECT: AtL)
Becomes : Action(Left, PRECOND: AtR, EFFECT: AtLAtR)
Actions can have conditional effects
Action(Left, PRECOND:AtR, EFFECT: AtL(AtLwhen cleanL:
¬cleanL)
Both disjunctive and conditional
34 Lecture No: 43 – Conditional Planning and STRIPS
Conditional planning
Conditional plans require conditional steps:
If <test> then plan_A else plan_B
if AtLCleanL then Right else Suck
Plans become trees
Games against nature:
Find conditional plans that work regardless of which action outcomes
actually occur.
Assume vacuum-world
Initial state = AtR CleanL CleanR
Double murphy: possibility of deposits dirt when moving to other
square and possibility of depositing dirt when action is Suck.
35 Lecture No: 43 – Conditional Planning and STRIPS
STRIPS Representation
Planning can be considered as a logical inference problem:
a plan is inferred from facts and logical relationships.
STRIPS represented planning problems as a series of state descriptions and
operators expressed in first-order predicate logic.
State descriptions represent the state of the world at three points during the
plan:
Initial state, the state of the world at the start of the problem;
Current state, and
Goal state, the state of the world we want to get to.
Operators are actions that can be applied to change the state of the world.
Each operator has outcomes i.e. how it affects the world.
Each operator can only be applied in certain circumstances. These are
the preconditions of the operator.
36 Lecture No: 43 – Conditional Planning and STRIPS
Representing Operators
STRIPS operators are defined as:
NAME: How we refer to the operator e.g. go(Agent, From, To).
PRECONDITIONS: What states need to hold for the operator to be
applied. e.g. [at(Agent, From)].
ADD LIST: What new states are added to the world as a result of
applying the operator e.g. [at(Agent, To)].
37 Lecture No: 43 – Conditional Planning and STRIPS
DELETE LIST: What old states are removed from the world as a result
of applying the operator. e.g. [at(Agent, From)].
We will specify operators within a Prolog predicate opn/4:
opn( go(Agent,From,To),
[at(Agent, From)],
[at(Agent, To)],
[at(Agent, From)] ).
38 Lecture No: 43 – Conditional Planning and STRIPS
All Operators
Operator Preconditions Delete List Add List
go(X,Y) at(monkey,X) at(monkey,X) at(monkey,Y)
on(monkey, floor)
push(B,X,Y) at(monkey,X) at(monkey,X) at(monkey,Y)
at(B,X) at(B,X) at(B,Y)
on(monkey,floor)
on(B,floor)
39 Lecture No: 43 – Conditional Planning and STRIPS
climb_on(B) at(monkey,X) on(monkey,floor) on(monkey,B)
at(B,X)
on(monkey,floor)
on(B,floor)
grab(B) on(monkey,box) status(B,hanging) status(B,grabbed)
at(box,X)
at(B,X)
status(B,hanging)
40 Lecture No: 43 – Conditional Planning and STRIPS
Running Example Gripper
Gripper task with four balls:
There is a robot that can move between two rooms and pick up or drop balls
with either of his two arms. Initially, all balls and the robot are in the first
room. We want the balls to be in the second room.
Objects: The two rooms, four balls and two robot arms.
Predicates: Is x a room? Is x a ball? Is ball x inside room y? Is robot arm x
empty?
Initial state: All balls and the robot are in the first room. All robot arms
are empty.
Goal specification: All balls must be in the second room.
Actions/Operators: The robot can move between rooms, pick up a ball or
drop a ball.
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Objects
Objects:
Rooms: rooma, roomb
Balls: ball1, ball2, ball3, ball4
Robot arms: left, right
In PDDL:
(:objects rooma roomb
ball1 ball2 ball3 ball4
left right)
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Predicates
Predicates:
ROOM(x) – true iff x is a room
BALL(x) – true iff x is a ball
GRIPPER(x) – true iff x is a gripper (robot arm)
at-robby(x) – true iff x is a room and the robot is in x
at-ball(x, y) – true iff x is a ball, y is a room, and x is in y
free(x) – true iff x is a gripper and x does not hold a ball
carry(x, y) – true iff x is a gripper, y is a ball, and x holds y
In PDDL:
(:predicates (ROOM ?x) (BALL ?x) (GRIPPER ?x)
(at-robby ?x) (at-ball ?x ?y)
(free ?x) (carry ?x ?y))
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Initial state
Initial state:
ROOM(rooma) and ROOM(roomb) are true.
BALL(ball1), ..., BALL(ball4) are true.
GRIPPER(left), GRIPPER(right), free(left) and free(right) are true.
at-robby(rooma), at-ball(ball1, rooma), ..., at-ball(ball4, rooma) are true.
Everything else is false.
In PDDL:
(:init (ROOM rooma) (ROOM roomb)
(BALL ball1) (BALL ball2) (BALL ball3) (BALL ball4)
(GRIPPER left) (GRIPPER right) (free left) (free right)
(at-robby rooma)
(at-ball ball1 rooma) (at-ball ball2 rooma)
(at-ball ball3 rooma) (at-ball ball4 rooma))
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Goal specification
Goal specification:
at-ball(ball1, roomb), ..., at-ball(ball4, roomb) must be true.
Everything else we don’t care about.
In PDDL:
(:goal (and (at-ball ball1 roomb)
(at-ball ball2 roomb)
(at-ball ball3 roomb)
(at-ball ball4 roomb)))
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Movement operator
Action/Operator:
Description: The robot can move from x to y.
Precondition: ROOM(x), ROOM(y) and at-robby(x) are true.
Effect: at-robby(y) becomes true. at-robby(x) becomes false.
Everything else doesn’t change.
In PDDL:
(:action move :parameters (?x ?y)
:precondition (and (ROOM ?x) (ROOM ?y)
(at-robby ?x))
:effect (and (at-robby ?y)
(not (at-robby ?x))))
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Pick-up operator
Action/Operator:
Description: The robot can pick up x in y with z.
Precondition: BALL(x), ROOM(y), GRIPPER(z), at-ball(x, y),
at-robby(y) and free(z) are true.
Effect: carry(z, x) becomes true. at-ball(x, y) and free(z)
become false. Everything else doesn’t change.
In PDDL:
(:action pick-up :parameters (?x ?y ?z)
:precondition (and (BALL ?x) (ROOM ?y) (GRIPPER ?z)
(at-ball ?x ?y) (at-robby ?y) (free ?z))
:effect (and (carry ?z ?x)
(not (at-ball ?x ?y)) (not (free ?z))))
Lecture No: 43 – Conditional Planning and STRIPS
Gripper task: Drop operator
Action/Operator:
Description: The robot can drop x in y from z.
(Preconditions and effects similar to the pick-up operator.)
In PDDL:
(:action drop :parameters (?x ?y ?z)
:precondition (and (BALL ?x) (ROOM ?y) (GRIPPER ?z)
(carry ?z ?x) (at-robby ?y))
:effect (and (at-ball ?x ?y) (free ?z)
(not (carry ?z ?x))))