Title: Search is a universal problem-solving method
1Search Chapter 3
Search is a universal problem-solving
method Search algorithms based on Problem-Space
Model The task Find a sequence of operations
that map initial state to goal state. Search
methods Breadth-first, Depth-first, A
(heuristic)
2Problem space model
- Problem space is the environment in which the
search takes place. - A set of states of the problem
- Operators
- Problem instance
- Problem space,
- initial state,
- goal state
3Eight Puzzle
4Vacuum world problem (state) space graph
states? actions? Initial? goal?
5The Russian Farmer Problem
6(F,W,G,C) (l, l, l, l)
7Tree versus Graph
- Most problem spaces correspond to graphs with
more than one paths between two nodes - Duplicate nodes increasing the size of the tree
- For simplicity they are represented as a tree
with initial state as root - The cost
- Duplicate nodes
- Increased tree size
- Benefit
- Absence of cycles simplifying most search
algorithms
8What differenciates AI search algorithms from
other graph based search algorithms is the size
of the graph. The Entire Chess graph has over 1040
- State space of AI problems never represented
explicitly by listing each state. - Size not expressed in terms of number of nodes
- Instead
- Branching factor (b)- average number of children
- Solution depth (d)- length of shortest path from
initial to goal - Or shortest
sequence of operators
9Brute-Force Search Uninformed search strategies
use only the information available in the problem
definition
- State description
- Set of legal operators
- Initial state
- Description of goal state
- Important brute force techniques
- Breadth first
- Uniform-cost
- Depth-first
- Interactive deepening
- Bidirectional
Terminology Generate node Create a DS
corresponding to node Expand node Generate all
children of the node
10Breadth First
- Expand nodes in order of their distance from root
one level at a time until solution found
11Implementation
- Queue (FIFO) of nodes initially containing the
root - Remove the node at the head of the queue and
expand - Add children to the tail of the queue
Space bound and exhaust memory in a few minutes.
Always finds the shortest path to a goal Time
spent Proportional to the number of nodes
generated(constant and f of b d) Number of
nodes at level d is bd Total number of nodes
generated in worst case bb2 b3 bd which
is O (bd)
12Uniform-Cost Search
- Edges have different costs
- Instead of expanding nodes in order of their
depth from root expand in order of cost from root - At each step, expand a node whose cost g(n) is
lowest where g(n) is sum of costs of edges from
root to node n - Nodes are stored in a priority queue
- Worst case time complexity
- O (bc/m) where c is the cost of an optimal
solution and m is the minimum edge cost
Problem Memory- similar to breadth first
13Depth-First Search
- Remedies space limitation of breadth first by
always generating a child of the deepest
unexpanded node.
14Implementation
- Maintain a list of unexpanded nodes treated as a
LIFO stack (as opposed to FIFO for breadth first - Usually implemented recrsively- with the
recursion stack taking the place of an explicit
node stack - Time complexity is O (bd)-Practically DF is time
limited and BF is space limited - Disadvantage does not terminate if tree infinite
or cycles in graph - Solution cutoff depth (d)
- d small?
- d large?
15Depth First Interactive Deepening
Combines best features of DF and BF
Performs a depth first to depth 1 then starts
over executing a complete depth first to depth 2
and continues to run depth first searches to
successive greater depths until a solution is
found.
Optimal in terms of time and space among all
brute force algorithms on a tree.