0% found this document useful (0 votes)
194 views19 pages

Graph Plan and SAT Plan

The document discusses planning graphs and how they can be used in artificial intelligence planning. Planning graphs consist of levels representing time steps, with each level containing actions and literals that could be true at that time. Mutex relationships between actions and literals are also represented. The GraphPLAN algorithm uses planning graphs to find a plan by repeatedly expanding the graph until goal predicates are reachable without mutexes.

Uploaded by

Jayashree
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)
194 views19 pages

Graph Plan and SAT Plan

The document discusses planning graphs and how they can be used in artificial intelligence planning. Planning graphs consist of levels representing time steps, with each level containing actions and literals that could be true at that time. Mutex relationships between actions and literals are also represented. The GraphPLAN algorithm uses planning graphs to find a plan by repeatedly expanding the graph until goal predicates are reachable without mutexes.

Uploaded by

Jayashree
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/ 19

Planning in Artificial Intelligence

The intelligent way to do things

COURSE: CS60045

Pallab Dasgupta
Professor,
Dept. of Computer Sc & Engg

1
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
USING PLANNING GRAPHS
GraphPlan and SATPlan

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

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)

Mutual exclusion Mutual exclusion


among actions among derived
predicates

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

4
Planning Graphs

• Consists of a sequence of levels that correspond to time steps in the plan

• 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

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

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)

In the world S2 the goal


Start: Have(Cake) predicates exist without
Finish: Have(Cake) ∧ Eaten(Cake) mutexes, hence we need not
expand the graph any further

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

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

• Mutex relation exists between two literals if:


 One is the negation of the other, or
 Each possible pair of actions that could achieve the two literals is mutually exclusive
(inconsistent support)

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)

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

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 )

INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR

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

• The planning problem is translated into a CNF satisfiability problem


• The goal is asserted to hold at a time step T, and clauses are included for each time step up to T.
• If the clauses are satisfiable, then a plan is extracted by examining the actions that are true.
• Otherwise, we increment T and repeat

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

Initial: At( P1, SFO )0 ∧ At( P2, JFK )0


Goal: At( P1, JFK ) ∧ At( P2, 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 ]

Check the satisfiability of:


initial state ∧ successor state axioms ∧ goal

13
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
Additional Axioms

Precondition Axioms:
Fly( P1, JFK, SFO)0 ⇒ At( P1, JFK )0

Action Exclusion Axioms:


¬ ( Fly( P2, JFK, SFO)0 ∧ Fly( P2, JFK, LAX)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

Explainable AI Planning (XAIP)


• Heuristic Search Planning
Enables you to seek explanations from the planner.
• Why did you do that?
• Planning with Temporal Goals
• And why didn’t you do something else (which I
• Planning under Adversaries
would have chosen)?
• Multi-agent Planning
• Why is what you propose better / cheaper / safer
• Planning in Continuous State Spaces than what I would have done?
• Why can’t you do that?
• Planning with Reinforcement Learning • Why do I need to backtrack (and replan) at this
point?
• Why do I not need to replan at this point?

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.

ACTION PRECOND EFFECT

Bake(x) ¬ Have(x) Have(x)

Eat-Pizza Have(Pizza) ∧ ¬ Have(Cake) Gastric ∧ ¬ Hungry

Eat-Cake Have(Cake) ∧ ¬ Have(Pizza) Toothache ∧ ¬ Hungry

Eat-Both Have(Cake) ∧ Have(Pizza) Gastric ∧ Toothache

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

You might also like