Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS Fall 2016 (Shavlik©), Lecture 10, Week 6

Similar presentations


Presentation on theme: "CS Fall 2016 (Shavlik©), Lecture 10, Week 6"— Presentation transcript:

1 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
1/2/2019 Today’s Topics Read Chapter 13, Sections , Subsection , and Section of Text HW2 can be turned in by 10/20/16 WITH NO LATE DAYS What if Arcs have Costs? Finding least-cost solutions (eg, GPS, Google Maps) Uniform-cost search, A* search Heuristic functions Search Wrapup (except genetic and games) 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

2 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
What if Arcs Have Costs? Might want CHEAPEST solutions and be willing to spend more cpu cycles We’ll put (non-negative) costs on arcs If costs negative, infinite loops would be great! S 2 10 B G 5 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

3 Uniform Cost Search (UC)
Sort OPEN by g(node), which is the cost from a/the startNode to node by the path taken to reach node Need to store ‘parent pointers’ in nodes (so can ‘back trace’ to startNode) Sometimes we will need to change these pointers if a CHEAPER path to node found 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

4 Addition to Our Generic Search Code
If a child of X is ALREADY IN OPEN OR CLOSED, see if current path is better If so, remove old item from OPEN/CLOSED and insert new item in OPEN Otherwise discard child In some cases non-optimal paths will never reach CLOSED, but safer to always check 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

5 New and Improved, Now with Arc Costs - assume LOWER scores are better
5 Start score = 9 1 6 B score = 11 C score = 8 7 8 D score = 4 9 2 Goal score = 0 E score = 3 4 Step# OPEN CLOSED X CHILDREN RemainingCHILDREN (this part done on blackboard for UNIFORM and, later, A*) 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

6 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
UC - not shown, but you should use a SUPERSCRIPT to show parent Step# OPEN CLOSED X CHILDREN RemCHILDREN { S0 } { } S { S5, B1, C6 } { B1, C6 } { B1, C6 } { S0 } B { D8 } { D8 } { C6, D8 } { S0, B1 } C { G15 } { G15 } { D8, G15 } { S0, B1, C6} D { E10, C16 } { E10 } { E10, G15 } { S0, B1, C6, D8} E { G14 } { G14 } { G14 } { S0, B1, C6, D8, E10} G DONE A* - subscript is g+h Step# OPEN CLOSED X CHILDREN RemCHILDREN { S0+9 } { } S { S5+9, B1+11, C6+8} { B1+11, C6+8 } { B1+11, C6+8} { S0+9 } B { D8+4 } { D8+4 } { D8+4, C6+8 } { S0+9, B1+11 } D { E10+3, C16+8 } { E10+3 } { E10+3, C6+8 } {S0+9, B1+11 , D8+4 } E { G14+0 } { G14 } { C6+8 , G14+0 } {… E10+3} C { G15+0 } { } { G14+0 } {… E10+3, C6+8 } G DONE 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

7 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Theorem Uniform-cost search will produce a lowest-cost solution PROOF (by contradiction) Assume we have found solution path S that costs C If cheaper soln exists, the beginning of it would be in OPEN (because we keep ALL partial solns) Since all arc costs are non-negative, this partial soln would cost less than C (total costs never get smaller) But by construction, we POP OPEN and lowest-cost always at front Hence cannot have something some thing still in OPEN that will cost less than C 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

8 UC Doesn’t Use Domain K (K = knowledge)
Under certain conditions (later), sorting by this will get a shortest path f(node) = g(node) + h(node) while possibly ‘expanding’ many fewer nodes h(node) is our heuristic estimate of ‘distance’ to goal S n G g(n) h(n) 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

9 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Practice with f(n) Go back to Slide 5 and use f(n) An example where using h(n) greatly helps h=94 S A D F E C B G Z 1 70 90 4 h=89 . . . 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

10 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Graph Where One Needs to Remove Item from CLOSED (also shows why we check for GOAL when REMOVING from OPEN, rather than when ADDING) S h=3 B h=20 C h=1 5 2 G h=0 99 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

11 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Step# OPEN CLOSED X CHILDREN RemCHILDREN { S0+3 } { } S { B2+20, C5+1 } { B2+20, C5+1 } { C5+1, B2+20 } { S0+3 } C { G104+0 } { G104+0 } { B2+20, G104+0 } { S0+9, C5+1 } B { C4+1 } { C4+1 } { C4+1, G104+0 } { S0+9, C5+1, B2+20 } C { G } { G } { G103+0 , G104+0 } { S0+9, C4+1, B2+20 } G DONE S h=3 B h=20 C h=1 5 2 G h=0 99 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

12 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Admissibility Defn: if a search algo always produces shortest paths (assuming one exists), then the algo is called admissible If h(n) never over estimates the actual distance to a goal, then using f(n)=g(n)+h(n) will lead to best-first search being admissible (and we also call h(n) admissible) BEST with an admissible h(n) is called A* (pronounced “A star” – some AI humor!) Note that A* can have large OPEN and CLOSED since all promising partial paths kept 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

13 What Happens if h(n) Overestimates?
Best solution might get pushed deep into OPEN and never checked S h=3 B h=999 C h=1 5 2 G h=0 99 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

14 What Happens if h(n) Underestimates?
Might waste time on a non-optimal path S h=3 B h=1 C h=1 5 2 1 G h=0 99 . . . D h=1 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

15 Creating Good h Functions
Mainly a task-specific ‘art’ h(n) should be a fast algorithm (would not be good if h(n) implemented DFS!) Often ‘simplifying assumptions’ or ‘relaxations’ of the task create good h’s Note that user focuses on creating h using domain K and A* ‘works out the details’ 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

16 So the better h(n) is, the faster A* runs
Some Properties of A* “Informedness” If h1(n) and h2(n) are both admissible, and n h1(n)  h2(n) then the nodes A* expands using h1(n) are a subset of those it expands using h2(n) Visually h True distance error h1 h2 So the better h(n) is, the faster A* runs 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

17 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Some Properties of A* “Robustness” If h ‘rarely’ overestimates by more than , then A* will rarely find a sol’n whose cost is  more than optimal “Completeness” A* will terminate with a optimal soln even in infinite space, provided a soln exists and all arc costs are greater than some positive number  10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

18 THINK Before You Search!
Naïve Algo ACTIONS: Fill ‘top-left most’ empty cell with legal moves in {1, 2, …, 9 } LARGE search tree! Smarter Algo (usually NEVER need to search!) Mark each empty cell with candidates that do not violate game’s rules, eg, top cell in this image can be filled with {3, 5, 8, or 9} IF NO cells with only one possible filler Let k be the smaller set of fillers, pick ‘top-left most’ cell with k fillers and put the k next board states in OPEN ELSE for all those cells with only ONE possible filler, choose that filler If game solved EXIT else update “possible fillers’” for all empty cells and go to 2 Only 2 legal here 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6

19 CS 540 - Fall 2016 (Shavlik©), Lecture 10, Week 6
Search Wrap Up Lots of Variations and Tradeoffs We’ve Explored a Wide Range but Not All Powerful, General-Purpose, Problem-Solving Method Watch for places it can be employed Especially when cpu cycles abundant OPEN a Key Data Structure CLOSED prevents repeated work Our General Search Algo Inefficient for Some Methods, but Provides a Unifying View Needs modification for some methods to work correctly Heuristic Functions a Good Way to Use Domain K in Intuitive Way Next: Search with an Adversary (Game Playing) Then: Genetic Search (based on Evolution) 10/11/16 CS Fall 2016 (Shavlik©), Lecture 10, Week 6


Download ppt "CS Fall 2016 (Shavlik©), Lecture 10, Week 6"

Similar presentations


Ads by Google