חיפוש בינה מלאכותית אבי רוזנפלד. סוכנים פותרי בעיות Reflex agents לא יכולים לתכנן קדימה כדי לחפש, יש צורך לייצר מודל לחפש בו !

Slides:



Advertisements
Similar presentations
Informed search algorithms
Advertisements

Informed search algorithms
Informed search algorithms
Informed search algorithms
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*
Artificial Intelligence Spring 2009
EIE426-AICV 1 Blind and Informed Search Methods Filename: eie426-search-methods-0809.ppt.
Search Strategies CPS4801. Uninformed Search Strategies Uninformed search strategies use only the information available in the problem definition Breadth-first.
Problem Solving by Searching
CSC344: AI for Games Lecture 5 Advanced heuristic search Patrick Olivier
SE Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Review: Search problem formulation
CS 460 Spring 2011 Lecture 3 Heuristic Search / Local Search.
Problem Solving and Search in AI Heuristic Search
Review Best-first search uses an evaluation function f(n) to select the next node for expansion. Greedy best-first search uses f(n) = h(n). Greedy best.
CSC344: AI for Games Lecture 4: Informed search
פתרון על ידי בעיות חיפוש בינה מלאכותית יעל נצר. סוכנים פותרי בעיות Reflex agents לא יכולים לתכנן קדימה Reflex agents עם מצב פנימי ( מודל עולם ) – קשה.
CS 561, Session 6 1 Last time: Problem-Solving Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation:
Rutgers CS440, Fall 2003 Heuristic search Reading: AIMA 2 nd ed., Ch
Informed search algorithms
Local Search and Optimization
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Search CSE When you can’t use A* Hill-climbing Simulated Annealing Other strategies 2 person- games.
INTRODUÇÃO AOS SISTEMAS INTELIGENTES Prof. Dr. Celso A.A. Kaestner PPGEE-CP / UTFPR Agosto de 2011.
Informed search algorithms
Informed search algorithms
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics Memory Bounded A* Search.
Informed search algorithms Chapter 4. Outline Best-first search Greedy best-first search A * search Heuristics.
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.
ISC 4322/6300 – GAM 4322 Artificial Intelligence Lecture 3 Informed Search and Exploration Instructor: Alireza Tavakkoli September 10, 2009 University.
CS 380: Artificial Intelligence Lecture #4 William Regli.
Informed searching. Informed search Blind search algorithms do not consider any information about the states and the goals Often there is extra knowledge.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
Local Search Algorithms
Local Search Pat Riddle 2012 Semester 2 Patricia J Riddle Adapted from slides by Stuart Russell,
For Wednesday Read chapter 6, sections 1-3 Homework: –Chapter 4, exercise 1.
Chapter 4 Informed Search and Exploration. Outline Informed (Heuristic) search strategies  (Greedy) Best-first search  A* search (Admissible) Heuristic.
For Wednesday Read chapter 5, sections 1-4 Homework: –Chapter 3, exercise 23. Then do the exercise again, but use greedy heuristic search instead of A*
Princess Nora University Artificial Intelligence Chapter (4) Informed search algorithms 1.
CSC3203: AI for Games Informed search (1) Patrick Olivier
Informed Search and Heuristics Chapter 3.5~7. Outline Best-first search Greedy best-first search A * search Heuristics.
4/11/2005EE562 EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS Lecture 4, 4/11/2005 University of Washington, Department of Electrical Engineering Spring 2005.
A General Introduction to Artificial Intelligence.
Feng Zhiyong Tianjin University Fall  Best-first search  Greedy best-first search  A * search  Heuristics  Local search algorithms  Hill-climbing.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
Informed search algorithms Chapter 4 Slides derived in part from converted to powerpoint by Min-Yen.
Heuristic Search Foundations of Artificial Intelligence.
Lecture 6 – Local Search Dr. Muhammad Adnan Hashmi 1 24 February 2016.
Local Search Algorithms and Optimization Problems
Artificial intelligence 1: informed search. 2 Outline Informed = use problem-specific knowledge Which search strategies?  Best-first search and its variants.
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
CPSC 420 – Artificial Intelligence Texas A & M University Lecture 5 Lecturer: Laurie webster II, M.S.S.E., M.S.E.e., M.S.BME, Ph.D., P.E.
Local Search Algorithms CMPT 463. When: Tuesday, April 5 3:30PM Where: RLC 105 Team based: one, two or three people per team Languages: Python, C++ and.
Romania. Romania Problem Initial state: Arad Goal state: Bucharest Operators: From any node, you can visit any connected node. Operator cost, the.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
Constraints Satisfaction Edmondo Trentin, DIISM. Constraint Satisfaction Problems: Local Search In many optimization problems, the path to the goal is.
Local search algorithms In many optimization problems, the path to the goal is irrelevant; the goal state itself is the solution State space = set of "complete"
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.
Last time: Problem-Solving
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
CS 4100 Artificial Intelligence
Artificial Intelligence Informed Search Algorithms
Informed search algorithms
Artificial Intelligence
Solving Problems by Searching
Informed Search.
Presentation transcript:

