Chapter 2

Informed search

A heuristic estimates remaining cost. Its numerical size alone does not establish safety: compare it with the true remaining cost and with every directed edge. A* uses the cost already paid as well as the estimate still to go.

2.1 Priority rules

Past papers · DA 2024–2026 (3 papers): 1 question, 1 mark

Greedy search is generally neither optimal nor complete on infinite spaces; with duplicate suppression it is complete on a finite reachable graph. A small hh does not mean a cheap complete path. When priorities tie, follow the stated rule; different valid tie rules can give different expansion sequences and counts.

2.2 Admissibility and consistency

Write g(n)g(n) for path cost, h(n)h(n) for the heuristic and f(n)=g(n)+h(n)f(n)=g(n)+h(n) for A* priority. Let h∗(n)h^*(n) be the true minimum remaining cost to any goal, with h∗=+∞h^*=+\infty if none is reachable. This handbook uses nonnegative admissible heuristics and zero heuristic at every goal. Edge costs are nonnegative.

2.3 Combining and constructing heuristics

Past papers · DA 2024–2026 (3 papers): 1 question, 1 mark

Write hih_i for candidate heuristic functions and h∗h^* for true remaining cost. A relaxed problem removes restrictions without increasing action costs. Its optimal remaining cost is a lower bound for the original problem. If each original transition is legal in the relaxed problem at no greater cost, relaxed shortest-path costs also satisfy consistency.

A heuristic h2h_2 dominates h1h_1 when h2(n)≥h1(n)h_2(n)\ge h_1(n) everywhere and both are admissible. It is at least as informative a lower bound. For consistent A* on the same problem, reachable states with optimal-path priority g∗(n)+h(n)<C∗g^*(n)+h(n)<C^* must be expanded before the optimal goal, where g∗g^* is least start-to-state cost and C∗C^* is optimal goal cost; equal-priority ties at C∗C^* need care when comparing counts. A stronger heuristic can cost more to compute.

2.4 Distance and puzzle heuristics

For a unit-cost sliding-tile puzzle, count misplaced numbered tiles, excluding the blank. Each move can put at most one such tile into its goal cell. Summed Manhattan distances of numbered tiles, also excluding the blank, form a stronger consistent lower bound: one move shifts one numbered tile by one cell. Do not add the misplaced count to Manhattan distance without a cost-partition proof.

Past papers · DA 2024–2026 (3 papers): 1 question, 2 marks

Let gg be stored path cost, hh the remaining-cost heuristic and f=g+hf=g+h the priority. A* repeatedly removes the entry with smallest g+hg+h. Keep a table containing state, best gg, parent, hh and ff. When a cheaper route is found, update its cost and parent, then insert/update its frontier entry. Ignore stale entries with an old larger cost.

VersionSufficient condition for optimality
Tree A*Admissible hh, goal tested on removal
Graph A*, never reopen an expanded stateConsistent hh, correct cost updates before expansion
Graph A*, reopen on improved ggAdmissible hh, correct improvements and stale-entry handling

For completeness on an infinite space, additionally assume finite branching, finite nonnegative heuristic values on relevant states, an edge-cost lower bound ε>0\varepsilon>0 and a finite-cost solution. The usual finite-graph version terminates with nonnegative costs and strict-improvement updates. A* can still require exponential memory and work; a heuristic is not a polynomial-time guarantee.

best[start] = 0; push(start, priority=h(start), cost=0)
while frontier is nonempty:
    n, saved_cost = pop_min()
    if saved_cost != best[n]: continue
    if n is a goal: return its stored path
    for each edge n -> v with cost c:
        candidate = best[n] + c
        if v is new or candidate < best[v]:
            best[v] = candidate; parent[v] = n
            push(v, priority=candidate+h(v), cost=candidate)
return failure

There is no permanent closed-set rejection in this version, so an improved expanded state is reopened. Use the question's tie rule in pop_min.

Here gg is path cost, hh a remaining-cost heuristic and f=g+hf=g+h. Iterative-deepening A* (IDA*) performs depth-first searches with a threshold on f=g+hf=g+h, increasing it to the smallest value that exceeded the previous threshold. With admissible hh, positive edge costs and finite branching it retains optimality while storing a path and pending successors, but can repeat substantial work. Recursive best-first search (RBFS) stores the best alternative bound and backtracks when the current route exceeds it. Memory-bounded A* can discard its worst leaves and retain backed-up bounds; sufficient memory to retain an optimal solution path is needed for its usual optimality guarantee.

Hill climbing keeps a current state and moves to a better neighbour. Local optima, ridges and plateaus can stop progress. Random restarts and limited sideways moves can help but do not give a general finite-run optimum guarantee. Beam search retains only a fixed number of candidate states and can discard the only solution route.

Last-minute recall

  • UCS uses gg, greedy uses hh, and A* uses g+hg+h.
  • Admissibility bounds total remaining cost; consistency bounds every edge.
  • Check zero heuristic at every goal.
  • A closed set without reopening needs consistency for the standard guarantee.
  • Max of admissible heuristics is admissible; a sum needs extra justification.
  • Absolute difference is admissible under the nonnegative convention.
  • Choose distance heuristics for the actual movement costs.
  • Trace improved paths, stale entries and ties explicitly.
  • Memory-saving search usually pays with repeated work or weaker guarantees.

Revise offline: the whole Artificial Intelligence handbook as one PDF

37 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections