Skip to content
BIASED

Search and planning

Search formulation, BFS and UCS, A* with admissible heuristics, STRIPS/PDDL and links to LM planning.

Formulating a search problem

A search problem has five parts: states and initial s0s_0; a goal test; Actions(s)(s); Result(s,a)(s,a); step costs c(s,a,s′)>0c(s,a,s')>0. A solution is a path to a goal; an optimal one has cost C⋆C^\star. In the 8-puzzle the reachable component has 9!/2=181,4409!/2=181{,}440 states. Formulation is abstraction: leave out what does not affect reachability of the goal.

A search keeps a frontier of reached-but-unexpanded nodes and expands one at a time. Graph search also remembers the cheapest path to each reached state.

Breadth-first and uniform-cost

Breadth-first search expands the shallowest node. With equal step costs the shallowest goal is optimal; memory is O(bd)O(b^d). With unequal costs it need not be optimal.

Uniform-cost search expands least g(n)g(n) (Dijkstra). Test the goal when a node is expanded, not generated. With c≥ε>0c\ge\varepsilon>0 the first expanded goal is optimal. UCS is blind: it spreads in every direction in order of cost.

A* and admissible heuristics

Key idea. Expand the node with smallest f(n)=g(n)+h(n)f(n)=g(n)+h(n). If hh never overestimates remaining cost, the first expanded goal is optimal, and a better hh expands fewer nodes.

hh is admissible if h(n)≤h⋆(n)h(n)\le h^\star(n) and h(goal)=0h(\mathrm{goal})=0. It is consistent if h(n)≤c(n,a,n′)+h(n′)h(n)\le c(n,a,n')+h(n'). Consistency implies admissibility; for graph search it makes ff nondecreasing along paths, so each node expands with best gg, and the first goal has cost C⋆C^\star. Tree search needs only admissibility.

On a grid with walls, Manhattan distance is consistent: UCS expanded 136136 cells, A* 8080, same path length 2121. Weighted A* with w>1w>1 saves more work but guarantees only cost ≤wC⋆\le w C^\star.

Heuristics and STRIPS/PDDL

Good heuristics are exact costs of relaxed problems (e.g. ignore walls → Manhattan). If admissible h2≥h1h_2\ge h_1 everywhere, h2h_2 dominates h1h_1 and A* never expands a node that h1h_1 would skip (up to ties).

STRIPS/PDDL factored states as sets of facts and actions as preconditions, add and delete lists: Result(s,a)=(s∖Del(a))∪Add(a)(s,a)=(s\setminus\mathrm{Del}(a))\cup\mathrm{Add}(a). Ignoring deletes yields planning heuristics. The Sussman anomaly needs a whole-state search: C to table, B onto C, A onto B.

LM planners and next

Language models often emit invalid plans in one pass. Reuse the pieces: LLM+P lets the model write PDDL and a planner search; Tree of Thoughts uses the model as successor and heuristic inside BFS/DFS; LLM-Modulo pairs a proposer with an external verifier.

Search assumed one known outcome per action. When outcomes are random, the object to compute is a policy — next: Markov decision processes.

Check your understanding

The same questions as in Pulse. Answers are shared between modes.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • BFS shortest path on a gridoptional

    NumPy/queue: find shortest-path length and recover the route on a 5×5 grid with one obstacle.

    ~20 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.

Full notes

Answers are saved on the server and tied to this browser until you sign in.