Heuristic Design Techniques

GATE Relevance: High

Prerequisites

🎯 Learning Objectives

  • Generate admissible heuristics from relaxed problems
  • Combine multiple heuristics with max()
  • Understand heuristic dominance and its effect on performance
  • Apply linear combination and learning-based approaches

1. Relaxed Problems

The most common technique for inventing admissible heuristics is to solve a relaxed version of the problem — one with fewer constraints on the actions. The exact cost of the optimal solution to the relaxed problem is always an admissible heuristic for the original problem because removing constraints can only make the problem easier (or keep it the same).

8-Puzzle Relaxations

Original rule: A tile can move from square A to square B if A is adjacent to B and B is blank.

  • Relaxation 1 (remove “B is blank”): Tiles can move to any adjacent square → optimal cost = Manhattan distance.
  • Relaxation 2 (remove both conditions): Tiles can move to any square → optimal cost = Misplaced tiles (Hamming distance).
  • Relaxation 3 (remove “A is adjacent to B”): Tiles can move to the blank → Gaschnig’s heuristic (counts swaps with blank needed).
GATE Tip: Automatic Generation

The relaxed-problem method can be automated. Given a formal description of the problem constraints, a program can systematically remove constraints and compute the resulting heuristic. This was demonstrated by Prieditis (1993) with the ABSOLVER system.

2. Max of Multiple Heuristics

Given admissible heuristics h1, h2, …, hk, define:

h(n) = max(h₁(n), h₂(n), …, hₖ(n))

This composite heuristic is:

  • Admissible: Since each hi(n) ≤ h*(n), max of them is also ≤ h*(n).
  • Dominant: h(n) ≥ hi(n) for all i, so it dominates each individual heuristic.
  • Consistent: If each hi is consistent, then max is also consistent.
Example: Combining 8-Puzzle Heuristics
State: [1,2,3 | 4,_,5 | 7,8,6]  (goal: [1,2,3 | 4,5,6 | 7,8,_])
h_misplaced = 3 (tiles 5, 6, blank)
h_manhattan = 1(5→right) + 2(6→down+right) + 2(blank→down+right) = 5
h_max = max(3, 5) = 5

The max heuristic gives h=5, which is more informative than either alone.

3. Heuristic Dominance

h2 dominates h1 if for every node n: h2(n) ≥ h1(n), and both are admissible.

Theorem: If h2 dominates h1, then A* with h2 will never expand more nodes than A* with h1 (they expand the same set of nodes or fewer).

This means a higher admissible heuristic is always better or equal in terms of nodes expanded.

8-Puzzle: Nodes Expanded (average) at Various Depths
Depth (d)IDS (h=0)h = Misplaced Tilesh = Manhattan
86,3843925
143,473,941539113
20—7,276676
24—39,1351,641

Manhattan dominates Misplaced Tiles, and the table shows dramatic reductions in nodes expanded.

4. Linear Combination of Features

A heuristic can be defined as a weighted sum of features:

h(n) = w₁ · f₁(n) + w₂ · f₂(n) + … + wₖ · fₖ(n)

Where fi are problem features (like number of misplaced tiles, distance metrics, etc.) and wi are non-negative weights.

⚠ Admissibility Not Guaranteed

A linear combination of admissible heuristics is not necessarily admissible! If w1·h1(n) + w2·h2(n) > h*(n) for some n, optimality is lost. Only use this when admissibility is not required, or verify the sum is bounded by h*.

5. Learning Heuristics from Experience

Heuristic weights can be learned by solving many random instances of a problem optimally, then using regression or neural networks to predict h*(n) from state features.

  1. Generate many random problem instances.
  2. Solve each optimally (e.g., with IDA* and a known heuristic).
  3. For each state n on the optimal path, record (features(n), h*(n)).
  4. Train a model to predict h*(n) from features(n).

This approach was used by Samadi et al. (2008) to learn heuristics for Rubik’s Cube that outperformed hand-crafted heuristics.

6. Worked Examples

Example 1: Deriving a Heuristic via Relaxation (Logistics Problem)

Problem: A robot must pick up 3 packages at different locations and deliver them to a depot. It can carry only 1 package at a time.

Relaxation (remove “carry only 1”): The robot can carry all packages simultaneously. Optimal relaxed cost = distance from robot to farthest package + distance from farthest package to depot = max(d(robot, pi) + d(pi, depot)). This is admissible because the real problem requires at least this many moves.

Example 2: Proving Dominance

Given: h1 = number of misplaced tiles. h2 = sum of Manhattan distances. Prove h2 dominates h1.

Proof: Each misplaced tile contributes ≥ 1 to Manhattan distance (since it is at least 1 step from its goal position). Tiles already in place contribute 0 to both. So for each tile: Manhattan(tile) ≥ Misplaced(tile). Summing over all tiles: h2(n) ≥ h1(n) for all n. ■

Example 3: Computing max() Heuristic

For a grid pathfinding problem with obstacles, three heuristics are:

  • h1(n) = Manhattan distance to goal = 7
  • h2(n) = Euclidean distance to goal = 5.83
  • h3(n) = Chebyshev distance to goal = 5

h(n) = max(7, 5.83, 5) = 7. We use Manhattan as it dominates the other two for this state. Note: the max can vary per state — different heuristics may “win” at different nodes.

Summary

  • Relaxed problems are the primary source of admissible heuristics.
  • max(h1, h2, …) is admissible and dominates each individual hi.
  • Higher (closer to h*) admissible heuristics mean fewer nodes expanded.
  • Linear combinations of features are useful but may not be admissible.
  • Heuristics can be learned from solved problem instances.