Problem Solving and Heuristic Search Strategies in Artificial Intelligence

Foundations of Heuristic Search and Informed Search Strategies

  • Informed Search Paradigm:

    • Unlike uninformed search algorithms that systematically inspect the state space without domain-specific guidance, informed search algorithms leverage problem-specific knowledge.
    • This knowledge encompasses estimates of distance to the goal, accumulated path cost, and optimal traversal strategies, enabling the agent to prune unproductive paths and explore dramatically smaller portions of the search space.
    • Informed search is particularly essential for large or infinite state spaces where uninformed exploration becomes computationally intractable.
  • Heuristic Functions:

    • A heuristic function, denoted as h(n)h(n), evaluates a state nn and produces an estimated cost of the cheapest path from state nn to a goal state.
    • The value of the heuristic function is non-negative: h(n)≥0h(n) \ge 0 for all states nn, with h(Goal)=0h(\text{Goal}) = 0.
    • Admissibility Condition:
    • A heuristic is admissible if it never overestimates the true cost to reach the nearest goal state.
    • Formally, h(n)≤h∗(n)h(n) \le h^*(n), where h(n)h(n) is the heuristic estimate and h∗(n)h^*(n) is the true optimal cost from state nn to the goal.
    • Admissible heuristics are inherently optimistic.
    • Pure Heuristic Search:
    • Represents the most basic form of heuristic search, expanding nodes solely based on their heuristic estimate h(n)h(n), without considering the cost accumulated from the start state.
  • Greedy Best-First Search:

    • Evaluates nodes using the evaluation function f(n)=h(n)f(n) = h(n), selecting the node that appears closest to the goal state at that immediate moment.
    • It combines features of breadth-first and depth-first search, operating with a priority queue prioritized by ascending values of h(n)h(n).
    • Data Structures:
    • OPEN list (frontier): contains all generated nodes awaiting expansion, sorted by h(n)h(n).
    • CLOSED list (explored set): stores all nodes that have already been expanded to prevent infinite loops and repeated work.
    • Algorithmic Execution Procedure:
    • Step 1: Insert the initial start state into the OPEN list.
    • Step 2: If the OPEN list is empty, terminate and return failure.
    • Step 3: Remove the node nn from the OPEN list with the minimal value of h(n)h(n) and append it to the CLOSED list.
    • Step 4: Expand node nn, generating all of its successor states.
    • Step 5: For each successor, check if it satisfies the goal test. If any successor is a goal, terminate and return the solution path; otherwise, proceed to Step 6.
    • Step 6: For each generated successor, compute f(n)=h(n)f(n) = h(n). If the node is not present in either the OPEN or CLOSED list, insert it into the OPEN list.
    • Step 7: Return to Step 2.
    • Theoretical Properties:
    • Time Complexity: Worst-case time complexity is O(bm)O(b^m), where bb is the branching factor and mm is the maximum depth of the search space.
    • Space Complexity: Worst-case space complexity is O(bm)O(b^m) because all generated nodes are retained in memory.
    • Completeness: Incomplete, even in finite state spaces, because it can become trapped in infinite loops like unguided depth-first search.
    • Optimality: Non-optimal, as it may follow a path with low heuristic values that ultimately incurs a high total path cost.
    • Greedy Best-First Search Worked Example:
    • Consider the search graph with root state SS and goal state GG:

Greedy best-first search tree and heuristic table

* **State Heuristic Values**:
  * h(S)=13h(S) = 13
  * h(A)=12h(A) = 12
  * h(B)=4h(B) = 4
  * h(C)=7h(C) = 7
  * h(D)=3h(D) = 3
  * h(E)=8h(E) = 8
  * h(F)=2h(F) = 2
  * h(H)=4h(H) = 4
  * h(I)=9h(I) = 9
  * h(G)=0h(G) = 0
* **Step-by-step Trace**:
  * Initialization: `OPEN` = [S(13)][S(13)], `CLOSED` = [][]
  * Iteration 1: Expand SS, generating AA and BB. `OPEN` = [B(4),A(12)][B(4), A(12)], `CLOSED` = [S][S]
  * Iteration 2: Expand BB, generating EE and FF. `OPEN` = [F(2),E(8),A(12)][F(2), E(8), A(12)], `CLOSED` = [S,B][S, B]
  * Iteration 3: Expand FF, generating II and GG. `OPEN` = [G(0),E(8),I(9),A(12)][G(0), E(8), I(9), A(12)], `CLOSED` = [S,B,F][S, B, F]
  * Iteration 4: Node GG has h(G)=0h(G) = 0 and is identified as the goal state. Terminate with success.
