Download presentation

Presentation is loading. Please wait.

Published byArianna Loveman Modified over 2 years ago

1
Intelligence Artificial Intelligence Ian Gent ipg@cs.st-and.ac.uk Search: 3

2
Intelligence Artificial Intelligence Part I :Best First Search Part II: Heuristics for 8s Puzzle Part III:A* Search 3

3
3 Search Reminder zSearch states, Search trees zDon’t store whole search trees, just the frontier

4
4 Best First Search zAll the algorithms up to now have been hard wired yI.e. they search the tree in a fixed order yuse heuristics only to choose among a small number of choices xe.g. which letter to set in SAT / whether to be A or a zWould it be a good idea to explore the frontier heuristically? zI.e. use the most promising part of the frontier? zThis is Best First Search

5
5 Best First Search zBest First Search is still an instance of general algorithm zNeed heuristic score for each search state zMERGE: merge new states in sorted order of score yI.e. list always contains most promising state first ycan be efficiently done if use (e.g.) heap for list no, heaps not done for free in Lisp, Prolog. zSearch can be like depth-first, breadth-first, or in- between ylist can become exponentially long

6
6 Search in the Eights Puzzle zThe Eights puzzle is different to (e.g.) SAT ycan have infinitely long branches if we don’t check for loops xbad news for depth-first, xstill ok for iterative deepening yUsually no need to choose variable (e.g. letter in SAT) xthere is only one piece to move (the blank) xwe have a choice of places to move it to ywe might want to minimise length of path xin SAT just want satisfying assignment

7
7 Search in the Eights Puzzle zAre the hard wired methods effective? yBreadth-first very poor except for very easy problems yDepth-first useless without loop checking xnot much good with it, either yDepth-bounded -- how do we choose depth bound? yIterative deepening ok xand we can use increment = 2 (why?) xstill need good heuristics for move choice zWill Best-First be ok?

8
8 Search in the Eights Puzzle zHow can we use Best-First for the Eights puzzle? zWe need good heuristic for rating states zIdeally want to find guaranteed shortest solution yTherefore need to take account of moves so far yAnd some way of guaranteeing no better solution elsewhere

9
9 Manhattan distance heuristic zThere is an easy lower bound on #moves required zJust calculate how far each piece is from its goal yadd up this for each piece ysum is minimum number of moves possible zThis is Manhattan distance ybecause pieces move according to Manhattan geometry zManhattan is not exact yWhy not? zCan use it as heuristic as estimate of distance to solution ymakes sense to explore apparently nearest first

10
10 The Eights Puzzle zInaccuracy of Manhattan yManhattan distance = ? yoptimal solution = 18

11
11 Using Heuristics zTake the Manhattan distance as an example zIn Best first, order all states in list by Manhattan zIn Depth first, order only new states by Manhattan ystill hope to explore most promising first zIn Breadth first, similarly zHeuristics important to all search algorithms yAlmost all problems solved by search solved by good heuristics yExcepting small problems like 8’s puzzle

12
12 Manhattan Distance in 8’s zManhattan distance in 8’s puzzle is NOT a good heuristic zIt can be misled ySuppose we have a small Manhattan distance for move A ybut any solution for move A must reverse move A eventually (e.g. to allow a vital move B) yWe have in reality made the solution 2 moves longer xmoving piece A and then putting it back again yHeuristic thinks we are closer to a solution zInfinite loops can occur in Best First + Manhattan

13
13 Total distance Heuristic zCan use Manhattan as basis of excellent heuristic zThe result will in fact be the A* algorithm ysorry about the name ypronounced “A star” zTotal distance heuristic takes account of moves so far yManhattan distance + moves to reach this position z This must be a lower bound on #moves from start state to goal state via the current state

14
14 A-ghastly name-* zActually the name is just A* zThe Total distance heuristic has a guarantee y1. heuristic score is guaranteed lower bound on true path cost via the current state y2. heuristic score of solution is the true cost of solution zA* = Best First + heuristic with this guarantee zA* guarantees that first solution found is optimal zHelpful because we can stop searching immediately yotherwise must continue to find possible better solutions ye.g. in Depth First for 8s puzzle.

15
15 The A* Guarantee zA* guarantees to find optimal solution zProof: suppose not, and we derive a contradiction yThen there is a solution with higher cost found first xmust be earlier in list than precursor of optimal solution yheuristic cost = true cost (by guarantee 2) ytrue cost of worse solution > true cost of optimal ytrue cost of optimal heuristic cost of precursor (guar. 1) y true cost of worse solution > heuristic cost of precursor y precursor of optimal earlier in list than worse solution yContradiction, w 5 (which was what was wanted)

16
16 Branch and Bound zBnB is not always bed and breakfast zBranch and bound is similarly inspired to A* zUnlike A* may not guarantee optimal solution first zAs in A*, look for a bound which is guaranteed lower than the true cost zSearch the branching tree in any way you like ye.g. depth first (no guarantee), best first zCut off search if cost + bound > best solution found zIf heuristic is cost + bound, search = best first ythen BnB = A*

17
17 BnB example: TSP zConsider the Travelling Salesperson Problem zBranch and Bound might use depth-first search zCost so far is sum of costs of chosen edges zBound might be cost of following minimum spanning tree of remaining nodes MST: tree connected to all nodes of min cost among all such trees yall routes have to visit all remaining nodes ycan’t possibly beat cost of MST zBounds often much more sophisticated ye.g. using mathematical programming optimisations

18
18 Summary and Next Lecture zSummary yBest first tries to explore most promising node first yIn 8s puzzle, Manhattan distance is one heuristic yTotal distance is much better and has guarantees yBest First + Guarantees = A* yBranch and Bound also uses guaranteed bounds zNext Lecture: Heuristics in decision problems yso far looked at heuristics for optimisation ywhat about when just want any old solution, e.g. SAT yLook at heuristics in these situations

Similar presentations

OK

Exact methods for ALB ALB problem can be considered as a shortest path problem The complete graph need not be developed since one can stop as soon as in.

Exact methods for ALB ALB problem can be considered as a shortest path problem The complete graph need not be developed since one can stop as soon as in.

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google

Ppt on drinking water in rural areas Ppt on applied operational research society Ppt on statistics in maths what is the product Hrm ppt on recruitment process Ppt on machine translation Download ppt on the seven ages poem by william shakespeare Ppt on earth hour activities Ppt on software company profiles Ppt on current account deficit united Ppt on 555 timer schematic