UNIT 2 – Problem Solving & Search in AI
1. Problem-Solving in AI
Problem-solving in AI is the process of finding a sequence of actions that transforms the initial state
into the goal state.
Key Components:
1. Initial state – The starting point of the problem.
2. Actions – Set of possible moves.
3. Transition model – Rules defining results of actions.
4. Goal test – Checks if the goal has been reached.
5. Path cost – Numeric cost of a path; the solution is the path with the lowest cost.
2. Problem-Solving Agent
A problem-solving agent is a goal-based agent that decides on actions by searching through
possible sequences to reach the goal.
Example: A GPS navigation system that finds the shortest route between two locations.
3. Difference Between Simple Reflex Agent and Problem-Solving Agent
- Simple Reflex Agent: Acts only on current percepts without considering the future or goal.
Example: Thermostat that turns heater on/off based on temperature.
- Problem-Solving Agent: Considers future actions and searches for solutions to achieve goals.
Example: Chess-playing AI that plans moves ahead.
4. Example Problem – 8-Puzzle
A 3×3 grid with 8 tiles and 1 blank space. The goal is to arrange the tiles into a specified
configuration by sliding tiles into the blank space.
Used to illustrate search algorithms and heuristics.
5. Search Algorithms
(A) Uninformed Search (Blind Search): No domain-specific knowledge is used.
Examples:
- Breadth-First Search (BFS): Explores level by level. Complete and optimal for uniform step cost.
High memory usage.
- Depth-First Search (DFS): Explores deep into one branch before backtracking. Low memory
usage but may get stuck in infinite paths.
- Uniform Cost Search: Expands the lowest path-cost node first.
(B) Informed Search: Uses heuristics to guide search toward the goal more efficiently.
Examples:
- Greedy Best-First Search: Selects node with the lowest heuristic value h(n). Fast but not always
optimal.
- A* Search: Uses f(n) = g(n) + h(n).
• g(n) = Cost to reach the node from the start.
• h(n) = Estimated cost from the node to the goal.
• f(n) = Total estimated cost of the cheapest solution through node n.
• A* is optimal if the heuristic h(n) is admissible and consistent.
6. BFS vs DFS Comparison
- BFS: Explores all nodes at the present depth before moving to the next level.
Advantages: Complete, finds shortest path for uniform step cost.
Disadvantages: High memory usage.
- DFS: Explores along one branch deeply before backtracking.
Advantages: Low memory use, can find a solution without exploring all nodes.
Disadvantages: Not complete for infinite spaces, may not find shortest path.
7. Heuristic Functions
Definition: A function that estimates the cost from the current state to the goal.
Properties:
- Admissible: Never overestimates cost.
- Consistent: Satisfies h(n) ≤ cost(n, a, n') + h(n').
8. Search in Complex Environments
Challenges: Large state space, partial observability, dynamic and changing conditions, uncertain
actions.
Example: Robot navigating in an unknown building with moving obstacles.
9. Local Search and Optimization
Hill Climbing: Moves to the neighbor with the highest value (or lowest cost). Problem: Can get
stuck in local maxima or plateaus.
Simulated Annealing: Starts like hill climbing but sometimes accepts worse solutions to escape
local maxima. Probability of accepting worse moves decreases over time (cooling schedule).