David Kauchak CS51A – Spring 2019

Slides:



Advertisements
Similar presentations
CMSC 471 Fall 2002 Class #5-6 – Monday, September 16 / Wednesday, September 18.
Advertisements

CMSC 671 Fall 2005 Class #5 – Thursday, September 15.
Informed Search CS 63 Chapter 4
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.
Search Techniques MSc AI module. Search In order to build a system to solve a problem we need to: Define and analyse the problem Acquire the knowledge.
Problem Solving by Searching
Uninformed Search Reading: Chapter 3 by today, Chapter by Wednesday, 9/12 Homework #2 will be given out on Wednesday DID YOU TURN IN YOUR SURVEY?
Problem Solving and Search in AI Heuristic Search
CMU Snake Robot
State-Space Searches. 2 State spaces A state space consists of A (possibly infinite) set of states The start state represents the initial problem Each.
Some material adopted from notes by Charles R. Dyer, University of Wisconsin-Madison Informed Search Chapter 4 (a)
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.
For Wednesday Read chapter 6, sections 1-3 Homework: –Chapter 4, exercise 1.
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*
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.
Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most desirable unexpanded node Implementation:
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.
For Monday Read chapter 4 exercise 1 No homework.
CMPT 463. What will be covered A* search Local search Game tree Constraint satisfaction problems (CSP)
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
1 Intro to AI Informed Search. 2 Intro to AI Heuristic search Best-first search –Greedy search –Beam search –A, A* –Examples Memory-conserving variations.
CSG3F3/ Desain dan Analisis Algoritma
Computer Science cpsc322, Lecture 7
Review: Tree search Initialize the frontier using the starting state
Heuristic Functions.
Heuristic Search A heuristic is a rule for choosing a branch in a state space search that will most likely lead to a problem solution Heuristics are used.
For Monday Chapter 6 Homework: Chapter 3, exercise 7.
Department of Computer Science
David Kauchak CS30 – Spring 2016
Informed Search Chapter 4 (a)
Artificial Intelligence Problem solving by searching CSC 361
Informed Search Chapter 4 (a)
HW #1 Due 29/9/2008 Write Java Applet to solve Goats and Cabbage “Missionaries and cannibals” problem with the following search algorithms: Breadth first.
Finding Heuristics Using Abstraction
The A* Algorithm Héctor Muñoz-Avila.
CS 4100 Artificial Intelligence
Informed search algorithms
Informed search algorithms
Lecture 8 Heuristic search Motivational video Assignment 2
BEST FIRST SEARCH -OR Graph -A* Search -Agenda Search CSE 402
Artificial Intelligence
Informed Search Chapter 4 (a)
A General Backtracking Algorithm
(1) Breadth-First Search  S Queue S
Heuristic Search Methods
CPSC 322 Introduction to Artificial Intelligence
Sudoku.
Solving problems by searching
Solving problems by searching
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
State-Space Searches.
State-Space Searches.
Search.
HW 1: Warmup Missionaries and Cannibals
CS 416 Artificial Intelligence
Search.
Midterm Review.
David Kauchak CS51A – Spring 2019
David Kauchak CS51A – Spring 2019
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
State-Space Searches.
Informed Search Idea: be smart about what paths to try.
Constraint satisfaction problems
Lecture 4: Tree Search Strategies
Solving problems by searching
Presentation transcript:

David Kauchak CS51A – Spring 2019 informed Search 2 David Kauchak CS51A – Spring 2019

Admin Assignment 9 Assignment 10

from: Claremont to:Rowland Heights What would the search algorithms do?

from: Claremont to:Rowland Heights DFS

from: Claremont to:Rowland Heights BFS

from: Claremont to: Rowland Heights Ideas?

from: Claremont to: Rowland Heights We’d like to bias search towards the actual solution

Informed search Order to_visit based on some knowledge of the world that estimates how “good” a state is h(n) is called an evaluation function Best-first search rank to_visit based on h(n) take the most desirable state in to_visit first different approaches depending on how we define h(n)

Heuristic Merriam-Webster's Online Dictionary Heuristic (pron. \hyu-’ris-tik\): adj. [from Greek heuriskein to discover.] involving or serving as an aid to learning, discovery, or problem-solving by experimental and especially trial-and-error methods The Free On-line Dictionary of Computing (2/19/13) heuristic 1. Of or relating to a usually speculative formulation serving as a guide in the investigation or solution of a problem: "The historian discovers the past by the judicious use of such a heuristic device as the 'ideal type'" (Karl J. Weintraub).

Heuristic function: h(n) An estimate of how close the node is to a goal Uses domain-specific knowledge! Examples Map path finding? 8-puzzle? Missionaries and cannibals?

Heuristic function: h(n) An estimate of how close the node is to a goal Uses domain-specific knowledge! Examples Map path finding? straight-line distance from the node to the goal (“as the crow flies”) 8-puzzle? how many tiles are out of place sum of the “distances” of the out of place tiles Missionaries and cannibals? number of people on the starting bank

