CS 4700: Foundations of Artificial Intelligence: Bart Selman Problem Solving by Search R&N: Chapter 3
CS 4700: Foundations of Artificial Intelligence: Bart Selman Problem Solving by Search R&N: Chapter 3
Bart Selman
Problem-solving agents
Problem types
Problem formulation
Example problems
Basic search algorithms
Problem-solving agents
More details on states soon.
Problem solving agents are goal-directed agents:
Find solution:
sequence of cities
leading from start to
goal state, e.g., Arad, Environment: fully observable (map),
Sibiu, Fagaras, deterministic, and the agent knows effects
Bucharest of each action. Is this really the case?
Execution Note: Map is somewhat of a toy example. Our real
drive from Arad to interest: Exponentially large spaces, with e.g. 10^100
Bucharest according to or more states. Far beyond full search. Humans can
the solution
often still handle those!
One of the mysteries of cognition.
Micro-world: The Blocks World
gripper
Start state
Goal
(reach one in
this set of states)
states? The agent is in one of 8 possible world states.
actions? Left, Right, Suck [simplified: left out No-op]
goal test? No dirt at all locations (i.e., in one of bottom two states).
path cost? 1 per action
Minimum path from Start to Goal state: 3 actions
Alternative, longer plan: 4 actions
Note: path with thousands of steps before reaching goal also exist.
Example: The 8-puzzle
sliding tile puzzle
Aside:
variations
on goal state.
eg empty square
bottom right or
in middle.
etc.
4 17 boards farthest away from goal state (80 moves)
1
13
?
<15,12,11>/
<9,10,14>
?
What is
?
it about
these 17
Each require 80 moves to reach:
boards
out of Intriguing similarities. Each number
over 10 has its own few locations.
trillion? Interesting machine learning task:
Learn to recognize the hardest boards!
(Extremal Combinatorics, e.g. LeBras, Gomes, and Selman AAAI-12)
17 boards farthest away from goal state (80 moves)
Thanks to Jonathan GS
A few urls:
Aside: in this
tree, immediate
duplicates are
removed.
Goal
A breadth-first search tree. (More detail soon.)
Really only barely feasible on compute cluster with lots of memory and
compute time. (Raw numbers for 24 puzzle, truly infeasible.)
Can we avoid generating all these boards? Do with much less search?
(Key: bring average branching factor down.)
Gedanken experiment: Assume that you knew for each state, the minimum
number of moves to the final goal state. (Table too big, but assume there is
some formula/algorithm based on the board pattern that gives this number
for each board and quickly.)
d >= 4 Select
d=3 d >= 3
d=2
Select
dSelect
=1
Select
d = 0 d >= 1
Goal
A breadth-first search tree. (More detail soon.)
We may not have the exact distance function (perfect heuristics), but
we can still guide the search using an approximate distance function.
Reinforcement learning:
Learn the state eval function.
Goal
A breadth-first search tree.
Because eval function is often only an estimate of the true state value,
greedy search may not find the optimum path to the goal.
1) Manhattan Distance: For each tile the number of grid units between its
current location and its goal location are counted and the values for all
tiles are summed up. (underestimate; too loose; not very powerful)
Protein design: sequence of amino acids that will fold into the 3-
dimensional protein with the right properties.
Basic idea:
simulated exploration of state space by generating successors of
already-explored states (a.k.a. ~ expanding states)
Added to tree.
Note:
1) Uses explored set to avoid visiting already explored states.
2) Uses frontier set to store states that remain to be explored and expanded.
3) However, with eg uniform cost search, we need to make a special check when
node (i.e. state) is on frontier. Details later.
Implementation: states vs. nodes
A state is a --- representation of --- a physical configuration.
The Expand function creates new nodes, filling in the various fields
and using the SuccessorFn of the problem to create the
corresponding states.
Fringe is the collection of nodes that have been generated but not (yet)
expanded. Each node of the fringe is a leaf node.
Implementation: general tree search
Search strategies
Breadth-first search
Uniform-cost search
Depth-first search
Depth-limited search
Iterative deepening search
Bidirectional search
Key issue: type of queue used for the fringe of the search tree
(collection of tree nodes that have been generated but not yet
expanded)
Breadth-first search
Expand shallowest unexpanded node.
Implementation:
fringe is a FIFO queue, i.e., new
Fringe
nodesqueue:
go at end <A>
(First In First Out queue.)
Select A from
queue and expand.
Gives
<B, C>
Queue: <B, C>
Select B from
front, and expand.
Gives
<C, D, E>
Fringe queue: <C, D, E>
Fringe queue: <D, E, F, G>
Implementation:
fringe = LIFO queue, i.e., put successors at front (push on stack)
Last In First Out
Fringe stack:
A
Expanding A,
gives stack:
B
C
So, B next.
Expanding B,
gives stack:
D
E
C
So, D next.
Expanding D,
gives stack:
H
I
E
C
So, H next.
etc.
Properties of depth-first search
Complete? No: fails in infinite-depth spaces, spaces with loops
Modify to avoid repeated states along path
complete in finite spaces
Time? O(bm): bad if m is much larger than d
but if solutions are dense, may be much faster than breadth-first
Note: Can also
reconstruct soln. path
Space? O(bm), i.e., linear space! from single stored
branch.
b: max. branching factor of the search tree
Guarantee that No d: depth of the shallowest (least-cost) soln.
opt. soln. is found? m: maximum depth of state space
Note: In backtrack search only one successor is generated
only O(m) memory is needed; also successor is modification of
the current state, but we have to be able to undo each modification.
More when we talk about Constraint Satisfaction Problems (CSP).
[here]
Iterative deepening search
Iterative deepening search l =0
Iterative deepening search l =1
Iterative deepening search l =2
Iterative deepening search l =3
Why would one do that?
Anytime nature.
Iterative deepening search
Number of nodes generated in an iterative deepening search to depth
d with branching factor b:
Looks quite wasteful, is it?
NIDS = d b1 + (d-1)b2 + + 3bd-2 +2bd-1 + 1bd
Complete? Yes
(b finite)
Space? O(bd)
Checking a node for membership in the other search tree can be done in constant
time (hash table)
Key limitations:
Space O(bd/2)
Also, how to search backwards can be an issue (e.g., in Chess)? Whats tricky?
Problem: lots of states satisfy the goal; dont know which one is relevant.
Iterative deepening search uses only linear space and not much more time
than other uninformed algorithms.