2nd
2nd
SEARCH
Search
SimpleProblemSolvingAgent(percept)
state = UpdateState(state, percept)
if sequence is empty then
goal = FormulateGoal(state)
problem = FormulateProblem(state, g)
sequence = Search(problem)
action = First(sequence)
sequence = Rest(sequence)
Return action
Assumptions
Static or dynamic?
Environment is static
Assumptions
Static or dynamic?
Fully or partially observable?
Static or dynamic?
Fully or partially observable?
Discrete or continuous?
Environment is discrete
Assumptions
Static or dynamic?
Fully or partially observable?
Discrete or continuous?
Deterministic or stochastic?
Environment is deterministic
Assumptions
Static or dynamic?
Fully or partially observable?
Discrete or continuous?
Deterministic or stochastic?
Episodic or sequential?
Environment is sequential
Assumptions
Static or dynamic?
Fully or partially observable?
Discrete or continuous?
Deterministic or stochastic?
Episodic or sequential?
Single agent or multiple agent?
Assumptions
Static or dynamic?
Fully or partially observable?
Discrete or continuous?
Deterministic or stochastic?
Episodic or sequential?
Single agent or multiple agent?
Search Example
Formulate goal: Be in
Bucharest.
Graph coloring
Protein folding
Game playing
Airline travel
Proving algebraic equalities
Robot motion planning
Visualize Search Space as a Tree
LIFO
Priority Queue
b=2
Analysis
1,000 bytes/node
Time complexity
In the worst case, search entire space
Goal may be at level d but tree may continue to level m, m>=d
O(bm)
Particularly bad if tree is infinitely deep
Space complexity
Only need to save one set of children at each level
1 + b + b + … + b (m levels total) = O(bm)
For previous example, DFS requires 118kb instead of 10 petabytes for d=12 (10 billion
times less)
Benefits
May not always find solution
Solution is not necessarily shortest or least cost
If many solutions, may find one quickly (quickly moves to depth d)
Simple to implement
Space often bigger constraint, so more usable than BFS for large problems
Analysis
Comparison of Search Techniques
DFS BFS
Complete N Y
Optimal N N
Heuristic N N
Time bm bd+1
Space bm bd+1
Avoiding Repeated States
Can we do it?
Do not return to parent or grandparent state
In 8 puzzle, do not move up right after down
QueueingFn is SortByCostSoFar
Cost from root to current node n is g(n)
Add operator costs along path
Open list: C
UCS Example
Open list: S(5) N(5) R(6) Z(6) F(6) D(8) G(10) L(10)
UCS Example
O(bd)
Analysis
Repeated work is approximately 1/b of total work
Negligible
N(BFS) = 1,111,100
N(IDS) = 123,450
Features
Shortest solution, not necessarily least cost
QueueingFunction is sort-by-h
Best-first search only as good as heuristic
Example heuristic for 8 puzzle: Manhattan
Distance
Example
Example
Example
Example
Example
Example
Example
Example
Example
Comparison of Search Techniques
QueueingFunction is sort-by-h
Only keep lowest-h state on open list
Best-first search is tentative
Hill climbing is irrevocable
Features
Much faster
Less memory
Dependent upon h(n)
If bad h(n), may prune away all goals
Not complete
Example
Example
Hill Climbing Issues
Also referred to as gradient descent
Foothill problem / local maxima / local minima
Can be solved with random walk or more steps
Other problems: ridges, plateaus
global
maxima
values
local
maxima
states
Comparison of Search Techniques
QueueingFunction is sort-by-h
Only keep best (lowest-h) n nodes on open list
Example
h1(x): | xgoal x |
h2(x): Euclidean distance ( xgoal x) 2 ( ygoal y) 2
h2 dominates h1
Effect on Search Cost
Hill climbing
Simulated annealing
Genetic algorithms
Iterative Improvement Algorithms
Constant memory
Example
Traveling salesman
N-queens
Ridges
Shoulder
Local Maxima
Plateau
global Maxima
Recombination
Representation
Chromosome = string
Reproduction (Selection)
Crossover
Mutation
Reproduction
11111 11000
00000 00111
Mutation
Population: Goal: 0 1 1 1 1 1
Solution = 0 0 1 0 1 0
Fitness(x) = #digits that match solution
A) 0 1 0 1 0 1 Score: 1
B) 1 1 1 1 0 1 Score: 1
C) 0 1 1 0 1 1 Score: 3
D) 1 0 1 1 0 0 Score: 3
E) 0 | 0 1 1 0 0 Score: 4 H) 0 1 1 | 1 0 0 Score: 3
F) 1 | 1 1 0 1 1 Score: 3 I) 0 0 1 | 0 1 0 Score: 6
G) 0 1 1 0 1 | 0 Score: 4 J) 0 0 | 1 0 1 0 Score: 6
H) 1 0 1 1 0 | 1 Score: 2 K) 0 1 | 1 1 0 0 Score: 3