1 CSC 550: Introduction to Artificial Intelligence Fall 2004 heuristics & informed search  heuristics  hill-climbing bold + informed search potential.

Slides:



Advertisements
Similar presentations
Heuristics & Informed Search
Advertisements

Artificial Intelligence
Artificial Intelligence Uninformed Search by LISP
Informed Search CS 171/271 (Chapter 4)
CMSC 471 Fall 2002 Class #5-6 – Monday, September 16 / Wednesday, September 18.
Review: Search problem formulation
Heuristic Search techniques
Informed search algorithms
An Introduction to Artificial Intelligence
Artificial Intelligence By Mr. Ejaz CIIT Sahiwal.
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.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 4 Jim Martin.
1 CSC 550: Introduction to Artificial Intelligence Fall 2008 heuristics & informed search  heuristics  hill-climbing bold + informed search potential.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2010 Decrease & conquer  previous examples  search spaces examples: travel, word ladder  depth.
October 1, 2012Introduction to Artificial Intelligence Lecture 8: Search in State Spaces II 1 A General Backtracking Algorithm Let us say that we can formulate.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
CS 484 – Artificial Intelligence1 Announcements Department Picnic: today, after class Lab 0 due today Homework 2 due Tuesday, 9/18 Lab 1 due Thursday,
Chapter 4 Search Methodologies.
Artificial Intelligence (CS 461D)
Heuristic search, page 1 CSI 4106, Winter 2005 Heuristic search Points Definitions Best-first search Hill climbing Problems with hill climbing An example:
Artificial Intelligence Lecture
Mahgul Gulzai Moomal Umer Rabail Hafeez
Review: Search problem formulation
1 Using Search in Problem Solving Part II. 2 Basic Concepts Basic concepts: Initial state Goal/Target state Intermediate states Path from the initial.
Informed Search (no corresponding text chapter). Recall: Wanted " An algorithm and associated data structure(s) that can: 1) Solve an arbitrary 8-puzzle.
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2004.
Using Search in Problem Solving
Intelligent Agents What is the basic framework we use to construct intelligent programs?
Problem Solving and Search in AI Heuristic Search
CSC344: AI for Games Lecture 4: Informed search
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2002.
CSCI 5582 Fall 2006 CSCI 5582 Artificial Intelligence Lecture 5 Jim Martin.
Problem-solving agents
Informed Search Next time: Search Application Reading: Machine Translation paper under Links Username and password will be mailed to class.
1 CSC 550: Introduction to Artificial Intelligence Fall 2004 applications of informed search  optimization problems Algorithm A, admissibility, A*  zero-sum.
For Friday Finish chapter 3 Homework: –Chapter 3, exercise 6 –May be done in groups. –Clarification on part d: an “action” must be running the program.
Heuristic Search Heuristic - a “rule of thumb” used to help guide search often, something learned experientially and recalled when needed Heuristic Function.
Informed Search Strategies
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l inference l all learning.
Introduction to search Chapter 3. Why study search? §Search is a basis for all AI l search proposed as the basis of intelligence l all learning algorithms,
Today’s Topics FREE Code that will Write Your PhD Thesis, a Best-Selling Novel, or Your Next Methods for Intelligently/Efficiently Searching a Space.
1 Shanghai Jiao Tong University Informed Search and Exploration.
Artificial Intelligence LECTURE 4 ARTIFICIAL INTELLIGENCE LECTURES BY ENGR. QAZI ZIA.
Informed search algorithms Chapter 4. Best-first search Idea: use an evaluation function f(n) for each node –estimate of "desirability"  Expand most.
For Friday Finish reading chapter 4 Homework: –Lisp handout 4.
For Monday Read chapter 4, section 1 No homework..
CS344: Introduction to Artificial Intelligence (associated lab: CS386)
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.
Lecture 3: Uninformed Search
For Wednesday Read chapter 6, sections 1-3 Homework: –Chapter 4, exercise 1.
For Friday Read chapter 4, sections 1 and 2 Homework –Chapter 3, exercise 7 –May be done in groups.
Basic Search Procedure 1. Start with the start node (root of the search tree) and place in on the queue 2. Remove the front node in the queue and If the.
Basic Problem Solving Search strategy  Problem can be solved by searching for a solution. An attempt is to transform initial state of a problem into some.
Goal-based Problem Solving Goal formation Based upon the current situation and performance measures. Result is moving into a desirable state (goal state).
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
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.
Heuristic Search Foundations of Artificial Intelligence.
Search as a problem solving technique. Consider an AI program that is capable of formulating a desired goal based on the analysis of the current world.
February 18, 2016Introduction to Artificial Intelligence Lecture 8: Search in State Spaces III 1 A General Backtracking Algorithm Sanity check function.
Artificial Intelligence Lecture No. 8 Dr. Asad Ali Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
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)
Heuristic search INT 404.
A General Backtracking Algorithm
Lecture 9 Administration Heuristic search, continued
Reading: Chapter 4.5 HW#2 out today, due Oct 5th
Presentation transcript:

