DD2380 Artificial Intelligence
Classical AI Planning
Jana Tumova
Planning 1
Planning
Deliberating a plan of action to achieve one’s goal
Planning 2
Planning
Deliberating a plan of action to achieve one’s goal
Planning 3
Real-world planning
• Limited resources: time, cost, capacity,. . .
• Uncertainty
• Multiple agents
• Different criteria: optimality,. . .
• Robotics: dynamical constraints
• Integration into context, integration with other AI methods
Planning 4
Real-world planning
• Limited resources: time, cost, capacity,. . .
• Uncertainty
• Multiple agents
• Different criteria: optimality,. . .
• Robotics: dynamical constraints
• Integration into context, integration with other AI methods
Today’s lecture: only fully observable, deterministic, static,
environments.
Planning 4
Planning problem
Planning problem:
• Initial state
• Actions available in a state ACTIONS(s)
• Results of applying action RESULT (s, a)
• Goal test
Planning 5
Planning vs. problem solving
• Problem solving (search and games):
• Explicit atomic representations
• Need good domain-specific heuristics
• Classical planning:
• Factored representation
• Domain-independent algorithms
Planning 6
Challenges
• How do we represent a planning problem?
• How do we solve a planning problem?
Planning 7
Challenges
• How do we represent a planning problem?
• PDDL, STRIPS, ...
• How do we solve a planning problem?
Planning 7
Planning Domain Definition Language
(PDDL)
A careful balance between expressivity and simplicity
States
• At(P, SFO)
• At(P, Arlanda) ∧ Plane(P) ∧ Loaded(Cargo, P)
Actions (think of them as universally quantified)
Planning 8
PDDL States
• State is a conjunction of ground, functionless atomic fluents
At(P, Arlanda) ∧ Plane(P) ∧ Loaded(Cargo, P)
• Database semantics: Fluents that are not mentionad are false
• Two equivalent viewpoints:
• Conjunction of fluents: logical inference
• Set of fluents: set operations
Planning 9
PDDL Action Schemes
Actions and their results are represented through action schemes
• Action name with the list of all used variables
• Precondition: a conjunction of literals saying when an action is
applicable in a state s, namely if s entails the precondition
ACTIONS(s) = {a | s |= PRECOND(a)}.
• Effect: a conjunction of literals representing the literals that need to
be removed and added
RESULT (s, a) = (s \ DEL(a)) ∪ ADD(a),
where DEL(a) are the fluents that appear as negative literals in the
effect and ADD(a) are the fluents that appear as positive ones.
Planning 10
Block World in PDDL
Planning 11
Block World in PDDL
Planning 11
Block World in PDDL
Planning 12
Q: What are the initial state and the goal
test?
Action(Slide(t, s1 , s2 ))
PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
EFFECT : On(t, s2 ) ∧ Blank(s1 ) ∧ ¬On(t, s1 ) ∧ ¬Blank(s2 )
Planning 13
Challenges
• How do we represent a planning problem?
• PDDL, STRIPS, ...
• How do we solve a planning problem?
Planning 14
Challenges
• How do we represent a planning problem?
• PDDL, STRIPS, ...
• How do we solve a planning problem?
• Via forward search and backward search with heuristics
Planning 14
PDDL Planning Problem as a State Space
Search
• Description of a planning problem defines a search problem
• States are truth assignments to fluents, actions and results define
the transitions
Block(A) , Block(B), Block(C) Block(A), Block(B), Block(C),
On(A, Table), On(B,Table), On(C,A), On(A,Table), On(B,Table), On(C,Table)
Clear(B),Clear(C) Clear(A), Clear(B), Clear(C)
… …
Planning 15
PDDL Planning Problem as a State Space
Search
• Description of a planning problem defines a search problem
• States are truth assignments to fluents, actions and results define
the transitions
On(A, Table), On(B,Table), On(C,A), On(A,Table), On(B,Table), On(C,Table)
Clear(B),Clear(C) Clear(A), Clear(B), Clear(C)
… …
Planning 16
Forward (progression) search
• As expected
• Start at the initial state
• Explore applicable actions
• Properties
• Large branching factor, often explores irrelevant actions
• Needs a good heuristic, ideally domain-independent
Planning 17
Example: Air Cargo Transport in PDDL
Planning 18
Heuristics
In both progression and regression search, we need good a heuristic.
Planning 19
Domain-independent heuristics
• Any planning problem instance
• Define a relaxed, easier problem and a heuristic as a solution
to this easier problem
• Use the internal structure of a factored representation of the
state space
• Ignore preconditions
• Ignore delete lists
• State abstraction
• Decomposition
• Planning graph
Planning 20
Domain-independent heuristics
• Any planning problem instance
• Define a relaxed, easier problem and a heuristic as a solution
to this easier problem
• Use the internal structure of a factored representation of the
state space
• Ignore preconditions
• Ignore delete lists
• State abstraction
• Decomposition
• Planning graph
Planning 21
Ignore preconditions
Ignore all preconditions
• Every action becomes applicable in every state
• The number of edges in the graph increases
• The number of steps to solve the relaxed problem is almost
the number of unsatisfied fluents in the goal
• Some actions may achieve multiple goals
• Some actions may undo the effects of others
Ignore some preconditions
Planning 22
Example: Ignore preconditions
Action(Slide(t, s1 , s2 ))
PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
EFFECT : On(t, s2 ) ∧ Blank(s1 ) ∧ ¬On(t, s1 ) ∧ ¬Blank(s2 )
h1 (n): number of the misplaced tiles
Planning 23
Example: Ignore preconditions
Action(Slide(t, s1 , s2 ))
PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
EFFECT : On(t, s2 ) ∧ Blank(s1 ) ∧ ¬On(t, s1 ) ∧ ¬Blank(s2 )
h1 (n): number of the misplaced tiles
• The relaxed problem assumed we can transfer any tile anywhere
• PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
Planning 23
Q: Match ignoring preconditions with the
heuristic
Action(Slide(t, s1 , s2 ))
PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
EFFECT : On(t, s2 ) ∧ Blank(s1 ) ∧ ¬On(t, s1 ) ∧ ¬Blank(s2 )
h2 (n): sum of the distances of the tiles from the goal position
Planning 24
Q: Match ignoring preconditions with the
heuristic
Action(Slide(t, s1 , s2 ))
PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
EFFECT : On(t, s2 ) ∧ Blank(s1 ) ∧ ¬On(t, s1 ) ∧ ¬Blank(s2 )
h2 (n): sum of the distances of the tiles from the goal position
• The relaxed problem assumed we can transfer any tile to an
adjacent cell
PRECOND : On(t, s1 ) ∧ Tile(t) ∧ Blank(s2 ) ∧ Adjacent(s1 , s2 )
Planning 24
Domain-independent heuristics
• Any planning problem instance
• Define a relaxed, easier problem and a heuristic as a solution
to this easier problem
• Use the internal structure of a factored representation of the
state space
• Ignore preconditions
• Ignore delete lists
• State abstraction
• Decomposition
• Planning graph
Planning 25
Ignore Delete Lists
• Remove all negative literals from effects
• No action will undo progress by another action towards the
goal
• The number of edges in the graph increases
Planning 26
Domain-independent Heuristics
• Any planning problem instance
• Define a relaxed, easier problem and a heuristic as a solution
to this easier problem
• Use the internal structure of a factored representation of the
state space
• Ignore preconditions
• Ignore delete lists
• State abstraction
• Decomposition
• Planning graph
Planning 27
State Abstraction
• Many-to-one mapping from states in the ground
representation to the abstract representation
• The number of states decreases
• Ignore some fluents
Planning 28
Domain-independent Heuristics
• Any planning problem instance
• Define a relaxed, easier problem and a heuristic as a solution
to this easier problem
• Use the internal structure of a factored representation of the
state space
• Ignore preconditions
• Ignore delete lists
• State abstraction
• Decomposition
• Planning graph
Planning 29
Decomposition
• G = G1 ∧ . . . ∧ Gn
• Instead of problem P, we solve problems P1 , . . . , Pn
• We can use maxi COST (Pi ) as a heuristic
Planning 30
Decomposition
• G = G1 ∧ . . . ∧ Gn
• Instead of problem P, we solve problems P1 , . . . , Pn
• We can use maxi COST (Pi ) as a heuristic
• Q: Can we use COST (P1 ) + . . . + COST (Pn ) as a heuristic?
Planning 30
Decomposition
• G = G1 ∧ . . . ∧ Gn
• Instead of problem P, we solve problems P1 , . . . , Pn
• We can use maxi COST (Pi ) as a heuristic
• Q: Can we use COST (P1 ) + . . . + COST (Pn ) as a heuristic?
• Q: What generally happens if we use a non-admissible
heuristic?
Planning 30
Domain-independent Heuristics
• Any planning problem instance
• Define a relaxed, easier problem and a heuristic as a solution
to this easier problem
• Use the internal structure of a factored representation of the
state space
• Ignore preconditions
• Ignore delete lists
• State abstraction
• Decomposition
• Planning graph
Planning 31
Planning Graph
Planning 32
Planning Graph
State level Action level
Each fluent that Persistence
holds initially Mutex
actions
Planning 33
Planning Graph
Mutex:
• Inconsistent effects: one
action negates the effect of
State level Action level
the other
• Interference: one of the
effects of one action is the
negation of a precondition of
the other
• Competing needs: one of the
preconditions of one action is
Each fluent that Persistence
Mutex
the negation of a precondition
holds initially actions
of the other
Planning 34
Planning Graph
State level Action level State level Mutex for literals:
• Negation
• If each possible pair of
actions that could
achieve the two literals
is mutually exclusive
Each fluent that Persistence
holds initially Mutex
actions
Planning 35
Planning Graph
State level Action level State level Action level
Each fluent that Persistence
holds initially Mutex
actions
Planning 36
Planning Graph
State level Action level State level Action level State level
Each fluent that Persistence Leveled off
holds initially Mutex
actions
Planning 37
Planning Graph
• Directed graph with alternating state and action levels
• Roughly,
• Si level contains literals that could hold at time i
• Ai level contains actions that could have their precoditions
satisfied at time i.
• Persistence actions: a literal can persist if no action negates it
• Mutex:
• Inconsistent effects: one action negates effect of the other
• Interference: effect of one action negates a precondition of the
other
• Competing needs: the precondition of one action is mutually
exclusive with a precondition of the other
Planning 38
Planning Graph Properties
• Polynomial in the size of the planning problem
• A literal never appears too late, but might appear too early
• If a goal literal does not appear in the final level of the graph,
the problem is unsolvable
• We can use it for designing an independent-domain heuristic:
• Max-level heuristic: admissible, but not always accurate
• Level-sum heuristic: generally inadmissible, but works well in
practice
• Set-level heuristic: find the level at which all the goal literals
appear without being mutually exclusive; admissible and works
well
Planning 39
Challenges
• How do we represent a planning problem?
• PDDL, STRIPS, ...
• How do we solve a planning problem?
• Via forward search and backward search with heuristics
Planning 40
Challenges
• How do we represent a planning problem?
• PDDL, STRIPS, ...
• How do we solve a planning problem?
• Via forward search and backward search with heuristics
• Via GRAPHPlan
Planning 40
GRAPHPlan
• Using the planning graph to extract a plan directly instead of using
it to design a heuristic for search
• EXTRACT-SOLUTION either through CSP or through backward
search in the planning graph, not in the state space
• If EXTRACT-SOLUTION does not find a plan, we store
(level, goals) in nogoods
Planning 41
GRAPHPlan
Planning 42
GRAPHPlan Properties
• Literals increase monotonically
• Actions increase monotonically
• Mutexes decrease monotonically
• No-goods decrease monotonically
• It is not enough to level-off the graph
• Termination when mutexes and no-goods have both leveled off
Planning 43
Challenges
• How do we represent a planning problem?
• PDDL, STRIPS, ...
• How do we solve a planning problem?
• Via forward search and backward search with heuristics
• Via GRAPHPlan
• As refinement of partially ordered plans
• As Boolean satisfiability
• As first-order logical deduction: situation calculus
• As constraint satisfaction
Planning 44
Final remarks
Where to learn more
• Artificial Intelligence: A Modern Approach by Stuart J. Russell
and Peter Norvig, chapter 10 + the udacity course Intro to AI
• Automated Planning and Acting by Dana S. Nau, Malik
Ghallab, and Paolo Traverso
Planning 45