1 / 36

בעיות חיפוש – informed search

בעיות חיפוש – informed search. בינה מלאכותית יעל נצר. תזכורת. חיפוש כדרך לפתרון בעיות: מצב התחלתי מטרה או מצבי פתרון פעולות אפשריות שיטות חיפוש : עיוורות uninformed – כלומר אין קשר בין אופן החיפוש לבין המידע עצמו. חיפוש לרוחב חיפוש לעומק חיפוש מיודע informed – שימוש בהיוריסטיקות

baba
Télécharger la présentation

בעיות חיפוש – informed search

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. בעיות חיפוש – informed search בינה מלאכותית יעל נצר

  2. תזכורת • חיפוש כדרך לפתרון בעיות: • מצב התחלתי • מטרה או מצבי פתרון • פעולות אפשריות • שיטות חיפוש: • עיוורות uninformed– כלומר אין קשר בין אופן החיפוש לבין המידע עצמו. • חיפוש לרוחב • חיפוש לעומק • חיפוש מיודע informed – שימוש בהיוריסטיקות • מרחב החיפוש: • מצב חיפוש • אופרטור • מצבים חדשים

  3. חיפוש לרוחב ולעומק • חיפוש לעומק • מבטיח מציאת פתרון, הקצר ביותר. • סיבוכיות – O(bn) – במקום ובזמן. • חיפוש לרוחב • במרחב אינסופי – אין הבטחה למציאת פתרון • זמן O(bn) מקום O(bn)

  4. Uniform Cost Search O 71 151 F Z S 99 80 211 75 R A 140 P 97 B 120 101 146 118 D 138 75 M 70 T 111 • UCS Intuition: Find shortest path in terms of sum of lengths of sub-paths. • Agenda: priority queue ordered by path length; get shortest path in queue. • Will it get the shortest path? • Optimal and complete L C

  5. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A

  6. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140

  7. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140 T118 S140 O146

  8. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140 T118 S140 O146 S140 O146L229

  9. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140 T118 S140 O146 S140 O146L229 O146R220 L229 F239 O291

  10. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140 T118 S140 O146 S140 O146L229 O146R220L229 F239 O291 R220 L229 F239 O291

  11. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140 T118 S140 O146 S140 O146L229 O146R220L229 F239 O291 R220 L229 F239 O291 L229 F239 O291 P317 D340 C366

  12. Uniform Cost Search O 151 F 71 S 99 Z 75 211 80 A 140 R B P 97 120 101 118 146 138 D 75 M T 111 70 L C A Z75 T118 S140 T118 S140 O146 S140 O146L229 O146R220L229 F239 O291 R220 L229 F239 O291 L229 F239 O291 P317 D340 C366 F239 O291 P317 D340 C366 M399 …

  13. חיפושים מיודעים informed search • הוספת ידע domain specific להעריך את הקרבה לפתרון • ההערכה מתבצעת על ידי פונקצית היוריסטיקה, h(n) (שלא מבטיחה את התוצאה הטובה ביותר אם בכלל) • תכנון המסלול נעשה על ידי • h(n) = estimated cost of the cheapest path from the state at n to goal state.

  14. חיפוש Best-First-Search • שינוי פונקציית התור בחיפוש • Evaluation function – פונקציה המשמשת להחלטה איזה קודקוד לפרוש בצעד החיפוש הבא: מחזירה מספר המייצג את טיב המצב הבא. • הקדקודים ממויינים כך שהקדקוד בעל הציון הטוב ביותר נבחר לצעד הבא. שימוש במדד (מוערך) – תוך ניסיון להשיג עלות מינימלית של החיפוש. • למשל: מרחק straight line distance מהיעד, בחיפוש נתיב על מפה.

  15. מפת רומניה מעודכנת

  16. Greedy Search Example

  17. Greedy Search (continued)

  18. Greedy Search Example

  19. Greedy Search (continued)

  20. הפתרון אינו אופטימלי: דרך Pimnicu Vilcea and Pitesi קצרה יותר. • לא אופטימלי • לא מבטיח פתרון • O(bm) סיבוכיות מקום וזמן

  21. Using Heuristic Information • What if h(B) is way larger than h(A)? • Add heuristic cost to path length so far • f(n) = g(n) + h(n) • A* S 150 10 A B 2 250 G

  22. Minimizing Cost • Uniform search מנסה להקטין את עלות מסלול החיפוש (נקרא לפונקציה g(n)) • שילוב בין h(n) של-g(n) • f(n)=g(n)+h(n) • למציאת הפתרון הזול ביותר, נחפש קודקוד שנותן ערך מינימלי ל-f. • מבטיחה פתרון complete and optimal אם הפונקציה h לא מחזירה ערך גדול יותר מאשר המרחק האמיתי למטרה, כלומר מדובר בהיוריסטיקה קבילה admissible.

  23. Admissibility • A* guaranteed to be optimal if h is admissible, i.e., cannot be an overestimate • If h is not admissible, cannot guarantee optimalityg(A)+h(A) = 105g(B)+h(B) = 203 S 100 3 A B h(B)=200 h(A)=5 5 4 G h(G)=0

  24. Heuristic for Path-Planning Problem: SLD • Is straight-line distance (SLD) an admissible heuristic for path planning? • Triangle inequality |AC| < |AB|+|BC| • Admissible!

  25. Graph Search Requires Consistency as well! • Consistency: h(n) ≤ c(n,n') + h(n'), where n' is a successor of n • Graph search is optimal if h(n) is consistent • If h(n) is consistent thenf(n) is a monotonicallyincreasing function n c(n,n') h(n) n' h(n') G

  26. Selecting a Heuristic • Heuristic should cut down on search space. • Can find heuristic by relaxing the problem • Heuristic functions can be solutions to “relaxed” version of original • Procedure: Relax hard problem so it’s easy to solve; use solution to relaxed problem as heuristic for real problem.

  27. 8-Puzzle Heuristic Possibilities • Relaxed problems: • Number of tiles in wrong position. • Distance from each tile to its proper place. • Admissible.

  28. A* Search

  29. A* Search

  30. A* Search

  31. A* Search

  32. A* Search

  33. Norvig’s Lisp – tree search (defun tree-search (states goal-p successors combiner) "Find a state that satisfies goal-p. Start with states, and search according to successors and combiner." (dbg :search "~&;; Search: ~a" states) (cond ((null states) fail) ((funcall goal-p (first states)) (first states)) (t (tree-search (funcall combiner (funcall successors (first states)) (rest states)) goal-p successors combiner))))

  34. DFS, BFS (defun depth-first-search (start goal-p successors) "Search new states first until goal is reached." (tree-search (list start) goal-p successors #'append)) (defun binary-tree (x) (list (* 2 x) (+ 1 (* 2 x)))) (defun is (value) #'(lambda (x) (eql x value))) (defun prepend (x y) "Prepend y to start of x" (append y x)) (defun breadth-first-search (start goal-p successors) "Search old states first until goal is reached." (tree-search (list start) goal-p successors #'prepend)) (defun finite-binary-tree (n) "Return a successor function that generates a binary tree with n nodes." #'(lambda (x) (remove-if #'(lambda (child) (> child n)) (binary-tree x))))

  35. Best First Search (defun diff (num) "Return the function that finds the difference from num." #'(lambda (x) (abs (- x num)))) (defun sorter (cost-fn) "Return a combiner function that sorts according to cost-fn." #'(lambda (new old) (sort (append new old) #'< :key cost-fn))) (defun best-first-search (start goal-p successors cost-fn) "Search lowest cost states first until goal is reached." (tree-search (list start) goal-p successors (sorter cost-fn)))

  36. Beam Search (defun beam-search (start goal-p successors cost-fn beam-width) "Search highest scoring states first until goal is reached, but never consider more than beam-width states at a time." (tree-search (list start) goal-p successors #'(lambda (old new) (let ((sorted (funcall (sorter cost-fn) old new))) (if (> beam-width (length sorted)) sorted (subseq sorted 0 beam-width))))))

More Related