Back to Lecture 9

Classical Planning Cheat Sheet

Quick reference guide for all key concepts

1. Classical Planning Basics

Definition

Classical Planning: Finding a sequence of actions to reach a goal in discrete, deterministic, static, fully observable environments.

Key Assumptions (DFSF)
  • Deterministic: Actions have predictable outcomes
  • Fully Observable: Complete state information available
  • Static: Only agent's actions change the world
  • Discrete: Finite states, actions, and time steps
Core Components
  • State (S): Complete description of the world
  • Initial State (S₀): Starting configuration
  • Goal State (Sₐ): Desired configuration
  • Actions (A): Operations that transform states
  • Transition Model: Result(s, a) = new state
  • Plan (π): Sequence of actions [a₁, a₂, ..., aₙ]

2. State Representation

Ground Atomic Fluents

State = Set of ground atomic fluents

  • Atomic: Single predicate (not complex formula)
  • Ground: Only constants, NO variables
  • Fluent: Can change over time
At(Robot, Kitchen) — Valid
Holding(Box) — Valid
At(x, Kitchen) — Has variable
¬Holding(Box) — Has negation
Database Semantics

States are represented as sets (unordered, no duplicates)

S = { At(Robot, Kitchen), Holding(Box), On(Book, Table) }
Closed-World Assumption (CWA)
What's not stated is FALSE
At(Robot, Kitchen) ∈ S → TRUE
At(Robot, Bedroom) ∉ S → FALSE
Unique Names Assumption (UNA)
Different names = Different objects
Robot1 ≠ Robot2
Kitchen ≠ Bedroom

3. STRIPS Actions

STRIPS Action Structure

Every action has exactly three parts:

Component Description Example
Preconditions
Precond(a)
What must be TRUE before action executes { At(Robot, Table), Empty(Hand) }
Add List
Add(a)
What becomes TRUE after action { Holding(Box) }
Delete List
Del(a)
What becomes FALSE after action { On(Box, Table), Empty(Hand) }
STRIPS Result Function:
Result(s, a) = (s − Del(a)) ∪ Add(a)
New state = (Current state - Deleted facts) + Added facts
Action Schemas

Template with variables → One schema generates many ground actions

Move(?robot, ?from, ?to)Move(Robot1, Kitchen, Bedroom)

4. PDDL (Planning Domain Definition Language)

Domain File
  • Defines general rules
  • Types of objects
  • Predicates
  • Action schemas
(define (domain logistics)
  (:types vehicle location)
  (:predicates 
    (at ?v - vehicle ?l - location))
  (:action move ...)
)
Problem File
  • Specific instance
  • Objects
  • Initial state
  • Goal conditions
(define (problem deliver)
  (:domain logistics)
  (:objects truck1 - vehicle)
  (:init (at truck1 depot))
  (:goal (at truck1 store))
)
PDDL Action Schema Syntax
(:action move
  :parameters (?v - vehicle ?from ?to - location)
  :precondition (and (at ?v ?from))
  :effect (and (at ?v ?to) (not (at ?v ?from)))
)
PDDL Element Syntax
Variable ?x ?robot ?from
Type ?x - type
Conjunction (and ...)
Negation (not ...)
Universal (forall (?x) ...)
Existential (exists (?x) ...)

5. Planning Algorithms

Forward Search

Progression: Start from initial state, apply actions until goal reached

  • Start: S₀
  • Expand: Apply applicable actions
  • Check: Goal test on each state
  • Complete & Optimal (with A*)
State-space search
Backward Search

Regression: Start from goal, work backwards to initial state

  • Start: Goal conditions
  • Expand: Relevant actions
  • Check: Match initial state
  • Better for goals with few facts
Goal-space search
SAT-Based Planning

Encode as logic: Convert planning to SAT problem

  • Propositionalize fluents
  • Encode actions as clauses
  • Use SAT solver
  • Handles large problems
Logic-based
Generic Search Algorithm
frontier ← {initial_state}
explored ← ∅

while frontier not empty:
    node ← Remove(frontier)  // BFS, DFS, or A* here
    if Goal-Test(node.state):
        return Solution(node)
    explored ← explored ∪ {node.state}
    for action in Applicable-Actions(node.state):
        child ← Apply(node.state, action)
        if child.state ∉ explored:
            Add(child, frontier)
return Failure
Note: Becomes BFS, DFS, or A* depending on frontier management

6. Planning Heuristics

Heuristic Description Properties
Goal Count h(s) = # of unsatisfied goal atoms Admissible
Delete Relaxation Ignore delete effects (optimistic) Admissible
hadd Sum of costs to achieve each goal Not admissible
hmax Max cost among all goals Admissible
FF (Fast-Forward) Plan length in relaxed problem Not admissible Effective
A* with Admissible Heuristic: f(n) = g(n) + h(n)
g(n) = cost so far | h(n) = estimated cost to goal
Guarantees optimal solution if h is admissible (never overestimates)

7. Python Implementation

Option 1: Pure Python STRIPS
class Action:
    def __init__(self, name, precond, add, delete):
        self.precond = set(precond)
        self.add = set(add)
        self.delete = set(delete)
    
    def applicable(self, state):
        return self.precond.issubset(state)
    
    def apply(self, state):
        return (state - self.delete) | self.add
Option 2: Python Libraries
pyddl
Pure Python STRIPS
pip install pyddl
pddlpy
PDDL parser
pip install pddlpy
pyperplan
Educational planner
pip install pyperplan
unified-planning
Modern framework
pip install unified-planning

8. Classic Planning Problems

Blocks World

Goal: Stack blocks in target configuration

Actions: Pickup, Putdown, Stack, Unstack

Predicates: On(x,y), Clear(x), Holding(x), HandEmpty

Spare Tire

Goal: Replace flat tire with spare

Actions: Remove(tire,loc), PutOn(tire,axle)

Predicates: Tire(tire, location)

Logistics/Cargo

Goal: Transport cargo between cities

Actions: Load, Unload, Fly, Drive

Predicates: At(obj,loc), In(cargo,vehicle)

Robot Navigation

Goal: Move robot to target location

Actions: Move(from,to), Grasp, Release

Predicates: At(robot,loc), Holding(obj)

9. Quick Comparison

Aspect STRIPS PDDL FOL
Variables Action schemas only Action schemas + types Full support
Negation Delete lists (not ...) in effects Full ¬ operator
Quantifiers ❌ No ✅ forall, exists ✅ ∀, ∃
Typing ❌ No ✅ Yes Depends
Usage Educational Standard for planners General reasoning

10. Key Formulas & Definitions

STRIPS Result Function:
Result(s, a) = (s − Del(a)) ∪ Add(a)

Applicable Action:
Applicable(a, s) ⟺ Precond(a) ⊆ s

Goal Test:
Goal-Test(s) ⟺ Goal ⊆ s

Plan Quality:
Cost(π) = Σ Cost(aᵢ) for aᵢ ∈ π
Forward Search:
s' = Result(s, a) where Applicable(a, s)

Backward Search (Regression):
g' = (g − Add(a)) ∪ Precond(a)

A* Evaluation:
f(n) = g(n) + h(n)

Branching Factor:
b = average # applicable actions

Tips & Best Practices

State Design
  • Keep fluents minimal
  • Only include what changes
  • Use clear predicate names
  • Avoid redundancy
Action Design
  • Complete preconditions
  • Accurate effects
  • Consider frame problem
  • Test action applicability
Performance
  • Use good heuristics
  • Reduce branching factor
  • Consider domain-specific tricks
  • Benchmark different planners