Introduction
- Uniform-Cost Search explores states in all directions based on distances from start
- To obtain solutions more quickly, we can use additional information to guide node expansion
- This leads to informed search algorithms
4.1 Evaluation Function
Definition
- Evaluation function f(n): estimates the cost when a node n is selected as part of the solution
- The node with the lowest evaluation value is chosen first
- Allows selection of nodes more likely to lead to quick solutions
Comparison
- Uninformed Search: explores without additional guidance
- Informed Search: uses evaluation function to guide search toward goal
4.2 Heuristic Functions
Definition and Properties
- Heuristic function h(n): estimates the cost to reach a goal node from node n
- Problem-specific function with one constraint: if is a goal node, then
- Takes a node as input but evaluates only the state associated with that node
- Can be used alone or as part of an evaluation function
4.3 Greedy Best-first Search (GBFS)
Algorithm Overview
- Chooses to expand the node estimated to be closest to the goal
- Always selects the node with the smallest from the frontier
- Evaluation function:
- Expands nodes based on heuristic values without considering cost to reach those nodes
Example: Romania Route-Finding Problem
- Uses straight-line distance as heuristic function
- Straight-line distance heuristics (hSLD) for cities:
- Arad: 366, Bucharest: 0, Craiova: 160, Drobeta: 242
- Eforie: 161, Fagaras: 176, Giurgiu: 77, Hirsova: 151
- Iasi: 266, Lugoj: 244, Mehadia: 241, Neamt: 234
- Oradea: 380, Pitesti: 100, Rm Vilcea: 193, Sibiu: 253
- Timisoara: 329, Urziceni: 80, Vaslui: 199, Zerind: 374
Search Process
- Expands states in direction toward goal
- Visits only 4 states before finding solution in Romania example
- However: obtained solution is not optimal
Evaluation of Greedy Best-first Search
Completeness
- Tree Search: Incomplete - may get stuck in cycles even in finite state spaces
- Graph Search: Complete in finite state spaces
Optimality
- Not optimal: does not always return the solution with minimum cost
- Focuses only on estimated distance to goal, ignoring actual cost to reach current node
4.4 A* Search
Algorithm Overview
- Minimizes total cost from initial node to goal node
- Evaluation function:
- : actual cost to reach node from initial node
- : heuristic function (estimated cheapest cost from to goal)
- : estimated cost of cheapest solution through
Example: Romania Route-Finding Problem
- Search process showing -values:
- Arad:
- Sibiu:
- Oradea:
- Rm Vilcea:
- And so on...
Advantages
- Focuses on expanding nodes in direction to goal
- Considers cumulative actual cost when selecting nodes
- Can obtain optimal solution
4.4.1 Evaluating A* Search
Optimality Conditions
Tree Search
- A* using tree search is optimal if is an admissible heuristic
- Admissible heuristic: never overestimates the cost to reach the goal
- Formally: , where is actual optimal cost to reach goal from
Graph Search
- A* using graph search is optimal if is a consistent (monotone) heuristic
- Consistent heuristic: for every node and successor of :
- Analogous to triangle inequality in geometry
- Ensures is non-decreasing along any path
Completeness
- A* with consistent heuristic has these properties:
- Expands all nodes such that
- May expand some nodes with , including goal
- Does not expand any node with
- Complete if there are only finitely many nodes with
4.5 Admissible Heuristic Design
Requirements
- Never overestimates cost to reach goal
- Should be fast and efficient to compute
- Otherwise, benefits of informed search are diminished
4.5.1 Creating Admissible Heuristics from Relaxed Problems
General Approach
- Many search problems have constraints
- Relax some constraints to make problem easier
- Compute cost of relaxed solution directly
- This cost cost of original solution
- Provides realistic estimate of original cost
Example: Romania Route-Finding
- Original constraint: must follow roads on map
- Relaxed version: can travel in straight lines
- Heuristic: straight-line distances between cities
- Easy to compute and admissible
Example: 8-Puzzle Problem
Original Constraints:
- Tile can move from A to B if:
- A is adjacent to B (horizontally/vertically)
- B is blank
Three Relaxed Problems:
Relaxed Problem (a): Remove both constraints
- Tile can move to any location
- : number of misplaced tiles
- Example: for goal state , state has
Relaxed Problem (b): Remove constraint (2) only
- Tile can move to adjacent location, ignoring blank
- : sum of Manhattan distances from each tile to goal position
- Manhattan distance =
- More accurate than
Relaxed Problem (c): Remove constraint (1) only
- Tile can move to blank location, ignoring adjacency
- : number of swaps between misplaced tiles and blank
- Similar to but more complex to compute
Implementation Notes
- Both GBFS and A* can be implemented by modifying uniform-cost search
- Use -value as priority in min-heap
- Need to implement problem-specific heuristic function
Key Takeaways
Algorithm Comparison
- Uniform-Cost Search: explores uniformly, guaranteed optimal
- Greedy Best-first: fast but not optimal
- A*: optimal (with admissible/consistent heuristics) and efficient
Heuristic Quality
- Better heuristics lead to more efficient search
- (Manhattan distance) typically better than (misplaced tiles)
- Consistency is stronger condition than admissibility
- Consistent heuristics are also admissible
Practical Considerations
- Heuristic computation time vs. search efficiency trade-off
- Domain knowledge crucial for designing good heuristics
- Relaxed problems provide systematic way to create admissible heuristics