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

Slides:



Advertisements
Similar presentations
BEST FIRST SEARCH - BeFS
Advertisements

Review: Search problem formulation
An Introduction to Artificial Intelligence
The A* Algorithm Héctor Muñoz-Avila. The Search Problem Starting from a node n find the shortest path to a goal node g ?
Greedy best-first search Use the heuristic function to rank the nodes Search strategy –Expand node with lowest h-value Greedily trying to find the least-cost.
Solving Problem by Searching
1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*
Problem Solving by Searching
SE Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Review: Search problem formulation
Project 1: Background Informed search : 8- puzzle world BFS, DFS and A* algorithms Heuristics : Manhattan distance, Number of misplaced tiles Lisp programming.
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
Problem Solving and Search in AI Heuristic Search
CSC344: AI for Games Lecture 4: Informed search
Rutgers CS440, Fall 2003 Heuristic search Reading: AIMA 2 nd ed., Ch
Informed Search Idea: be smart about what paths to try.
Informed Search Strategies
Graphs II Robin Burke GAM 376. Admin Skip the Lua topic.
1 CS 2710, ISSP 2610 Chapter 4, Part 1 Heuristic Search.
Informed search algorithms
Problem Solving by Searching Search Methods : informed (Heuristic) search.
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
CHAPTER 4: INFORMED SEARCH & EXPLORATION Prepared by: Ece UYKUR.
1 Shanghai Jiao Tong University Informed Search and Exploration.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Informed Search Methods. Informed Search  Uninformed searches  easy  but very inefficient in most cases of huge search tree  Informed searches  uses.
Informed Search Strategies Lecture # 8 & 9. Outline 2 Best-first search Greedy best-first search A * search Heuristics.
Informed Search Include specific knowledge to efficiently conduct the search and find the solution.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
Review: Tree search Initialize the frontier using the starting state While the frontier is not empty – Choose a frontier node to expand according to search.
CSC3203: AI for Games Informed search (1) Patrick Olivier
Informed Search I (Beginning of AIMA Chapter 4.1)
Artificial Intelligence Problem solving by searching.
1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
State space representations and search strategies - 2 Spring 2007, Juris Vīksna.
Informed Search CSE 473 University of Washington.
Heuristic Functions. A Heuristic is a function that, when applied to a state, returns a number that is an estimate of the merit of the state, with respect.
Search CSC 358/ Outline  Homework #7  GPS States and operators Issues  Search techniques DFS, BFS Beam search A* search Alpha-beta search.
A* optimality proof, cycle checking CPSC 322 – Search 5 Textbook § 3.6 and January 21, 2011 Taught by Mike Chiang.
CHAPTER 2 SEARCH HEURISTIC. QUESTION ???? What is Artificial Intelligence? The study of systems that act rationally What does rational mean? Given its.
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
G5AIAI Introduction to AI Graham Kendall Heuristic Searches.
Informed Search 1.
Search CSC 358/ Outline Homework #6 Game search States and operators Issues Search techniques DFS, BFS Beam search A* search Alpha-beta.
For Monday Read chapter 4 exercise 1 No homework.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Chapter 3.5 Heuristic Search. Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Review: Tree search Initialize the frontier using the starting state
Last time: Problem-Solving
Department of Computer Science
Heuristic Search Introduction to Artificial Intelligence
Artificial Intelligence Problem solving by searching CSC 361
The A* Algorithm Héctor Muñoz-Avila.
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
Informed search algorithms
Artificial Intelligence
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
HW 1: Warmup Missionaries and Cannibals
Artificial Intelligence
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
Informed Search Idea: be smart about what paths to try.
Informed Search.
“If I Only had a Brain” Search
Presentation transcript:

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

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

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

Uniform Cost Search 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 A B Z O S F P R T M D C

Uniform Cost Search A A B Z O S F C P R T L M D

Uniform Cost Search A Z 75 T 118 S 140 A B Z O S F C P R T L M D

Uniform Cost Search A T 118 S 140 O 146 Z 75 T 118 S 140 A B Z O S F C P R T L M D

S 140 O 146 L 229 Uniform Cost Search A T 118 S 140 O 146 Z 75 T 118 S 140 A B Z O S F C P R T L M D

S 140 O 146 L 229 Uniform Cost Search A T 118 S 140 O 146 Z 75 T 118 S 140 O 146 R 220 L 229 F 239 O 291 A B Z O S F C P R T L M D

S 140 O 146 L 229 Uniform Cost Search A T 118 S 140 O 146 Z 75 T 118 S 140 O 146 R 220 L 229 F 239 O 291 R 220 L 229 F 239 O 291 A B Z O S F C P R T L M D

S 140 O 146 L 229 Uniform Cost Search A T 118 S 140 O 146 Z 75 T 118 S 140 O 146 R 220 L 229 F 239 O 291 R 220 L 229 F 239 O 291 A B Z O S F C P R T L M D L 229 F 239 O 291 P 317 D 340 C 366

S 140 O 146 L 229 Uniform Cost Search A T 118 S 140 O 146 Z 75 T 118 S 140 O 146 R 220 L 229 F 239 O 291 R 220 L 229 F 239 O 291 A B Z O S F C P R T L M D F 239 O 291 P 317 D 340 C 366 M 399 … L 229 F 239 O 291 P 317 D 340 C 366

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

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

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

Greedy Search Example

Greedy Search (continued)

Greedy Search Example

Greedy Search (continued)

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

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 AB G

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

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

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

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 then f(n) is a monotonically increasing function n n' G h(n) h(n') c(n,n')

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.

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

A* Search

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))))

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))))

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)))

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))))))