Two heuristics Which state is better? 1 2 3 8 4 7 6 5 GOAL 2 8 3 1 6 4

Two heuristics How many tiles are out of place? 2 8 3 1 6 4 7 5 1 2 3 Goal How many tiles are out of place?

Two heuristics 2 8 3 1 6 4 7 5 1 2 3 8 4 7 6 5 Goal 5

Two heuristics 2 8 3 1 6 4 7 5 1 2 3 8 4 7 6 5 Goal What is the “distance” of the tiles that are out of place?

Two heuristics 2 8 3 1 6 4 7 5 1 2 3 8 4 7 6 5 1 2 1 1 1 Goal 6

? Two heuristics 5 6 Sum of distances for out of place tiles Tiles out of place 2 8 3 1 6 4 7 5 5 6 1 2 3 8 4 7 6 5 1 2 3 8 6 4 7 5 GOAL ? 6 2 3 8 4 7 1 5

Two heuristics 5 6 2 2 2 6 Sum of distances for out of place tiles Tiles out of place 2 8 3 1 6 4 7 5 5 6 1 2 3 8 4 7 6 5 1 2 3 8 6 4 7 5 2 2 GOAL 1 1 6 2 3 8 4 7 1 5 3 2 6 3

Two heuristics 5 6 Which heuristic is better (if either)? 2 2 2 6 Sum of distances for out of place tiles Tiles out of place 2 8 3 1 6 4 7 5 5 6 1 2 3 8 4 7 6 5 Which heuristic is better (if either)? 1 2 3 8 6 4 7 5 2 2 GOAL 1 1 6 2 3 8 4 7 1 5 3 2 6 3

Two heuristics Sum of distances for out of place tiles Tiles out of place 2 8 3 1 6 4 7 5 5 6 More closely approximates “real” number of steps remaining? 1 2 3 8 4 7 6 5 1 2 3 8 6 4 7 5 2 2 GOAL 2 1 6 2 3 8 4 7 1 5 3 2 6 3

2 8 3 1 6 4 7 5 Next states?

2 8 3 1 6 4 7 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 Which would you do?

2 8 3 1 6 4 7 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 Which would DFS choose Completely depends on how next states are generated. Not an “intelligent” decision!

Best first search: out of place tiles? 1 2 3 8 4 7 6 5 2 8 3 1 6 4 7 5 GOAL 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 Best first search: out of place tiles?

Best first search: distance of tiles? 1 2 3 8 4 7 6 5 2 8 3 1 6 4 7 5 GOAL 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 1 2 1 2 1 2 6 4 6 1 1 1 1 1 1 1 Best first search: distance of tiles?

1 2 3 8 4 7 6 5 2 8 3 1 6 4 7 5 GOAL 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 Next states?

Which next for best first search? 1 2 3 8 4 7 6 5 2 8 3 1 6 4 7 5 GOAL 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 1 2 6 4 6 1 2 3 1 8 4 7 6 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 3 5 5 5 Which next for best first search?

1 2 3 8 4 7 6 5 2 8 3 1 6 4 7 5 GOAL 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 1 2 4 1 2 3 1 8 4 7 6 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 3 5 5 5 2 3 1 8 4 7 6 5 2 8 3 1 4 7 6 5 2 3 1 8 4 7 6 5 2 4 4

1 2 3 8 4 7 6 5 2 8 3 1 6 4 7 5 GOAL 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 1 2 4 1 2 3 1 8 4 7 6 5 2 8 3 1 4 7 6 5 2 8 3 1 6 4 7 5 2 8 3 1 4 7 6 5 3 5 5 5 2 3 1 8 4 7 6 5 2 8 3 1 4 7 6 5 2 3 1 8 4 7 6 5 2 4 4 …

Informed search algorithms Best first search is called an “informed” search algorithm Why wouldn’t we always use an informed algorithm? Coming up with good heuristics can be hard for some problems There is computational overhead (both in calculating the heuristic and in keeping track of the next “best” state)

Informed search algorithms Any other problems/concerns about best first search?

Informed search algorithms Any other problems/concerns about best first search? Only as good as the heuristic function START GOAL Best first search using distance as the crow flies as heuristic What would the search do?

Informed search algorithms Any other problems/concerns about best first search? Only as good as the heuristic function START GOAL Best first search using distance as the crow flies as heuristic What is the problem?

Informed search algorithms Any other problems/concerns about best first search? Only as good as the heuristic function START GOAL Best first search using distance as the crow flies as heuristic Doesn’t take into account how far it has come. Best first search is a “greedy” algorithm

Informed search algorithms Best first search is called an “informed” search algorithm There are many other informed search algorithms: A* search (and variants) Theta* Beam search