חיפוש בינה מלאכותית אבי רוזנפלד

סוכנים פותרי בעיות Reflex agents לא יכולים לתכנן קדימה כדי לחפש, יש צורך לייצר מודל לחפש בו !

להגדרת אלגוריתם חיפוש סוכן צריך לדחות פעולות שלא מקדמות למטרה Goal formulation - נוסחת מטרה המבוססת על מדד הביצועים הנוכחיים של הסוכן ועל המצב הנוכחי מטרה – אוסף של מצבים בעולם שצריכים להתקיים אם המטרה הושגה. מטרת הסוכן היא למצוא את רצף הפעולות שיביא אותו לאוסף הזה של מצבים קודם לכן, עליו להחליט אילו פעולות ואילו מצבים הם רלוונטיים.

State Space 1. initial state 2. successor function

Goal Test 3. goal test

מפת רומניה

Example: 8-Puzzle

(Partial) Search Space for 8-Puzzle Problem 1. initial state 2. successor function 3. goal test

Example: Route Planning in a Map Graph: nodes are cities and links are roads. Map gives world dynamics Current state is known World is fully predictable World (set of cities) is finite and enumerable. Cost: total distance or total time for path.

על מה לומדים היום ? BFS DFS Best-first search A * search – Heuristics Local search algorithms – Hill-climbing search – Backtracking – Simulated annealing 10

איך מבצעים את החיפוש?

Breadth-First Search Breadth-first search tree after 0,1,2 and 3 node expansions CLASSIC FIFO! (Queue!) אופטימאלי

Depth-First Search לא אופטימאלי ! Alternatively can use a recursive implementation.

Breadth-First Search A B Z O SF C P R T L M D

A B Z O SF C P R T L M D A

A B Z O SF C P R T L M D A Z A S A T A

Breadth-First Search A B Z O SF C P R T L M D A Z A S A T A S A T A O AZ

Breadth-First Search A B Z O SF C P R T L M D A Z A S A T A S A T A O AZ T A O AZ O AS F AS R AS

Breadth-First Search A B Z O SF C P R T L M D A Z A S A T A S A T A O AZ T A O AZ O AS F AS R AS O AZ O AS F AS R AS L AT

Breadth-First Search A B Z O SF C P R T L M D A Z A S A T A S A T A O AZ T A O AZ O AS F AS R AS O AZ O AS F AS R AS L AT O AS F AS R AS L AT

Breadth-First Search A B Z O SF C P R T L M D A Z A S A T A S A T A O AZ T A O AZ O AS F AS R AS O AZ O AS F AS R AS L AT O AS F AS R AS L AT

Breadth-First Search A B Z O SF C P R T L M D A Z A S A T A S A T A O AZ T A O AZ O AS F AS R AS O AZ O AS F AS R AS L AT O AS F AS R AS L AT R AS L AT B ASF Result = B ASF

Breadth-First Search B A Z O SF C P R T L M D

Evaluation of Search Strategies Completeness Time Complexity Space Complexity Optimality To evaluate, we use the following terms b = branching factor m = maximum depth d = goal depth

Evaluation of BFS Complete Complexity: – O(b d ) time – O(b d ) space Optimal (counting by number of arcs).

Depth-First Search A B Z O SF C P R T L M D

A B Z O SF C P R T L M D A

A B Z O SF C P R T L M D A Z A S A T A

Depth-First Search A B Z O SF C P R T L M D A Z A S A T A

Depth-First Search A B Z O SF C P R T L M D A Z A S A T A O AZ S A T A

Depth-First Search A B Z O SF C P R T L M D A Z A S A T A O AZ S A T A S AZO S A T A

Depth-First Search A B Z O SF C P R T L M D A Z A S A T A O AZ S A T A S AZO S A T A F AZOS R AZOS S A T A

Depth-First Search A B Z O SF C P R T L M D A Z A S A T A O AZ S A T A S AZO S A T A F AZOS R AZOS S A T A B AZOSF R AZOS S A T A

Depth-First Search A B Z O SF C P R T L M D A Z A S A T A O AZ S A T A S AZO S A T A F AZOS R AZOS S A T A B AZOSF R AZOS S A T A Result = B AZOSF

