Lecture 2 AI
Lecture 2 AI
Solving Problems by
Searching
AI
Well-defined problems and solutions
A problem is defined by 5 components:
Initial state
Actions
Transition model or
(Successor functions)
Goal Test.
Path Cost.
Well-defined problems and solutions
A problem is defined by 4 components:
The initial state
that the agent starts in
The set of possible actions
Transition model: description of what each action
does.
(successor functions): refer to any state reachable from
given state by a single action
Initial state, actions and Transition model define the
state space
the set of all states reachable from the initial state by any
sequence of actions.
A path in the state space:
any sequence of states connected by a sequence of actions.
The 8-puzzle
The 8-puzzle
States:
a state description specifies the location of each of
the eight tiles and blank in one of the nine squares
Initial State:
Any state in state space
Successor function:
the blank moves Left, Right, Up, or Down
Goal test:
current state matches the goal configuration
Path cost:
each step costs 1, so the path cost is just the length
of the path
Searching For Solutions
Tree search example
Node selected
for expansion.
Nodes added to tree.
Selected for expansion.
Added to tree.
Breadth-first search
Depth-first search
Depth-limited search
Iterative deepening search
Uniform-cost search
10
Comparing Uninformed Search
Strategies
Completeness
Will a solution always be found if one exists?
Time
How long does it take to find the solution?
Often represented as the number of nodes searched
Space
How much memory is needed to perform the search?
Often represented as the maximum number of nodes stored
at once
Optimal
Will the optimal (least cost) solution be found?
11
Comparing Uninformed Search
Strategies
Time and space complexity are
measured in
b – maximum branching factor of the
search tree
d – depth of the least cost solution
d e p
b c e h r q
a a h r p q f
p q f q c G
q c G a
a
Iterative Deepening Search
Complete
Yes
Time
O(bd)
Space
O(bd)
Optimal
Yes if step cost = 1
Can be modified to explore uniform cost tree
Uniform cost search
Breadth-first finds the shallowest goal state
but not necessarily be the least-cost solution
work only if all step costs are equal
S 0
d 3 e 9 p 1
b 4c e 5 h 1r 1 q 1
1 7 1 6
Cost a 6 a 1h 1 r 7 p q f
contou 3
rs p q f 8 q c G
q 1c G 1 a
1 0
a
End …