Professional Documents
Culture Documents
Ai Lecture02
Ai Lecture02
• Search problems
• Generic search algorithms
• Criteria for evaluating search algorithms
• Uninformed Search
– Breadth-First Search
– Depth-First Search
– Iterative Deepening
• Heuristics
Search in AI
Example: Eight-Puzzle
START
Example: Eight-Puzzle
5 4 5
1 4
2 3
6 1 88 6
8 84
7 3 22 7 6 25
Other Real-Lif
Example: Protein creation
Protein design
http://www.blueprint.org/proteinfolding/trades/trades_problem.html
Example: Eight-Puzzle
Example: Eight-Puzzle
5 4 5
1 4
2 3
6 1 88 6
8 84
7 3 22 7 6 25
Assumptions
The general search problem formulation does not make these assumptions,
but we will make them when discussing search algorithms
Specialize the abstract classes, and add the code that does the work
3 Search tree
start state A D
state = A,
cost = 0
state = B, state = D,
cost = 3 cost = 3
state = C, state = F,
cost = 5 cost = 12
goal state!
state = A,
cost = 7
1. Initialize the search tree using the initial state of the problem
2. Repeat
(a) If no candidate nodes can be expanded, return failure
(b) Choose a leaf node for expansion, according to some search strategy
(c) If the node contains a goal state, return the corresponding path
(d) Otherwise expand the node by:
• Applying each operator
• Generating the successor state
• Adding the resulting nodes to the tree
state = B, state = D,
cost = 3 cost = 3
goal state!
state = B, state = D,
.. cost = 10
.. cost = 10
. .
• If a state is not a goal, we cannot tell how close to the goal it might be
• Hence, all we can do is move systematically between states until we
stumble on a goal
• In contrast, informed (heuristic) search uses a guess on how close to the
goal a state might be
Example
Label all successors of states in V0 that have not yet been labelled as set V1
Example
!"
Label all successors of states in V1 that have not yet been labelled as set V2
Label all successors of states in V2 that have not yet been labelled as set V3
Example
!"
Label all successors of states in V3 that have not yet been labelled as set V4
!"#$%&'(")*$+,-$).$'/01#/#2)
Analyzing BFS
• Good news:
– Complete
– Guaranteed to find the shallowest path to the goal
This is not necessarily the best path! But we can “fix” the algorithm
to get the best path.
– Different start-goal combinations can be explored at the same time
• Good news:
– Complete
– Guaranteed to find the shallowest path to the goal
This is not necessarily the best path! But we can “fix” the algorithm
to get the best path.
– Different start-goal combinations can be explored at the same time
• Bad news:
– Exponential time complexity: O(bd) (why?)
This is the same for all uninformed search methods
– Exponential memory requirements! O(bd) (why?)
This is not good...
Example
!"
!""#$%&'#()%*#+#'%#,#'%#'-.#/012.#%(#+
Example
34
!"#$%&'(#$)*+$,-#.$#$"&/$0##1$(23&-#3$)+*.$4$-*$56$$!",/$,/$7#1#+&''8$1*-$/(22*+-#3$
08$&$:;<$0(-$-"#+#$&+#$=&8/$-*$)&>#$,-6
Example
!"
Example
!"
Example
!"
:!"#;(&)#+'<)#'+=3)%/+#(5#>1#)*%(5?&7##!'#"3;)#)*%&#%*6#%)#2('<)#2(5?#%"#;(&)#+#
'+=3)%/+ (5#>@##A()+#?++$#%'#B+B(56#+/+56)*%'=#2+</+#&++'7
COMP-424, Lecture 2 - January 9, 2013 42
Example
Example
!"
Example
!"
Example
Example
!"
Example
!"
Example
!"
Example
!"
Analyzing DFS
• Good news:
– Space complexity O(bd) (why?)
– It is easy to implement recursively (do not even need a queue data
structure)
– More efficient than BFS if there are many paths leading to a solution.
!"
• Good news:
– Space complexity O(bd) (why?)
– It is easy to implement recursively (do not even need a queue data
structure)
– More efficient than BFS if there are many paths leading to a solution.
• Bad news:
– Exponential time complexity: O(bd)
This is the same for all uninformed search methods
– Not optimal
– DFS may not complete! (why?)
– NEVER use DFS if you suspect a big tree depth
Depth-Limited Search
#
$
"
&
Informed Search
6 1 88 6
8 84
7 3 22 7 6 25
Example: Eight-Puzzle
Example Heuristics: 8-puzzle
5 4 5
1 4
2 3
6 1 88 6
8 84
7 3 22 7 6 25
6 1 88 6
8 84
7 3 22 7 6 25