Sudoku Fill in the grid with the numbers 1-9 4 3 6 7 5 2 8 1 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 7 2 8 9 3 6 5 1 4 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 4 3 6 7 5 2 8 1 How can we pose this as a search problem? State Start state Goal state State space/transitions Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 4 3 6 7 5 2 8 1 How can we pose this as a search problem? State: 9 x 9 grid with 1-9 or empty Start state: Goal state: State space/transitions Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 4 3 6 7 5 2 8 1 Generate next states: pick an open entry try all possible numbers that meet constraints Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 How many next states? 4 3 6 7 5 2 8 1 Generate next states: pick an open entry try all possible numbers that meet constraints How many next states? What are they? Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 1, 6, 7, 9 4 3 6 7 5 2 8 1 Generate next states: pick an open entry try all possible numbers that meet constraints 1, 6, 7, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 1, 6, 7, 9 4 3 6 7 5 2 8 Generate next states: pick an open entry try all possible numbers that meet constraints 1, 6, 7, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 How many next states? 4 3 6 7 5 2 8 Generate next states: pick an open entry try all possible numbers that meet constraints How many next states? What are they? Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 2, 6, 7, 8, 9 4 3 6 7 5 2 8 Generate next states: pick an open entry try all possible numbers that meet constraints 2, 6, 7, 8, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 2, 6, 7, 8, 9 4 3 6 7 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints 2, 6, 7, 8, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 What are the next states? 2 4 3 6 7 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints What are the next states? Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 7, 8, 9 2 4 3 6 7 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints 7, 8, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 7, 8, 9 2 7 4 3 6 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints 7, 8, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 2 7 4 3 6 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 2 7 9 4 3 6 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Now what? Fill in the grid with the numbers 1-9 2 7 9 4 3 6 5 8 Generate next states: pick an open entry try all possible numbers that meet constraints Now what? Try another branch, i.e. go back to a place where we had a decision and try a different one Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Sudoku Fill in the grid with the numbers 1-9 7, 8, 9 2 8 4 3 6 7 5 Generate next states: pick an open entry try all possible numbers that meet constraints 7, 8, 9 Fill in the grid with the numbers 1-9 each row has 1-9 (without repetition) each column has 1-9 (without repetition) each quadrant has 1-9 (without repetition)

Best first Sudoku search DFS and BFS will choose entries (and numbers within those entries) randomly Is that how people do it? How do you do it? Heuristics for best first search? Generate next states: pick an open entry try all possible numbers that meet constraints

Best first Sudoku search DFS and BFS will choose entries (and numbers within those entries) randomly Pick the entry that is MOST constrained People often try and find entries where only one option exists and only fill it in that way (very little search) Generate next states: pick an open entry try all possible numbers that meet constraints

Representing the Sudoku board 4 3 6 7 5 2 8 1 [1, 6, 7, 9], [1, 2, 6, 7, 8, 9], [1, 2, 7, 8, 9], [1, 9], 4, 3, 5, [1, 6, 7, 9], [1, 7, 9] Which is the most constrained (of the ones above)? Board is a matrix (list of lists) Each entry is either: a number (if we’ve filled in the space already, either during search or as part of the starting state) a list of numbers that are valid to put in that entry if it hasn’t been filled in yet

Representing the Sudoku board 4 3 6 7 5 2 8 1 [1, 6, 7, 9], [1, 2, 6, 7, 8, 9], [1, 2, 7, 8, 9], [1, 9], 4, 3, 5, [1, 6, 7, 9], [1, 7, 9] Which is the most constrained (of the ones above)? Board is a matrix (list of lists) Each entry is either: a number (if we’ve filled in the space already, either during search or as part of the starting state) a list of numbers that are valid to put in that entry if it hasn’t been filled in yet

Representing the Sudoku board 1 4 3 6 7 5 2 8 What would the state look like if we add pick 1? Board is a matrix (list of lists) Each entry is either: a number (if we’ve filled in the space already, either during search or as part of the starting state) a list of numbers that are valid to put in that entry if it hasn’t been filled in yet

Representing the Sudoku board 1 4 3 6 7 5 2 8 [6, 7, 9], [ 2, 6, 7, 8, 9], [2, 7, 8, 9], [9], 4, 3, 5, [6, 7, 9], [7, 9] Remove 1 from all entries in the quadrant What other parts of the board need to be updated? Board is a matrix (list of lists) Each entry is either: a number (if we’ve filled in the space already, either during search or as part of the starting state) a list of numbers that are valid to put in that entry if it hasn’t been filled in yet

Representing the Sudoku board 1 4 3 6 7 5 2 8 [6, 7, 9], [ 2, 6, 7, 8, 9], [2, 7, 8, 9], [9], 4, 3, 5, [6, 7, 9], [7, 9] Remove 1 from all entries in the quadrant Remove 1 from all entries in the same column Remove 1 from all entries in the same row Board is a matrix (list of lists) Each entry is either: a number (if we’ve filled in the space already, either during search or as part of the starting state) a list of numbers that are valid to put in that entry if it hasn’t been filled in yet