chapter04_4e (3)
chapter04_4e (3)
Approach
Fourth Edition
Chapter 4
Search in Complex
Environments
1
Copyright © 2021 Pearson Education, Inc. All Rights Reserved
Outline
♦ Local Search and Optimization Problems
♦ Hill-climbing
♦ Simulated annealing
♦ Genetic algorithms
♦ Local search in continuous spaces
♦ Search with Nondeterministic Actions
♦ Search in Partially Observable Environments
Chapter 4, Sections 2
3–4
© 2021 Pearson Education Ltd.
Local Search and Optimization Problems
They are not systematic—they might never explore a portion of the search
space where a solution actually resides.
Chapter 4, Sections 4
3–4
© 2021 Pearson Education Ltd.
Example: n-queens
Put n queens on an n × n board with no two queens on the
same row, column, or diagonal
Move a queen to reduce number of conflicts
Chapter 4, Sections 5
3–4
© 2021 Pearson Education Ltd.
Hill-climbing (or gradient ascent/descent)
“Like climbing Everest in thick fog with amnesia”
Chapter 4, Sections 6
3–4
© 2021 Pearson Education Ltd.
Hill-climbing contd.
Useful to consider state space
landscape
objective function global maximum
shoulder
local maximum
"flat" local maximum
state space
current
state
Chapter 4, Sections 7
3–4
© 2021 Pearson Education Ltd.
Simulated annealing
Idea: escape local maxima by allowing some “bad” moves
but gradually decrease their size and frequency
Chapter 4, Sections 9
3–4
© 2021 Pearson Education Ltd.
Local beam search
Idea: keep k states instead of 1; choose top k of all their
successors
Not the same as k searches run in parallel!
Searches that find good states recruit other searches to join them
Problem: quite often, all k states end up on same local hill
Idea: choose k successors randomly, biased towards good ones
Observe the close analogy to natural selection!
Chapter 4, Sections 10
3–4
© 2021 Pearson Education Ltd.
Genetic algorithms
= stochastic local beam search + generate successors from pairs of
states
24748552 24 31% 32752411 32748552 32748152
32752411 23 29% 24748552 24752411 24752411
Chapter 4, Sections 11
3–4
© 2021 Pearson Education Ltd.
Genetic algorithms contd.
GAs require states encoded as strings (GPs use programs)
Crossover helps iff substrings are meaningful
components
+ =
Chapter 4, Sections 12
3–4
© 2021 Pearson Education Ltd.
Continuous state spaces
Suppose we want to site three airports in Romania:
– 6-D state space defined by (x1 , y2 ), (x2 , y2 ), (x3 , y3 )
– objective function f (x1, y2, x2, y2, x3, y3) =
sum of squared distances from each city to nearest airport
Discretization methods turn continuous space into discrete space,
e.g., empirical gradient considers ±δ change in each coordinate
Gradient methods compute
∂f ∂f ∂f ∂f ∂f ∂f
∇f =
, , , ,
∂x1 , ∂y1 ∂x 2 ∂y2 ∂x 3 3
∂y
to increase/reduce f , e.g., by x ← x + α∇f (x)
Sometimes can solve for ∇f (x) = 0 exactly (e.g., with one city).
Newton–Raphson (1664, 1690) iterates x ← x − H−f 1 (x)∇f
(x) to solve ∇f (x) = 0, where H i j = ∂ 2 f /∂xi ∂xj
Chapter 4, Sections 13
3–4
© 2021 Pearson Education Ltd.
Search with Nondeterministic Actions
Agent doesn’t know the state its transitioned to after action, the
environment is nondeterministic.
Rather, it will know the possible states it will be in, which is called
“belief state”
Examples:
• The erratic vacuum world (if-then-else) steps. If statement tests
to know the current state.
• AND-OR search trees. Two possible actions (OR nodes).
Branching that happens from a choice (AND nodes).
• Try, try again. A cyclic plan where minimum condition (every leaf
= goal state & reachable from other points in the plan)
Chapter 4, Sections 14
3–4
© 2021 Pearson Education Ltd.
Search in Partially Observable Environments
Problem of partial observability, where the agent’s percepts are not
enough to pin down the exact state.
Chapter 4, Sections 15
3–4
© 2021 Pearson Education Ltd.
Summary
Local search methods keep only a small number of states in
memory that are useful for optimization.
Chapter 4, Sections 16
3–4
© 2021 Pearson Education Ltd.