1 CSC 550: Introduction to Artificial Intelligence Fall 2004 heuristics & informed search  heuristics  hill-climbing bold + informed search potential dangers, variants  best first search tentative + informed search best-first search vs. DFS vs. BFS

2 Search strategies so far… bold & uninformed: STUPID tentative & uninformed: DFS (and variants), BFS bold & informed: hill-climbing  essentially, DFS utilizing a "measure of closeness" to the goal (a.k.a. a heuristic function )  from a given state, pick the best successor state i.e., the state with highest heuristic value  stop if no successor is better than the current state i.e, no backtracking so only need to store current path EXAMPLE: travel problem, e.g.Omaha  LosAngeles heuristic(State) = -(crow-flies distance from goal)

3 Hill-climbing example (define MOVES '((Omaha --> Chicago) (Omaha --> Denver) (Chicago --> Denver) (Chicago --> LosAngeles) (Chicago --> Omaha) (Denver --> LosAngeles) (Denver --> Omaha) (LosAngeles --> Chicago) (LosAngeles --> Denver))) (define DISTANCES '((Omaha (Omaha 0) (Chicago 500) (Denver 400) (LosAngeles 1700)) (Chicago (Chicago 0) (Omaha 500) (Denver 700) (LosAngeles 2000)) (Denver (Denver 0) (Omaha 400) (Chicago 700) (LosAngeles 1400)) (LosAngeles (LosAngeles 0) (Omaha 1700) (Chicago 2000) (Denver 1400)))) (define (HEURISTIC state goalState) (- 0 (cadr (assoc goalState (cdr (assoc state DISTANCES)))))) the heuristic guides the search, always moving closer to the goal what if the flight from Denver to L.A. were cancelled?

