Graph Plan and SAT Plan
Graph Plan and SAT Plan
COURSE: CS60045
Pallab Dasgupta
Professor,
Dept. of Computer Sc & Engg
1
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
USING PLANNING GRAPHS
GraphPlan and SATPlan
2
Planning Graph Op( ACTION: Eat(Cake),
PRECOND: Have(Cake),
EFFECT: Eaten(Cake) ∧ ¬Have(Cake))
Start: Have(Cake)
Finish: Have(Cake) ∧ Eaten(Cake) Op( ACTION: Bake(Cake),
PRECOND: ¬Have(Cake),
EFFECT: Have(Cake))
S0 A0 S1
Have(Cake) Have(Cake)
¬ Have(Cake)
Eat( Cake )
Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake)
Persistence action
(carries over a predicate to the next world)
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
3
Mutex Links in a Planning Graph
S0 A0 S1
Have(Cake) Have(Cake)
¬ Have(Cake)
Eat( Cake )
Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake)
4
Planning Graphs
• Each level contains a set of actions and a set of literals that could be true at that time
step depending on the actions taken in previous time steps
• For every +ve and –ve literal C, we add a persistence action with precondition C and
effect C
5
Op( ACTION: Eat(Cake), Op( ACTION: Bake(Cake),
Planning Graph PRECOND: Have(Cake), PRECOND: ¬Have(Cake),
EFFECT: Eaten(Cake) ∧ ¬Have(Cake)) EFFECT: Have(Cake))
S0 A0 S1 A1 S2
Bake( Cake )
Have(Cake) Have(Cake) Have(Cake)
¬ Have(Cake) ¬ Have(Cake)
Eat( Cake ) Eat( Cake )
Eaten(Cake) Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake) ¬ Eaten(Cake)
6
Mutex Actions
• Mutex relation exists between two actions if:
Inconsistent effects – one action negates an effect of the other
Eat( Cake ) causes ¬ Have(Cake) and Bake( Cake ) causes Have(Cake)
Interference – one of the effects of one action is the negation of a precondition of the other
Eat( Cake ) causes ¬ Have(Cake) and the persistence of Have( Cake ) needs Have(Cake)
Competing needs – one of the preconditions of one action is mutually exclusive with a
precondition of the other
Bake( Cake ) needs ¬ Have(Cake) and Eat( Cake ) needs Have(Cake)
A1
S0 A0 S1
Bake( Cake )
S2
Have(Cake) Have(Cake) Have(Cake)
¬ Have(Cake) ¬ Have(Cake)
Eat( Cake ) Eat( Cake )
Eaten(Cake) Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake) ¬ Eaten(Cake)
Mutex Literals
A1
S0 A0 S1
Bake( Cake )
S2
Have(Cake) Have(Cake) Have(Cake)
¬ Have(Cake) ¬ Have(Cake)
Eat( Cake ) Eat( Cake )
Eaten(Cake) Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake) ¬ Eaten(Cake)
8
Function GraphPLAN( problem )
// returns solution or failure
graph Initial-Planning-Graph( problem )
goals Goals[ problem ]
do
if goals are all non-mutex in last level of graph then do
solution Extract-Solution( graph )
if solution ≠ failure then return solution
else if No-Solution-Possible (graph )
then return failure
graph Expand-Graph( graph, problem )
9
Finding the plan
• Once a world is found having all goal predicates without mutexes, the plan can be
extracted by solving a constraint satisfaction problem (CSP) for resolving the mutexes
• Creating the planning graph can be done in polynomial time, but planning is known to be a
PSPACE-complete problem. The hardness is in the CSP.
• The plan is shown in blue below
A1
S0 A0 S1
Bake( Cake )
S2
Have(Cake) Have(Cake) Have(Cake)
¬ Have(Cake) ¬ Have(Cake)
Eat( Cake ) Eat( Cake )
Eaten(Cake) Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake) ¬ Eaten(Cake)
10
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Termination of GraphPLAN when no plan exists
• Literals increase monotonically
• Actions increase monotonically
• Mutexes decrease monotonically
This guarantees the existence of a fixpoint
A1
S0 A0 S1
Bake( Cake )
S2
Have(Cake) Have(Cake) Have(Cake)
¬ Have(Cake) ¬ Have(Cake)
Eat( Cake ) Eat( Cake )
Eaten(Cake) Eaten(Cake)
¬ Eaten(Cake) ¬ Eaten(Cake) ¬ Eaten(Cake)
11
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Planning with Propositional Logic
12
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Example
Aeroplanes P1 and P2 are at SFO and JFK respectively. We want P1 at JFK and P2 at SFO
Action: At( P1, JFK )1 ⇔ [ At( P1, JFK )0 ∧ ¬ ( Fly( P1, JFK, SFO)0 ∧ At( P1, JFK )0 ) ]
∨ [ At( P1, SFO )0 ∧ Fly( P1, SFO, JFK)0 ]
13
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Additional Axioms
Precondition Axioms:
Fly( P1, JFK, SFO)0 ⇒ At( P1, JFK )0
State Constraints:
∀ p, x, y, t ( x ≠ y ) ⇒ ¬ ( At( p, x )t ∧ At( p, y )t )
14
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
SATPlan
Function SATPlan( problem, Tmax )
// returns solution or failure
for T = 0 to Tmax do
cnf, mapping Trans-to-SAT(problem, T)
assignment SAT-Solver( cnf )
if assignment is not NULL then
return Extract-Solution(assignment, mapping)
return failure
15
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Further Readings
16
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Exercise-1
Start: At( Flat, Axle ) ∧ At( Spare, Trunk ) Op( ACTION: PutOn( Spare, Axle ),
Goal: At( Spare, Axle ) PRECOND: At( Spare, Ground )
∧ ¬ At( Flat, Axle ),
EFFECT: At( Spare, Axle )
Op( ACTION: Remove( Spare, Trunk ),
∧ ¬ At( Spare, Ground ))
PRECOND: At( Spare, Trunk ),
EFFECT: At( Spare, Ground )
Op( ACTION: LeaveOvernight,
∧ ¬ At( Spare, Trunk ))
PRECOND:
EFFECT: ¬ At( Spare, Ground )
Op( ACTION: Remove( Flat, Axle ),
∧ ¬ At( Spare, Axle )
PRECOND: At( Flat, Axle ),
∧ ¬ At( Spare, Trunk )
EFFECT: At( Flat, Ground )
∧ ¬ At( Flat, Ground )
∧ ¬ At( Flat, Axle ))
∧ ¬ At( Flat, Axle ))
Use the partial order planning algorithm to develop a plan for this domain.
17
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Exercise-2
Consider the following list of actions.
• The initial world is defined by ¬ Have(Pizza) ∧ ¬ Have(Cake).
• The planning goal is: Gastric ∧ Toothache ∧ ¬ Hungry.
Draw the planning graph after two levels of actions and indicate (with justification) whether we already have a
plan. Your planning graph should clearly specify the mutex relations between the actions and the facts.
18
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Exercise-3 (No, you don’t need to read the book, nor watch the movies to solve this one)
Lord Voldemort wishes to acquire the elder wand, the resurrection stone, and the invisibility cloak. There are
actions by which he wishes to get these, but the actions also have other side effects. He has written down the
actions as follows:
Op( ACTION: GetWand, PRECOND: At(x), EFFECT: Have(wand) ∧ ¬Happy )
Op( ACTION: GetStone, PRECOND: At(x), EFFECT: Have(stone) ∧ Safe )
Op( ACTION: StealCloak, PRECOND: At(x), EFFECT: Have(cloak) ∧ Invisible ∧ Happy )
Op( ACTION: BuyCloak, PRECOND: At(x), EFFECT: Have(cloak) ∧ ¬Invisible ∧ ¬Safe )
Op( ACTION: Start, EFFECT: At(Hogwarts) )
Op( ACTION: Finish, PRECOND: Have(wand) ∧ Have(stone) ∧ Have(cloak) )
1. Voldemort has decided to use the GraphPlan algorithm to choose his plan. Draw the planning graph after one
iteration, clearly indicating all the mutex links.
2. Is any further iteration necessary? Explain.
3. Will GraphPlan terminate with a plan in this case? If so, draw the plan. If not, explain why.
19
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR