Upload
camryn-pinnix
View
218
Download
0
Embed Size (px)
Citation preview
Informed Search and Exploration
COSC 159 - Fundamentals of AI
2
Overview Heuristic Search
Best-First Search Approach Greedy A* Heuristic Functions
Local Search and Optimization Hill-climbing Simulated Annealing Local Beam Genetic Algorithms
COSC 159 - Fundamentals of AI
3
Informed Searching An informed search strategy uses
knowledge beyond the definition of the problem
The knowledge is embodied in an evaluation function f(n) Estimates the distance of node n from
the goal
COSC 159 - Fundamentals of AI
4
Best-First Search An instance of tree or graph search Fringe is ordered by f(n) Several best-first algorithms
Greedy, A*, … Key is the heuristic function h(n)
Heuristic measures distance from n to goal based solely on the state at n
Problem specific Constraint: h(n) = 0 if n is a goal node
COSC 159 - Fundamentals of AI
5
Greedy Best-First Search Expands node estimated to be
closest to the goal f(n) = h(n)
Consider the route finding problem. Can we use additional information to
avoid costly paths that lead nowhere? Consider using the straight line
distance (SLD)
COSC 159 - Fundamentals of AI
6
Route Finding
374
253366
329
COSC 159 - Fundamentals of AI
7
Route Finding
Arad f(n) = 366
TimisoaraSibiu Zerind 374329253
Arad Rimnicu VilceaOradeaFagaras366 176 380 193
Bucharest Sibiu0 253
COSC 159 - Fundamentals of AI
8
Exercise
So is Arad->Sibiu->Fagaras->Bucharest optimal?
COSC 159 - Fundamentals of AI
9
Greedy Best-First Search Not optimal. Not complete.
Could go down a path and never return to try another.
Time Complexity O(bm)
Space Complexity O(bm)
COSC 159 - Fundamentals of AI
10
A* Search The greedy best-first search does
not consider how costly it was to get to a node.
Combine g(n), the cost to reach node n, with h(n) f(n) = g(n) + h(n) estimated cost of cheapest solution
through n
COSC 159 - Fundamentals of AI
11
Route Finding
COSC 159 - Fundamentals of AI
12
A* Search
Arad f(n) = 0 + 366
TimisoaraSibiu Zerind 449447393=140+253
Arad Rimnicu VilceaOradeaFagaras646 415 671 413
Things are different
now!
COSC 159 - Fundamentals of AI
13
A* Search Continued
Arad Rimnicu VilceaOradeaFagaras646 415 671 413
591
SibiuBucharest
450
Pitesti SibiuCraiova526 417 553
Craiova615
Rimnicu Vilcea
607
Bucharest
418
COSC 159 - Fundamentals of AI
14
A* Search When used with tree search Optimal
Yes! If h(n) is an admissible heuristic Complete
Yes! Same as above. Time and Space Complexity
Depends on h(n) Subexponential if
where h*(n) is true cost of getting from n to goal Optimally efficient
))((log)()( ** nhOnhnh
COSC 159 - Fundamentals of AI
15
Admissible Heuristics A heuristic function h(n) is admissible if it
never overestimates the cost to reach the goal from n
Is SLD an admissible heuristic? Another property of heuristic functions is
consistency h(n)c(n,a,n’)+h(n’) where c(n,a,n’) is the
cost to get to n’ from n using action a. Graph search is optimal if h(n) is consistent.
Is SLD consistent?
COSC 159 - Fundamentals of AI
16
Heuristic Functions
h1 = number of misplaced tiles h2 = sum of distances of tiles to goal
position.
COSC 159 - Fundamentals of AI
17
Heuristic Functions Is h1
admissible? consistent?
Is h2 admissible? consistent?
COSC 159 - Fundamentals of AI
18
Heuristic Functions Heuristics are often obtained from
relaxed problem Simplify the original problem by
removing constraints The cost of an optimal solution to a
relaxed problem is an admissible heuristic.
COSC 159 - Fundamentals of AI
19
8-Puzzle Original
A tile can move from A to B if A is horizontally or vertically adjacent to B and B is blank.
Relaxations Move from A to B if A is adjacent to B
• h2 by moving each tile in turn to destination Move from A to B if B is blank Move from A to B
• h1 by simply moving each tile directly to destination.
COSC 159 - Fundamentals of AI
20
8-Puzzle What heuristic is obtained from
Move from A to B if B is blank?
Gaschnig’s heuristic (1979)
COSC 159 - Fundamentals of AI
21
More Complicated Monkey and Banana Suppose now that the bananas are hung
from the ceiling and the monkey needs to climb on a box to get the bananas. In addition, walls exist in the environment.
Box, monkey, and bananas placed randomly
Monkey can see the entire world. Actions: N,S,E,W,Grab,Drop,Climb,Eat
COSC 159 - Fundamentals of AI
22
Monkey and Banana Describe the problem as a search
problem. Initial state, successor function, goal,
path cost In what way(s) can we relax the
problem to obtain a heuristic?
COSC 159 - Fundamentals of AI
23
Dominating Heuristics If h2(n) h1(n) for all n, then h2 dominates
h1
h2 is better for use with searching
For the 8-puzzle, h2 does dominate h1
If a tile is out of place, it is at least a distance of 1 away from its correct position. Since h1 counts the number of out of place tiles, and h2 totals all of the distances, h2(n) h1(n) for all n.
COSC 159 - Fundamentals of AI
24
Optimization Problems Idea is to find the best state. We don’t really care how to get to the
best state, just that we get there. The best state is defined according to an
objective function Measures the “fitness” of a state.
Problem: Find the optimal state The one that maximizes (or minimizes) the
objective function.
COSC 159 - Fundamentals of AI
25
State Space LandscapesObjective Function
State Space
shoulder
global max
local max
COSC 159 - Fundamentals of AI
26
State Space Landscapes
COSC 159 - Fundamentals of AI
27
Problem Formulation Complete-state formulation
Start with an approximate solution and perturb
n-queens problem Place n queens on a board so that no
queen is attacking another queen.
COSC 159 - Fundamentals of AI
28
Problem Formulation Initial State: n queens placed
randomly on the board, one per column.
Successor function: States that obtained by moving one queen to a new location in its column.
Heuristic/objective function: The number of pairs of attacking queens.
COSC 159 - Fundamentals of AI
29
n-Queens
5
5
4
3
2
3
4
5
2
4
3
4
3
3
2 3
5
4
2
3
1
4
2
2
COSC 159 - Fundamentals of AI
30
Phasor Measurement Unit Problem formulation?
COSC 159 - Fundamentals of AI
31
Local Search Algorithms Hill climbing Simulated annealing Local beam search Genetic Algorithms
COSC 159 - Fundamentals of AI
32
Hill Climbing (or Descent)Objective Function
State Space
COSC 159 - Fundamentals of AI
33
Hill Climbing Pseudo-code
COSC 159 - Fundamentals of AI
34
Hill Climbing ProblemsObjective Function
State Space
COSC 159 - Fundamentals of AI
35
Other Problematic Spaces
http://www.cs.qub.ac.uk/~M.Sullivan/ga/optimization_pictures.html
COSC 159 - Fundamentals of AI
36
n-Queens
5
5
4
3
2
3
4
5
2
4
3
4
3
3
2 3
5
4
2
3
1
4
2
2
What happens if we move 3rd queen?
COSC 159 - Fundamentals of AI
37
Possible Improvements Stochastic hill climbing
Choose at random from uphill moves Probability of move could be influenced by steepness
First-choice hill climbing Generate successors at random until one is better than
current. Random-restart
Execute hill climbing several times, choose best result. If p is probability of a search succeeding, then expected
number of restarts is 1/p.
COSC 159 - Fundamentals of AI
38
Simulated Annealing Similar to stochastic hill climbing
Moves are selected at random If a move is an improvement, accept Otherwise, accept with probability less
than 1. Probability gets smaller as time
passes and by the amount of “badness” of the move.
COSC 159 - Fundamentals of AI
39
Simulated Annealing Algorithm
Success
COSC 159 - Fundamentals of AI
40
Traveling Salesperson Problem (TSP) Tour of cities Visit each one exactly once Minimize distance/cost/etc.
COSC 159 - Fundamentals of AI
41
TSP State: Permutation of cities Successors: Any permutation
reached by swapping two cities Could be others.
Objective function: Total distance/cost/etc.
COSC 159 - Fundamentals of AI
42
TSP By Simulated Annealing Key is identifying proper schedule
Requires experimentation One possible schedule
Start T at some value k After 1000*N successes, let T=.90*T,
where N is the number of cities.
COSC 159 - Fundamentals of AI
43
Local Beam Search Keep k states in memory instead of
just one Generate successors of all k states If one is a goal, return the goal Otherwise, take k best successors
and repeat.
COSC 159 - Fundamentals of AI
44
Local Beam Search
Concentrates on promising paths
COSC 159 - Fundamentals of AI
45
Local Beam Search Initial k states may not be diverse
enough Could have clustered around a local
max. Improvement is stochastic beam
search Choose k states at random, with
probability of choice an increasing function of its value.
COSC 159 - Fundamentals of AI
46
Genetic Algorithms Variant of stochastic beam search Successor states are generated by
combining two parent states Hopefully improves diversity
Start with k states, the population Each state, or individual, represented as a
string over a finite alphabet (e.g. DNA) Each state is rated by a fitness function Select parents for reproduction using the
fitness function
COSC 159 - Fundamentals of AI
47
Genetic Algorithms
Taken from http://www.cs.qub.ac.uk/~M.Sullivan/ga/ga_index.html
COSC 159 - Fundamentals of AI
48
A Genetic Algorithm
COSC 159 - Fundamentals of AI
49
Genetic Algorithm for PMU Each state is represented as a
binary string 1 in location n represents PMU on node
n Fitness function
(nodes+edges observed)/# of PMUs
COSC 159 - Fundamentals of AI
50
Just Some Chess Pieces