4 Hill-climbing implementation (require (lib "compat.ss")) (define (hill-climb startState goalState) (define (climb-path path) (if (equal? (car path) goalState) path (let ((nextStates (sort better-state (GET-MOVES (car path))))) (if (or (null? nextStates) (not (better-state (car nextStates) (car path)))) #f (climb-path (cons (car nextStates) path)))))) (define (better-state state1 state2) (> (HEURISTIC state1 goalState) (HEURISTIC state2 goalState))) (climb-path (list startState))) can utilize the sort function from the compat.ss library  requires a comparison function (evals to #t if input1 should come before input2) climb-path takes the current path:  if the current state (car of path) is the goal, then SUCCEED  otherwise, get all possible moves and sort based on heuristic value (high to low)  if no moves or "best" move is no better than current state, then FAIL  otherwise, add "best" move to path and recurse

5 Hill-climbing in practice > (hill-climb 'Omaha 'LosAngeles) (losangeles denver omaha) > (hill-climb 'LosAngeles 'Omaha) (omaha denver losangeles ) given these flights, actually finds optimal paths ;;; REMOVED Denver to L.A. FLIGHT > (hill-climb 'Omaha 'LosAngeles) #f WHY? ;;; ADDED Omaha  KC, KC  LA FLIGHTS ;;; ASSUME Omaha is 200 mi from KC, KC is 1900 mi from LA > (hill-climb 'Omaha 'LosAngeles) (losangeles denver omaha) > (hill-climb 'LosAngeles 'Omaha) (losangeles kansascity omaha) get different answers WHY? hill-climbing only works if  the heuristic is accurate (i.e., distinguishes "closer" states)  the path to the goal is direct (i.e., state improves on every move)

6 8-puzzle example start state has 5 tiles in place hval = hval = 4hval = hval = 4 hval = 5 of the 3 possible moves, 2 improve the situation if assume left-to-right preference, move leads to a dead-end (no successor state improves the situation) so STOP! heuristic(State) = # of tiles in place, including the space

7 Intuition behind hill-climbing if you think of the state space as a topographical map (heuristic value = elevation), then hill- climbing selects the steepest gradient to move up towards the goal potential dangers plateau: successor states have same values, no way to choose foothill: local maximum, can get stuck on minor peak ridge: foothill where N-step lookahead might help

8 Hill-climbing variants could generalize hill-climbing to continue even if the successor states look worse  always choose best successor  don't stop unless reach the goal or no successors dead-ends are still possible (and likely if the heuristic is not perfect) simulated annealing  allow moves in the wrong direction on a probabilistic basis  decrease the probability of a backward move as the search continues idea: early in the search, when far from the goal, heuristic may not be good heuristic should improve as you get closer to the goal approach is based on a metallurgical technique

9 Best first search since bold, hill-climbing is dependent on a near-perfect heuristic tentative & informed: best first search  like breadth first search, keep track of all paths searched  like hill-climbing, use heuristics to guide the search  always expand the "most promising" path i.e., the path ending in a state with highest heuristic value

10 Best first example hval = hval = 4 hval = hval = hval = 9hval = 4 hval =

11 Breadth first search vs. best first search procedural description of breadth first search  must keep track of all current paths, initially: ((startState))  look at first path in the list of current paths if the path ends in a goal, then DONE otherwise,  remove the first path  generate all paths by extending to each possible move  add the newly extended paths to the end of the list  recurse procedural description of best first search  must keep track of all current paths, initially: ((startState))  look at first path in the list of current paths if the path ends in a goal, then DONE otherwise,  remove the first path  generate all paths by extending to each possible move  add the newly extended paths to the list, sorted by (decreasing) HEURISTIC value  recurse

12 Best first implementation (require (lib "compat.ss")) (define (best startState goalState) (define (best-paths paths) (cond ((null? paths) #f) ((equal? (caar paths) goalState) (car paths)) (else (best-paths (sort better-path (append (cdr paths) (extend-all (car paths) (GET-MOVES (caar paths))))))))) (define (extend-all path nextStates) (cond ((null? nextStates) '()) ((member (car nextStates) path) (extend-all path (cdr nextStates))) (else (cons (cons (car nextStates) path) (extend-all path (cdr nextStates)))))) (define (better-path path1 path2) (> (HEURISTIC (car path1) goalState) (HEURISTIC (car path2) goalState))) (best-paths (list (list startState)))) only difference from BFS implementation:  newly extended path list is sorted by heuristic value of end states (high-to-low)  since new paths are added at end & sort is stable, ties will favor older/shorter paths

13 Travel example > (best 'Omaha 'LosAngeles) (losangeles denver omaha) > (best 'LosAngeles 'Omaha) (omaha denver losangeles ) given these flights, actually finds optimal paths note: best first search does not guarantee an "optimal" solution  does not take the past into account, simply tries move that gets closest  would select LA  KC  Omaha  DesMoines even if LA  Chicago  DesMoines were possible ;;; REMOVED Denver to L.A. FLIGHT > (best 'Omaha 'LosAngeles) (losangeles chicago omaha) WHY? ;;; ADDED Omaha  KC, KC  LA FLIGHTS ;;; ASSUME Omaha is 200 mi from KC, KC is 1900 mi from LA > (best 'Omaha 'LosAngeles) (losangeles denver omaha) > (best 'LosAngeles 'Omaha) (losangeles kansascity omaha) still different answers WHY?

14 8-puzzle example (define (HEURISTIC state goalState) (cond ((null? state) 0) ((equal? (car state) (car goalState)) (+ 1 (HEURISTIC (cdr state) (cdr goalState)))) (else (HEURISTIC (cdr state) (cdr goalState))))) heuristic counts number of tile matches with goal > (best '( space 7 5 4) '( space )) (( space ) ( space 5) ( space) ( space 7 5 4)) > (best '( space ) '( space )) (( space ) ( space 5) ( space) ( space 7 5 4) ( space ) (1 2 3 space ) (space ) (2 space ) ( space )) DFS-nocycles required > 400 moves BFS found same soln, but 6 times slower DFS-nocycles hangs BFS found same soln, but > 200 times slower

15 Other examples heuristic function for the Water Jug Problem? heuristic function for Missionaries & Cannibals?

16 Comparing best first search unlike hill-climbing, best first search can handle "dips" in the search  not so dependent on a perfect heuristic depth first search and breadth first search may be seen as special cases of best first search DFS: heuristic value is distance (number of moves) from start state BFS: heuristic value is inverse of distance (number of moves) from start state or, procedurally: DFS: assign all states the same heuristic value when adding new paths, add equal heuristic values at the front BFS: assign all states the same heuristic value when adding new paths, add equal heuristic values at the end

17 Next week… MIDTERM EXAM (10/11)  designed to be completed in 60 – 90 minutes, will allow full 120 minutes types of questions:  TRUE/FALSE  short answer, discussion  explain/modify/augment/write Scheme code study advice:  review online lecture notes  review text  reference other sources for examples, different perspectives  look over quizzes