Depth-first Search O A B Z SF C P R T L M D

Evaluation of DFS Not complete Complexity: – O(b m ) time – O(mb) space Non-optimal

Bi-Directional Search

Romania with step costs in km 38

Greedy best-first search example 39

Greedy best-first search example 40

Greedy best-first search example 41

Greedy best-first search example 42

Romania with step costs in km 43 המחיר הכולל: 450. האם זה אופטימאלי? לא!

Properties of greedy best-first search  Complete? No – can get stuck in loops, e.g., Iasi  Neamt  Iasi  Neamt  Complete in finite space with checking for repeated states  Time? O(b m ), but a good heuristic can give dramatic improvement  Space? O(b m ) – keeps all nodes in memory  Optimal? No 44 b is branching factor, m is maximum depth of the search space

 הרעיון המרכזי : קח בחשבון את המחיר הכללי ( עד עכשיו )  Evaluation function f(n) = g(n) + h(n)  g(n) = cost so far to reach n  h(n) = estimated cost from n to goal  f(n) = estimated total cost of path through n to goal A* search uses an admissable heuristic:  h(n) <= h*(n), where h*(n) is the true cost from n  Also require h(n) >= 0, so h(G) = 0 for any goal G 45 A * חיפוש

A * search example 46

A * search example 47

A * search example 48

A * search example 49

A * search example 50

A * search example 51

Romania with step costs in km 52

Heuristic functions  E.g., for the 8-puzzle  Avg. solution cost is about 22 steps (branching factor +/- 3)  Exhaustive search to depth 22: 3.1 x states  A good heuristic function can reduce the search 53

Heuristic functions  For the 8-puzzle, two commonly used heuristics  h 1 = the number of misplaced tiles  h 1 (s)=8  h 2 = the sum of the distances of the tiles from their goal positions (manhattan distance)  h 2 (s)= =18 54

Inventing admissible heuristics  Another way to find an admissible heuristic is through learning from experience:  Experience = solving lots of 8-puzzles  An inductive learning algorithm can be used to predict costs for other states that arise during search 55

בעיית המלכות השחמט יש ל 8 מלכות בשחמט איך אפשר לשים את כולם על הלוח כך שאחת לא יכולה לתקוף את השני יש 92 פתרונות D7%95%D7%A0%D7%94_%D7%94%D7%9E%D7%9C%D7%9B%D7%95%D7%AA D7%95%D7%A0%D7%94_%D7%94%D7%9E%D7%9C%D7%9B%D7%95%D7%AA 56 a)b)

חיפוש לוקאלי  אל תחפש כל מצב – רק תנסה " תיקון " מקומי  יתרונות  אין צורך בהרבה זיכרון  אפשר למצוא פתרונות במרחבי חיפוש גדולים 57

Hill-climbing search 58

Hill-climbing example 8-queens problem (complete-state formulation) Successor function: move a single queen to another square in the same column Heuristic function h(n): the number of pairs of queens that are attacking each other (directly or indirectly, i.e., “through” another queen) 59

Example: n-queens  Put n queens on an n × n board with no two queens on the same row, column, or diagonal  Move a queen to reduce the number of conflicts 60

Hill-climbing example a) shows a state of h=17 and the h-value for each possible successor b) A local minimum in the 8-queens state space (h=1) 61 a)b)

Drawbacks  Ridge = sequence of local maxima difficult for greedy algorithms to navigate  Plateau = an area of the state space where the evaluation function is flat  Gets stuck 86% of the time in the 8-queens problem 62

פתרון אחד : Backtracking  תחזור חזרה למלכה האחרונה – ותזיז אותה !  קוד שלי באתר  tm tm 63

Hill Climbing Variations  Random-restart hill-climbing  Tries to avoid getting stuck in local maxima  Conducts a series of hill-climbing searches from randomly generated initial states  Stops each search at a local maxima – or better yet, stops after a fixed amount of time  For the 3,000,000-queens problem, solutions found in under a minute  The success (or failure) of hill-climbing can very much depend on the shape of the state- space landscape 64

Simulated annealing  Escape local maxima by allowing “bad” moves  Idea: but gradually decrease their size and frequency  Origin; metallurgical annealing  Bouncing ball analogy:  Shaking hard (= high temperature)  Shaking less (= lower the temperature)  If T decreases slowly enough, best state is reached  Applied for VLSI layout, airline scheduling, etc. 65

Simulated annealing search  Idea (again): escape local maxima by allowing some “bad” moves but gradually decrease their size and frequency 66