Problem-Solving As Search
Problem-Solving As Search
Intelligent Agents
Agent: Anything that can be viewed as perceiving its environment through sensors and acting upon that environment through actuators. Agent Function: Agent behavior is determined by the agent function that maps any given percept sequence to an action. Agent Program: The agent function for an artificial agent will be implemented by an agent program.
Environment
Condition-action rules
Environment
Condition-action rules
Goal-Based Agent
Agent Sensors What the world is like now What it will be like if I do action A
Environment
Goals
Schedule
Search Machine learning Knowledge based systems Discovery
The 8 Puzzle
3 Initial State
6 Goal State
Clicker
What is the size of the state space?
A. 4 B. 3x3 C. 9! D. 99 E. Whatever
Clicker
How many actions possible for each state (on average)?
A. ~1 B. ~4 C. ~9 D. ~9!
Cryptarithmetic
SEND + MORE -----MONEY Find (non-duplicate) substitution of digits for letters such that the resulting sum is arithmetically correct. Each letter must stand for a different digit.
Output:
Path from initial state to goal state. Solution quality is measured by the path cost.
3 Start State
6 Goal State
What would the search tree look like after the start state was expanded?
PARENT-NODE NODE
STATE
2 CHILD-NODE CHILD-NODE
Consider paths of length 1, then of length 2, then of length 3, then of length 4,....
Let b = branching factor, d = solution depth, then the maximum number of nodes generated is: b + b2 + ... + bd + (bd+1-b)
Time .11 sec 11 sec 19 min 31 hrs 129 days 35 yrs 3523 yrs
Memory 1 meg 106 meg 10 gig 1 tera 101 tera 10 peta 1 exa
Uniform-cost Search
Use BFS, but always expand the lowest-cost node on the fringe as measured by path cost g(n). s s
0
A A 1 s 15 C 5 B 5 5 10 A G B 11 A B G C 15 5 C 15 s 1 B 5 C 15 s
Requirement: g(Successor(n))
g(n)
11
10
Always expand lowest cost node in open-list. Goal-test only before expansion, not after generation.
BFS
DFS
YES
Finite depth
YES
NO
O(bd+1)
O(bm)
O(bd+1)
O(bm)
B=BFS
D=DFS
B=BFS
D=DFS
B=BFS
D=DFS
B=BFS
D=DFS
Backtracking Search
Idea: DFS, but dont expand all b states before next level Generate the next state as needed (e.g. from previous state) Uses only O(m) storage Important when space required to store each state is very large (e.g. assembly planning)
Limit=0
Iterative Deepening
Limit=1
Limit=2
Limit=3
b 2 3 5 10
25
100
1.08
1.02
Bidirectional Search
DepthFirst bm bm no No
yes Yes
***Note that many of the ``yes's'' above have caveats, which we discussed when covering each of the algorithms.