Presentation is loading. Please wait.

Presentation is loading. Please wait.

Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1.

Similar presentations


Presentation on theme: "Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1."— Presentation transcript:

1 Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1

2 Outline Best-first searchBest-first search Greedy best-first searchGreedy best-first search A * searchA * search HeuristicsHeuristics Local search algorithmsLocal search algorithms Hill-climbing searchHill-climbing search Simulated annealing searchSimulated annealing search Local beam searchLocal beam search Genetic algorithmsGenetic algorithms

3 Informed Search Idea: use problem specific knowledge to pick which node to expand Typically involves a heuristic function h(n) estimating the cheapest path from Typically involves a heuristic function h(n) estimating the cheapest path from n.STATE to a goal state A search strategy is defined by picking the order of node expansion 3

4 Best-first search We can use it to direct our search towards the goal.We can use it to direct our search towards the goal. Best first search simply chooses the unvisited node with the best heuristic value to visit next. Best first search simply chooses the unvisited node with the best heuristic value to visit next. It can be implemented in the same algorithm as lowest-cost Breadth First Search. It can be implemented in the same algorithm as lowest-cost Breadth First Search. Idea: use an evaluation function f(n) for each nodeIdea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:Implementation: Order the nodes in fringe in decreasing order of desirability Special cases: –greedy best-first search –A * search 4

5 Romania with step costs in km

6 Greedy best-first search Evaluation function f(n) = h(n) (heuristic)Evaluation function f(n) = h(n) (heuristic) = estimate of cost from n to goal e.g., h SLD (n) = straight-line distance from n to Buchareste.g., h SLD (n) = straight-line distance from n to Bucharest Greedy best-first search expands the node that appears to be closest to goalGreedy best-first search expands the node that appears to be closest to goal

7 Greedy best-first search example

8

9

10

11 Properties of greedy best-first search Complete? No – can get stuck in loops, e.g., Iasi  Neamt  Iasi  Neamt Complete? No – can get stuck in loops, e.g., Iasi  Neamt  Iasi  Neamt  Time? O(b m ), but a good heuristic can give dramatic improvementTime? O(b m ), but a good heuristic can give dramatic improvement Space? O(b m ) -- keeps all nodes in memory Optimal? NoSpace? O(b m ) -- keeps all nodes in memory Optimal? No

12 A * search Idea: avoid expanding paths that are already expensiveIdea: avoid expanding paths that are already expensive Evaluation function f(n) = g(n) + h(n)Evaluation function f(n) = g(n) + h(n) g(n) = cost so far to reach ng(n) = cost so far to reach n h(n) = estimated cost from n to goalh(n) = estimated cost from n to goal f(n) = estimated total cost of path through n to goalf(n) = estimated total cost of path through n to goal

13 A * search example

14

15

16

17

18

19 Admissible heuristics A heuristic h(n) is admissible if for every node n,A heuristic h(n) is admissible if for every node n, h(n) ≤ h * (n), where h * (n) is the true cost to reach the goal state from n. An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimisticAn admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic Example: h SLD (n) (never overestimates the actual road distance)Example: h SLD (n) (never overestimates the actual road distance) Theorem: If h(n) is admissible, A * using TREE- SEARCH is optimalTheorem: If h(n) is admissible, A * using TREE- SEARCH is optimal

20 Properties of A* Complete? Yes (unless there are infinitely many nodes with f ≤ f(G) )Complete? Yes (unless there are infinitely many nodes with f ≤ f(G) ) Time? ExponentialTime? Exponential Space? Keeps all nodes in memorySpace? Keeps all nodes in memory Optimal? YesOptimal? Yes

21 Local search algorithms In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solutionIn many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution State space = set of "complete" configurationsState space = set of "complete" configurations Find configuration satisfying constraints, e.g., n- queensFind configuration satisfying constraints, e.g., n- queens In such cases, we can use local search algorithmsIn such cases, we can use local search algorithms keep a single "current" state, try to improve it.keep a single "current" state, try to improve it. Very memory efficient (only remember current state)Very memory efficient (only remember current state)

22 Hill-climbing search “ a loop that continuously moves in the direction of increasing value”“ a loop that continuously moves in the direction of increasing value” –terminates when a peak is reached Value can be eitherValue can be either –Objective function value –Heuristic function value (minimized) Hill climbing does not look ahead of the immediate neighbors of the current state.Hill climbing does not look ahead of the immediate neighbors of the current state. Can randomly choose among the set of best successors, if multiple have the best value.Can randomly choose among the set of best successors, if multiple have the best value. Characterized as “trying to find the top of Mount Everest while in a thick fog”Characterized as “trying to find the top of Mount Everest while in a thick fog” 22

23 Example: n-queens Put n queens on an n × n board with no two queens on the same row, column, or diagonalPut n queens on an n × n board with no two queens on the same row, column, or diagonal 23

24 Hill-climbing search

25 Hill climbing and local maxima When local maxima exist, hill climbing is suboptimalWhen local maxima exist, hill climbing is suboptimal Local maxima: a local maximum, as opposed to a global maximum, is a peak that is lower than the highest peak in the state space.Local maxima: a local maximum, as opposed to a global maximum, is a peak that is lower than the highest peak in the state space. Once on a local maximum, the algorithm will halt Once on a local maximum, the algorithm will halt even though the solution may be far from satisfactory.even though the solution may be far from satisfactory. Simple (often effective) solutionSimple (often effective) solution –Multiple random restarts 25

26 Hill-climbing search: 8-queens problem A local minimum with h = 1

27 Simulated annealing search Idea: escape local maxima by allowing some "bad" moves but gradually decrease their frequencyIdea: escape local maxima by allowing some "bad" moves but gradually decrease their frequency

28 Properties of simulated annealing search One can prove: If T decreases slowly enough, then simulated annealing search will find a global optimum with probability approaching 1One can prove: If T decreases slowly enough, then simulated annealing search will find a global optimum with probability approaching 1 Widely used in VLSI layout, airline scheduling, etcWidely used in VLSI layout, airline scheduling, etc

29 Local beam search Keep track of k states rather than just oneKeep track of k states rather than just one Start with k randomly generated statesStart with k randomly generated states At each iteration, all the successors of all k states are generatedAt each iteration, all the successors of all k states are generated If any one is a goal state, stop; else select the k best successors from the complete list and repeat.If any one is a goal state, stop; else select the k best successors from the complete list and repeat.

30 Genetic algorithms A successor state is generated by combining two parent statesA successor state is generated by combining two parent states Start with k randomly generated states (population)Start with k randomly generated states (population) A state is represented as a string over a finite alphabet (often a string of 0s and 1s)A state is represented as a string over a finite alphabet (often a string of 0s and 1s) Evaluation function (fitness function). Higher values for better states.Evaluation function (fitness function). Higher values for better states. Produce the next generation of states by selection, crossover, and mutationProduce the next generation of states by selection, crossover, and mutation

31 Genetic algorithms Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28)Fitness function: number of non-attacking pairs of queens (min = 0, max = 8 × 7/2 = 28) 24/(24+23+20+11) = 31%24/(24+23+20+11) = 31% 23/(24+23+20+11) = 29% etc23/(24+23+20+11) = 29% etc

32 Genetic algorithms


Download ppt "Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1."

Similar presentations


Ads by Google