* **Final Path**:
  * Resulting trajectory: S→B→F→GS \rightarrow B \rightarrow F \rightarrow G

Greedy best-first search traversal path

A* Search Algorithm and Optimality Guarantees

  • Formulation of A* Search:
    • A* search evaluates nodes by integrating both the backward cost already incurred to reach the node and the estimated forward cost to reach the goal.
    • Evaluation function: f(n)=g(n)+h(n)f(n) = g(n) + h(n)
    • g(n)g(n): Exact cost incurred to reach node nn from the initial start state.
    • h(n)h(n): Heuristic estimate of the cheapest path cost from node nn to a goal node.
    • f(n)f(n): Estimated total cost of the cheapest solution passing through node nn, often termed the fitness number.

A* evaluation function components

  • A* Algorithmic Procedure:

    • Step 1: Place the starting node SS into the OPEN list with f(S)=g(S)+h(S)=0+h(S)f(S) = g(S) + h(S) = 0 + h(S).
    • Step 2: If the OPEN list is empty, terminate and return failure.
    • Step 3: Select and remove the node nn from OPEN having the minimal value of f(n)f(n). If nn is a goal state, terminate with success and return the constructed path.
    • Step 4: Expand node nn, generate all of its successors n′n', and place node nn into the CLOSED list.
    • Step 5: For each successor n′n':
    • Compute g(n′)=g(n)+c(n,a,n′)g(n') = g(n) + c(n, a, n') and f(n′)=g(n′)+h(n′)f(n') = g(n') + h(n').
    • If n′n' is neither in OPEN nor in CLOSED, add it to OPEN.
    • If n′n' already exists in OPEN or CLOSED, check if the newly calculated g(n′)g(n') is strictly lower than its previous cost. If so, update its back-pointer to point to nn, update its stored g(n′)g(n') and f(n′)f(n') values, and if it was in CLOSED, return it to OPEN.
    • Step 6: Return to Step 2.
  • Optimality and Completeness Conditions:

    • Completeness: Guaranteed if the branching factor bb is finite and every step cost is strictly positive (bounded below by a fixed constant ϵ>0\epsilon > 0).
    • Optimality in Tree Search: Requires that h(n)h(n) is an admissible heuristic (h(n)≤h∗(n)h(n) \le h^*(n)).
    • Optimality in Graph Search: Requires consistency (monotonicity):
    • For every node nn and successor n′n' generated by action aa, h(n)≤c(n,a,n′)+h(n′)h(n) \le c(n, a, n') + h(n').
    • Consistency enforces that the ff-values along any path are monotonically non-decreasing, ensuring that the first time a state is expanded, the path to it is guaranteed to be optimal.
    • Complexity Analysis:
    • Time Complexity: O(bd)O(b^d), where dd is the depth of the optimal solution.
    • Space Complexity: O(bd)O(b^d), because A* preserves all generated nodes in memory, which constitutes its principal practical computational bottleneck.
  • A* Search Worked Example:

    • Given the following directed state space graph with action costs and heuristic table:

A* search graph and heuristic values

  • State Heuristic Values:
    • h(S)=5h(S) = 5
    • h(A)=3h(A) = 3
    • h(B)=4h(B) = 4
    • h(C)=2h(C) = 2
    • h(D)=6h(D) = 6
    • h(G)=0h(G) = 0
  • Edge Costs:
    • c(S,A)=1c(S, A) = 1
    • c(S,G)=10c(S, G) = 10
    • c(A,B)=2c(A, B) = 2
    • c(A,C)=1c(A, C) = 1
    • c(B,D)=5c(B, D) = 5
    • c(C,D)=3c(C, D) = 3
    • c(C,G)=4c(C, G) = 4
    • c(D,G)=2c(D, G) = 2
  • Trace of Iterations:
    • Initialization:
      • OPEN = {(S,f=0+5=5)}\{(S, f=0+5=5)\}, CLOSED = [][]
    • Iteration 1:
      • Expand SS. Successors are AA and GG:
      • Path S→AS \rightarrow A: g=1g = 1, f=1+3=4f = 1 + 3 = 4
      • Path S→GS \rightarrow G: g=10g = 10, f=10+0=10f = 10 + 0 = 10
      • OPEN = {(S→A,4),(S→G,10)}\{(S \rightarrow A, 4), (S \rightarrow G, 10)\}, CLOSED = [S][S]
    • Iteration 2:
      • Expand AA (lowest f=4f=4). Successors are BB and CC:
      • Path S→A→BS \rightarrow A \rightarrow B: g=1+2=3g = 1 + 2 = 3, f=3+4=7f = 3 + 4 = 7
      • Path S→A→CS \rightarrow A \rightarrow C: g=1+1=2g = 1 + 1 = 2, f=2+2=4f = 2 + 2 = 4
      • OPEN = {(S→A→C,4),(S→A→B,7),(S→G,10)}\{(S \rightarrow A \rightarrow C, 4), (S \rightarrow A \rightarrow B, 7), (S \rightarrow G, 10)\}, CLOSED = [S,A][S, A]
    • Iteration 3:
      • Expand CC (lowest f=4f=4). Successors are DD and GG:
      • Path S→A→C→DS \rightarrow A \rightarrow C \rightarrow D: g=2+3=5g = 2 + 3 = 5, f=5+6=11f = 5 + 6 = 11
      • Path S→A→C→GS \rightarrow A \rightarrow C \rightarrow G: g=2+4=6g = 2 + 4 = 6, f=6+0=6f = 6 + 0 = 6
      • OPEN = {(S→A→C→G,6),(S→A→B,7),(S→G,10),(S→A→C→D,11)}\{(S \rightarrow A \rightarrow C \rightarrow G, 6), (S \rightarrow A \rightarrow B, 7), (S \rightarrow G, 10), (S \rightarrow A \rightarrow C \rightarrow D, 11)\}, CLOSED = [S,A,C][S, A, C]
    • Iteration 4:
      • Select path S→A→C→GS \rightarrow A \rightarrow C \rightarrow G with minimal f=6f = 6.
      • State GG is the goal. Terminate with success.
    • Optimal Solution Path:
      • S→A→C→GS \rightarrow A \rightarrow C \rightarrow G with total optimal path cost g=6g = 6.

A* search tree expansion and optimal path

Local Search and Optimization in Discrete State Spaces

  • Local Search Foundations:

    • In many computational domains, the path to the solution is completely irrelevant; only the final configuration matters (e.g., 8-queens, IC layout, factory floor configuration, portfolio optimization).
    • Local search algorithms operate from a single current state (or a small set of states) and move exclusively to neighboring states without tracking traversal history or retaining the path.
    • Key Advantages:
    • Minimal memory footprint: frequently requires only O(1)O(1) memory space.
    • Capable of finding valid configurations in immense, continuous, or infinite state spaces where systematic frontier-based algorithms fail.
  • The State-Space Landscape:

    • States are mapped across a topological surface where the elevation represents an objective function (for maximization, termed hill climbing) or a cost function (for minimization, termed gradient descent).

State-space landscape diagram

  • Topological Landscape Features:

    • Global Maximum: The state with the highest absolute objective function value across the entire space.

    • Local Maximum: A peak whose value is higher than all its immediate neighbors, but lower than the global maximum.

    • Flat Local Maximum: A flat plateau region with no uphill exit, where all neighboring states have identical elevation.

    • Shoulder: A horizontal plateau that eventually allows progress uphill.

    • Ridge: A steep, narrow sequence of local maxima oriented along an angle, where moves aligned with the coordinate axes point downhill.

    • Hill-Climbing Search (Steepest-Ascent):

  • Continuously evaluates neighboring states and moves in the direction of the steepest ascent (maximum immediate gain in the objective function).

  • Terminating condition: halts when reaching a state whose neighbors all have lower or equal value.

Hill-climbing search algorithm pseudocode

  • The 8-Queens Problem Formulation:
    • Complete-state formulation: All 8 queens are placed on the board, exactly one queen per column.
    • State space size: 88≈1.7×1078^8 \approx 1.7 \times 10^7 (approximately 17 million17\text{ million}) possible board states.
    • Successor definition: Move any single queen to any other row within its column, yielding 8×7=568 \times 7 = 56 successors per state.
    • Heuristic cost function hh: The total number of pairs of attacking queens (direct or indirect). A valid solution has h=0h = 0.

8-queens states showing near-solution and successor heuristic evaluations

  • Performance Metrics on 8-Queens:

    • Starting from random initial states, steepest-ascent hill climbing succeeds only 14%14\% of the time, getting trapped in local maxima or plateaus in 86%86\% of instances.

    • Rapid runtime: averages 44 steps to find a solution when successful, and 33 steps before becoming trapped.

    • Introducing a maximum threshold of 100100 consecutive sideways moves raises the success rate from 14%14\% to 94%94\%.

    • Trade-off: Average steps on success increase to approximately 2121, while failed runs average 6464 steps.

    • Pathologies of Hill Climbing:

  • Local Maxima: The search gets trapped because every single available transition decreases the objective function value.

  • Ridges: Greedy search oscillates back and forth across the crest, making negligible longitudinal progress because orthogonal moves lead downhill.

Illustration of a ridge in a state-space landscape

  • Plateaus: Greedy search drifts aimlessly due to zero-gradient evaluation across all neighbors.

    • Variants of Hill Climbing:
  • Stochastic Hill Climbing: Selects randomly among uphill moves, where the probability of selecting an action is proportional to the steepness of the climb.

  • First-Choice Hill Climbing: Implements stochastic hill climbing by generating successors sequentially at random until one is found that is strictly superior to the current state; advantageous when thousands of successors exist.

  • Random-Restart Hill Climbing:

    • Conducts iterative hill-climbing searches from randomly generated initial states until a goal is attained.
    • Complete with probability 11 in finite state spaces.
    • Mathematical formulation: If each search instance has probability pp of success, the expected number of restarts is:       Expected Restarts=1p\text{Expected Restarts} = \frac{1}{p}
    • The total expected cost (in steps) is:       Expected Steps=Costsuccess+1−pp×Costfailure\text{Expected Steps} = \text{Cost}_{\text{success}} + \frac{1 - p}{p} \times \text{Cost}_{\text{failure}}
    • For 8-queens without sideways moves (p≈0.14p \approx 0.14), expected restarts are approximately 77 (66 failures and 11 success), requiring approximately 2222 total steps.
    • When sideways moves are permitted (p=0.94p = 0.94), expected iterations drop to 1/0.94≈1.061 / 0.94 \approx 1.06, with expected total steps calculated as:       (1×21)+(0.060.94)×64≈25 steps(1 \times 21) + \left(\frac{0.06}{0.94}\right) \times 64 \approx 25\text{ steps}

Stochastic Local Search: Simulated Annealing, Beam Search, and Evolutionary Algorithms

  • Simulated Annealing:
    • Combines hill climbing with a controlled random walk to escape local extrema while maintaining asymptotic convergence toward the global optimum.
    • Inspired by metallurgical annealing, where metals are heated to high temperatures (liquid state) and gradually cooled to form low-energy, defect-free crystalline structures.
    • Operates like shaking a bumpy surface to bounce a ball out of local depressions into deeper valleys.

Simulated annealing algorithm pseudocode

  • Mathematical Acceptance Criterion:

    • At each step, a successor state nextnext is chosen uniformly at random.

    • The change in objective value is calculated as ΔE=VALUE(current)−VALUE(next)\Delta E = \text{VALUE}(current) - \text{VALUE}(next) (for minimization/cost) or ΔE=VALUE(next)−VALUE(current)\Delta E = \text{VALUE}(next) - \text{VALUE}(current) (for maximization).

    • If the move improves the evaluation (ΔE>0\Delta E > 0), it is unconditionally accepted.

    • If the move worsens the evaluation, it is accepted probabilistically according to the Boltzmann distribution factor:       P(acceptance)=e−ΔETP(\text{acceptance}) = e^{-\frac{\Delta E}{T}}

    • Where TT is the temperature parameter dictated by an annealing schedule T=schedule(t)T = \text{schedule}(t).

    • High TT allows frequent downhill transitions; as T→0T \rightarrow 0, downhill probability approaches zero, transforming the process into pure greedy local search.

    • If the cooling schedule reduces TT sufficiently slowly, the algorithm converges to the global maximum with probability approaching 11.

    • Local Beam Search:

  • Tracks kk distinct states concurrently rather than maintaining a single active node.

  • Begins with kk randomly initialized states. At each iteration, all successors of all kk states are generated.

  • If any successor represents the goal, search halts; otherwise, it retains the kk best successors from the combined pool of all generated states.

  • Information Sharing:

    • Unlike kk independent random restarts executed in parallel, beam search facilitates information sharing across parallel threads: search resources dynamically abandon unpromising regions and concentrate around the most fruitful areas.
  • Clustering Pathology & Stochastic Beam Search:

    • Standard beam search frequently suffers from rapid diversity loss, as all kk states quickly converge to the same localized region of the state space.

    • Stochastic Beam Search: Alleviates clustering by selecting kk successors probabilistically in proportion to their fitness value, similar to natural selection.

    • Genetic Algorithms (Evolutionary Algorithms):

  • Form of stochastic beam search directly inspired by biological evolution and sexual recombination.

  • Individual states are encoded as finite strings over an alphabet (e.g., binary bit strings, base-10 digit strings).

  • Key Components:

    • Population Size: Number of individual configurations maintained in memory.
    • Mixing Number (\rho): Number of parents combined to generate offspring (standard is ρ=2\rho = 2; ρ=1\rho = 1 corresponds to asexual stochastic beam search).
    • Selection Operator: Parents are chosen probabilistically weighted by their relative fitness scores.
    • Crossover (Recombination): Combines genetic material from parents by splitting strings at a chosen crossover point.
    • Mutation: Independent bit-flip or digit-replacement applied at each position with a small probability.
    • Elitism and Culling: Elitism retains top-performing parents in subsequent generations to guarantee monotonically non-decreasing maximum fitness; culling removes candidates falling below a strict fitness threshold.

Genetic algorithm pipeline from initial population to mutation

  • 8-Queens Problem Genetic Encoding:
    • States are represented as 8-digit strings where the cc-th digit denotes the row of the queen in column cc.
    • Maximum possible fitness value (non-attacking pairs) is:       Max Fitness=8×72=28\text{Max Fitness} = \frac{8 \times 7}{2} = 28
    • Example population with fitness scores and selection probabilities:
      • Individual 1: 24748552, Fitness = 2424, Selection Probability = 31%31\%
      • Individual 2: 32752411, Fitness = 2323, Selection Probability = 29%29\%
      • Individual 3: 24415124, Fitness = 2020, Selection Probability = 26%26\%
      • Individual 4: 32543213, Fitness = 1111, Selection Probability = 14%14\%
    • Mating selection: Random crossover points are selected. Parents 32752411 and 24748552 crossed at position 3 yield offspring 32748552 and 24752411.

Crossover in the 8-queens problem

Genetic algorithm and reproduction pseudocode

  • Schema Theory:
    • A schema is a structural template specifying values at certain string positions while leaving others unspecified using wildcards (e.g., 246*****).
    • Strings matching a schema are instances of that schema.
    • If the average fitness of instances of a schema exceeds the population mean, the frequency of that schema grows exponentially over successive generations.

Local Search in Continuous State Spaces and Optimization Techniques

  • Continuous State Space Foundations:

    • Physical real-world problems frequently present continuous action and state spaces, resulting in an infinite branching factor.
    • States are represented by an nn-dimensional vector of continuous variables: x=(x1,x2,…,xn)\mathbf{x} = (x_1, x_2, \dots, x_n).
  • Airport Placement Example in Romania:

    • Task: Situate 33 new airports across Romania such that the cumulative sum of squared Euclidean distances from each city to its closest airport is minimized.

Map of Romania with inter-city distances

  • State Representation:
    • 6-dimensional continuous state vector: x=(x1,y1,x2,y2,x3,y3)\mathbf{x} = (x_1, y_1, x_2, y_2, x_3, y_3)
  • Objective Function:
    • Let CiC_i denote the set of cities whose closest facility is airport ii:

Sum of squared distances objective function

* f(x)=∑i=13∑c∈Ci((xi−xc)2+(yi−yc)2)f(\mathbf{x}) = \sum_{i=1}^3 \sum_{c \in C_i} \left( (x_i - x_c)^2 + (y_i - y_c)^2 \right)
* This formulation holds in the local neighborhood of x\mathbf{x}; large displacements alter the Voronoi partitioning of cities, changing sets CiC_i.
  • Handling Continuous Spaces:

    • Discretization: Constrain variables to a grid with step size δ\delta. In a 6-dimensional space, each variable can change by ±δ\pm\delta, reducing an infinite branching factor to exactly 1212 successors.
    • Empirical Gradient Methods: Measure the empirical slope between adjacent evaluations by perturbing coordinates by small amounts δ\delta.
    • Analytical Gradient Ascent / Descent:
    • The gradient vector ∇f(x)\nabla f(\mathbf{x}) specifies the magnitude and direction of the steepest ascent:       ∇f(x)=(∂f∂x1,∂f∂y1,…,∂f∂yn)\nabla f(\mathbf{x}) = \left( \frac{\partial f}{\partial x_1}, \frac{\partial f}{\partial y_1}, \dots, \frac{\partial f}{\partial y_n} \right)
    • For the airport problem, the local partial derivatives are:       ∂f∂xi=2∑c∈Ci(xi−xc)\frac{\partial f}{\partial x_i} = 2 \sum_{c \in C_i} (x_i - x_c)∂f∂yi=2∑c∈Ci(yi−yc)\frac{\partial f}{\partial y_i} = 2 \sum_{c \in C_i} (y_i - y_c)
    • Parameter update rule with learning rate / step size α\alpha:       x←x+α∇f(x)\mathbf{x} \leftarrow \mathbf{x} + \alpha \nabla f(\mathbf{x})
    • Line search techniques mitigate poor choices of α\alpha by continually stepping along the gradient direction (e.g., doubling α\alpha) until the function value declines.
  • Newton-Raphson Optimization:

    • Root-finding technique for systems of equations g(x)=0g(\mathbf{x}) = 0. For optimization, we seek points where the gradient vanishes: ∇f(x)=0\nabla f(\mathbf{x}) = \mathbf{0}.
    • Second-order matrix-vector update utilizing the Hessian matrix Hf\mathbf{H}_f of second derivatives:     x←x−Hf−1(x)∇f(x)\mathbf{x} \leftarrow \mathbf{x} - \mathbf{H}_f^{-1}(\mathbf{x}) \nabla f(\mathbf{x})
  • Constrained Optimization:

    • Imposes hard constraints on candidate variables (e.g., airport coordinates must reside within national borders and on dry land).
    • Linear Programming (LP): Solves problems with linear constraints forming convex polyhedral feasible regions and a linear objective function. Time complexity is polynomial in the number of variables.
    • Convex Optimization: Generalization of linear programming where the constraint region is convex and the objective function is convex; solvable in polynomial time and scalable to thousands of variables.

Search in Nondeterministic Environments and AND-OR Search Trees

  • Nondeterministic Search Formalism:

    • In nondeterministic environments, actions can yield multiple possible outcomes; agents plan over belief states (sets of possible physical states).
    • Rather than generating a linear sequence of actions, solutions take the form of conditional plans (contingency plans) incorporating branching logic based on runtime observations.
  • The Erratic Vacuum World:

    • State space consists of 8 physical states:

Eight states of the vacuum world

  • Available actions: Left, Right, Suck.

  • Clean goal states: State 7 and State 8.

  • Erratic Suck Semantics:

    • When applied to a dirty square, it cleans the current square and non-deterministically cleans the adjacent square too.
    • When applied to a clean square, it sometimes deposits dirt on the square.
    • Generalized transition model function: RESULTS(1,Suck)={5,7}\text{RESULTS}(1, \text{Suck}) = \{5, 7\}.
  • Contingency Plan for State 1:

    • [Suck, if State = 5 then [Right, Suck] else [ ]]

    • AND-OR Search Trees:

  • Search trees alternate between two distinct node types:

    • OR Nodes: Correspond to agent action choices (Left, Right, Suck).
    • AND Nodes: Correspond to environmental nondeterminism where every branching outcome must be handled.

First two levels of the AND-OR search tree for the erratic vacuum world

  • Definition of a Solution Subtree:
    • Must contain a goal node at every terminating leaf.
    • Must specify exactly one action branch at each of its OR nodes.
    • Must include every possible outcome branch at each of its AND nodes.

AND-OR search algorithm pseudocode

  • Cycle Detection in AND-OR Search:

    • If a state matches an ancestor state along the current path from the root, the path terminates and returns failure.

    • Prevents infinite recursive loops and guarantees termination in finite state spaces.

    • Cyclic Plans in Slippery Environments:

  • In a slippery vacuum world, movement actions non-deterministically fail, leaving the agent in its current position (e.g., executing Right in state 1 yields belief state Δ={1,2}\Delta = \{1, 2\}.

  • Acyclic solutions do not exist; plans must incorporate explicit looping constructs:

    • Using while statements: [Suck, while State = 5 do Right, Suck]
    • Using labels: [Suck, L1: Right, if State = 5 then L1 else Suck]

Search graph for slippery vacuum world with cyclic paths

Search in Partially Observable Environments and Belief-State Spaces

  • Sensorless (Conformant) Problems:

    • Occur when an agent receives zero perceptual input (PERCEPT(s)=null\text{PERCEPT}(s) = \text{null}).
    • In an underlying physical environment with NN states, the belief-state search space contains 2N2^N possible belief states.
    • Solutions consist of open-loop linear action sequences that coerce the world into a goal state regardless of the initial starting state.
    • For the deterministic sensorless vacuum world, the initial belief state is the complete set of all states: {1,2,3,4,5,6,7,8}\{1, 2, 3, 4, 5, 6, 7, 8\}.
    • Coercive sequence: [Right, Suck, Left, Suck] guarantees arrival at goal state 7 from any initial state.
  • Belief-State Problem Formulation:

    • States: Subsets of the physical state space.
    • Initial State: Typically the set of all physical states in the problem.
    • Actions: If illegal actions have no adverse side effects, the legal actions are the union of actions across all constituent physical states: ⋃s∈bACTIONS(s)\bigcup_{s \in b} \text{ACTIONS}(s). If illegal actions cause catastrophic failures, safe actions are the intersection: ⋂s∈bACTIONS(s)\bigcap_{s \in b} \text{ACTIONS}(s).
    • Transition Model:
    • For deterministic physical actions: b′={s′:s′=RESULT(s,a) and s∈b}b' = \{s' : s' = \text{RESULT}(s, a) \text{ and } s \in b\}
    • For nondeterministic physical actions: b′=⋃s∈bRESULTS(s,a)b' = \bigcup_{s \in b} \text{RESULTS}(s, a)

Predicting next belief state for deterministic and slippery actions

  • Goal Test:

    • An agent possibly achieves the goal if at least one state in bb satisfies the goal test.

    • An agent necessarily achieves the goal if every state in bb satisfies the goal test.

    • Reachable Belief Space and Pruning:

  • In the deterministic sensorless vacuum world, only 1212 out of the 28=2562^8 = 256 possible belief states are reachable.

Reachable portion of belief-state space for sensorless vacuum world

  • Subset/Superset Pruning:

    • If a belief state b1b_1 is a superset of an already generated belief state b2b_2 (b1⊃b2b_1 \supset b_2), b1b_1 can be pruned because solving the larger uncertainty set is strictly harder than solving the smaller one.

    • If a larger belief state b1b_1 has been solved, any subset b2⊂b1b_2 \subset b_1 is guaranteed to be solved by the same action sequence.

    • Partially Observable Search with Sensing:

  • Belief-state transitions occur through three successive stages:

    • Prediction Stage: Compute the predicted state distribution following an action:       b^=PREDICT(b,a)=RESULT(b,a)\hat{b} = \text{PREDICT}(b, a) = \text{RESULT}(b, a)
    • Possible Percepts Stage: Compute the set of observations that could be perceived:       POSSIBLE-PERCEPTS(b^)={o:o=PERCEPT(s) and s∈b^}\text{POSSIBLE-PERCEPTS}(\hat{b}) = \{o : o = \text{PERCEPT}(s) \text{ and } s \in \hat{b}\}
    • Update Stage: Compute the refined belief state for each specific observation oo:       bo=UPDATE(b^,o)={s:s∈b^ and o=PERCEPT(s)}b_o = \text{UPDATE}(\hat{b}, o) = \{s : s \in \hat{b} \text{ and } o = \text{PERCEPT}(s)\}

Transitions in local-sensing vacuum worlds

AND-OR search tree for local-sensing vacuum world

  • Recursive State Estimation (Filtering / Monitoring):
    • Maintains the agent's internal belief state over time as actions are executed and percepts arrive:     b′=UPDATE(PREDICT(b,a),o)b' = \text{UPDATE}(\text{PREDICT}(b, a), o)

Two prediction-update cycles in kindergarten vacuum world

  • Robot Localization Worked Example:
    • Environment: Maze grid with walls and obstacles.
    • Sensors: Four sonar sensors outputting a 4-bit percept vector [North, East, South, West], where 1 indicates an obstacle.
    • Initial state: Complete ignorance across all open maze coordinates.
    • Step 1: Agent observes percept E1=1011E_1 = 1011 (obstacles North, South, West). The belief state collapses to exactly 44 matching physical coordinates.
    • Step 2: Agent executes Right, but faulty mobility results in a random nondeterministic move to an adjacent square, causing the predicted belief state to disperse across adjacent cells.
    • Step 3: Agent receives percept E2=1010E_2 = 1010. Applying the update equation collapses the belief state down to exactly 11 single unambiguous location coordinate.

Robot localization positions after sequential sonar observations

Online Search Agents in Unknown Environments

  • Online vs. Offline Search Paradigm:

    • Offline search algorithms compute a complete end-to-end path in a simulator prior to executing the first physical action.
    • Online search interleaves computation, sensing, and execution: the agent acts, observes the resulting state, updates its internal map, and determines its subsequent step.
    • Required in dynamic domains, unknown terrains, and nondeterministic environments.
  • Online Problem Formulation:

    • The agent only has access to:
    • ACTIONS(s)\text{ACTIONS}(s): Valid actions available in state ss.
    • c(s,a,s′)c(s, a, s'): Step cost function (usable only after observing transition to s′s').
    • IS-GOAL(s)\text{IS-GOAL}(s): Goal test function.
    • The transition model RESULT(s,a)\text{RESULT}(s, a) is entirely unknown prior to physical execution.

Simple maze problem with start and goal

  • Competitive Ratio:
    • The ratio of the actual path cost incurred by the online agent to the optimal path cost computed offline with full prior knowledge of the map.
  • Dead Ends and Adversary Arguments:
    • Irreversible actions lead to inescapable dead ends where no goal state remains reachable.
    • An adversary can construct topologies such that identical prior observation sequences lead to either dead ends or arbitrarily long detours.

State spaces causing dead ends and unbounded paths for online agents

  • Complete exploration guarantees are strictly restricted to safely explorable environments where every state can be reversed.

    • Online Depth-First Search Exploration:
  • Interleaves local node expansion with physical backtracking.

  • Maintains three persistent lookup tables:

    • result[s, a]: Stores the observed state resulting from taking action aa in state ss.
    • untried[s]: Tracks actions in state ss not yet executed.
    • unbacktracked[s]: Stack of predecessor states from which the agent entered state ss, used for physical backtracking.

Online depth-first search exploration agent pseudocode

  • Online Local Search and Learning Real-Time A* (LRTA*):
    • Standard hill climbing fails in online environments because agents become permanently trapped at local maxima, and teleportation via random restarts is physically impossible.
    • Pure random walks escape local traps asymptotically, but can take exponentially many steps in topological traps where backward transitions dominate.

State space where random walk takes exponential steps

  • LRTA* Core Principle:
    • Enhances local search with memory rather than randomness.
    • Maintains a persistent table H(s)H(s) of cost estimates, initialized to the admissible heuristic h(s)h(s).
    • Evaluates untried actions under the optimism-under-uncertainty assumption, presuming untried actions lead directly to the goal with cost h(s)h(s).
    • Updates the heuristic value of the state just departed (ss) to reflect the observed neighbor costs:       H(s)←min⁡b∈ACTIONS(s)LRTA*-COST(s,b,result[s,b],H)H(s) \leftarrow \min_{b \in \text{ACTIONS}(s)} \text{LRTA*-COST}(s, b, \text{result}[s, b], H)LRTA*-COST(s,b,s′,H)=c(s,b,s′)+H(s′)\text{LRTA*-COST}(s, b, s', H) = c(s, b, s') + H(s')
    • The agent then moves to the neighbor minimizing this cost estimate.

Five iterations of LRTA* on a one-dimensional state space

LRTA* agent and cost estimation pseudocode

  • Convergence Properties:
    • Guaranteed to discover the goal in any finite, safely explorable environment.
    • Worst-case exploration complexity across an environment of nn states is bounded by O(n2)O(n^2).
    • Learning mechanism: Sequentially updates the environmental map table result[s, a] while flattening out local heuristic depressions, progressively learning the optimal value function through real-time experience.