CS 416 Artificial Intelligence Lecture 6 Informed Searches

advertisement
CS 416
Artificial Intelligence
Lecture 6
Informed Searches
Local Search Algorithms and
Optimization Problems
Characterize Techniques
Uninformed Search
• Looking for a solution where solution is a path from start to
goal
• At each intermediate point along a path, we have no
prediction of value of path
Informed Search
• Again, looking for a path from start to goal
• This time we have insight regarding the value of intermediate
solutions
Now change things a bit
What if the path isn’t important, just the goal?
• So the goal is unknown
• The path to the goal need not be solved
Examples
• What quantities of quarters, nickels, and dimes add up to
$17.45 and minimizes the total number of coins
• Is the price of Microsoft stock going up tomorrow?
Local Search
Local search does not keep track of previous
solutions
• Instead it keeps track of current solution (current state)
• Uses a method of generating alternative solution candidates
Advantages
• Use a small amount of memory (usually constant amount)
• They can find reasonable (note we aren’t saying optimal)
solutions in infinite search spaces
Optimization Problems
Objective Function
• A function with vector inputs and scalar output
– goal is to search through candidate input vectors in order
to minimize or maximize objective function
Example
• f (q, d, n) = 1,000,000 if q*0.25 + d*0.1 + n*0.05 != 17.45
= q + n + d otherwise
• minimize f
Search Space
The realm of feasible input vectors
• Also called state-space landscape
• Usually described by
– number of dimensions (3 for our change example)
– domain of each dimension (#quarters is discrete from 0 to 69…)
– nature of relationship between input vector and objective function
output
 no relationship
 smoothly varying
 discontinuities
Search Space
Looking for global
maximum (or minimum)
Hill Climbing
Also called Greedy Search
• Select a starting point and set current
• evaluate (current)
• loop do
– neighbor = highest value successor of
current
– if evaluate (neighbor) <= evaluate (current)
 return current
– else current = neighbor
Hill climbing gets stuck
Hiking metaphor (you are wearing glasses that
limit your vision to 10 feet)
• Local maxima
– Ridges (in cases when you can’t walk along the ridge)
• Plateau
– why is this a problem?
Hill Climbing Gadgets
Variants on hill climbing play special roles
• stochastic hill climbing
– don’t always choose the best successor
• first-choice hill climbing
– pick the first good successor you find
 useful if number of successors is large
• random restart
– follow steepest ascent from multiple starting states
– probability of finding global max increases with number of starts
Hill Climbing Usefulness
It Depends
• Shape of state space greatly influences hill climbing
• local maxima are the Achilles heel
• what is cost of evaluation?
• what is cost of finding a random starting location?
Simulated Annealing
A term borrowed from metalworking
• We want metal molecules to find a stable location relative to
neighbors
• heating causes metal molecules to jump around and to take on
undesirable (high energy) locations
• during cooling, molecules reduce their movement and settle
into a more stable (low energy) position
• annealing is process of heating metal and letting it cool slowly
to lock in the stable locations of the molecules
Simulated Annealing
“Be the Ball”
• You have a wrinkled sheet of metal
• Place a BB on the sheet and what happens?
– BB rolls downhill
– BB stops at bottom of hill (local or global min?)
– BB momentum may carry it out of hill into another (local or global)
• By shaking metal sheet, your are adding energy (heat)
• How hard do you shake?
Our Simulated Annealing Algorithm
“You’re not being the ball, Danny” (Caddy Shack)
• Gravity is great because it tells the ball which way is downhill
at all times
• We don’t have gravity, so how do we find a successor state?
– Randomness
 AKA Monte Carlo
 AKA Stochastic
Algorithm Outline
Select some initial guess of evaluation function parameters:
Evaluate evaluation function,
Compute a random displacement,
• The Monte Carlo event
Evaluate
• If v’ < v; set new state,
• Else set
with Prob(E,T)
– This is the Metropolis step
Repeat with updated state and temp
Metropolis Step
We approximate nature’s alignment of molecules by allowing
uphill transitions with some probability
•
Prob (in energy state E) ~
– Boltzmann Probability Distribution
– Even when T is small, there is still a chance in high energy state
•
Prob (transferring from E1 to E2) =
– Metropolis Step
– if E2 < E1, prob () is greater than 1
– if E2 > E1, we may transfer to higher energy state
The rate at which T is decreased and the amount
it is decreased is prescribed by an annealing schedule
What have we got?
Always move downhill if possible
Sometimes go uphill
• More likely at start when T is high
Optimality guaranteed with slow annealing schedule
No need for smooth search space
• We do not need to know what nearby successor is
Can be discrete search space
• Traveling salesman problem
More info: Numerical Recipes in C (online)
Chapter 10.9
Local Beam Search
Keep more previous states in memory
• Simulated Annealing just kept one previous state in memory
• This search keeps k states in memory
Generate k initial states
if any state is a goal, terminate
else, generate all successors and select best k
repeat
Isn’t this steepest ascent in parallel?
Information is shared between k search points
• Each k state generates successors
• Best k successors are selected
• Some search points may contribute none to best successors
• One search point may contribute all k successors
– “Come over here, the grass is greener” (Russell and Norvig)
• If executed in parallel, no search points would be terminated
like this
Beam Search
Premature termination of search paths?
• Stochastic beam search
– Instead of choosing best K successors
– Choose k successors at random
Download