Project 1: Background Informed search : 8- puzzle world BFS, DFS and A* algorithms Heuristics : Manhattan distance, Number of misplaced tiles Lisp programming.

Slides:



Advertisements
Similar presentations
BEST FIRST SEARCH - BeFS
Advertisements

Review: Search problem formulation
Informed search strategies
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.
1 Heuristic Search Chapter 4. 2 Outline Heuristic function Greedy Best-first search Admissible heuristic and A* Properties of A* Algorithm IDA*
Informed (Heuristic) Search Algorithms. Homework #1 assigned due 10/4 before Exam 1 2.
Lisp Recitation (cse471/598 Fall 2007 ) Aravind Kalavagattu.
Review: Search problem formulation
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.
Returning values from functions You can return a value from a function by using the built- in function : ( return-from Function_name value) For example:
Problem Solving and Search in AI Heuristic Search
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2002.
Class of 28 th August. Announcements Lisp assignment deadline extended (will take it until 6 th September (Thursday). In class. Rao away on 11 th and.
Informed Search Idea: be smart about what paths to try.
LISP 1.5 and beyond A very quick tour. Data Atoms (symbols) including numbers – All types of numbers including Roman! (well, in the early days) – Syntactically.
Dijkstra’s Algorithm and Heuristic Graph Search David Johnson.
Search Much of AI has traditionally revolved around search –Search means “searching among all the possibilities for an answer” (or possibly the best answer)
Functional Programming 02 Lists
Vilalta&Eick: Informed Search Informed Search and Exploration Search Strategies Heuristic Functions Local Search Algorithms Vilalta&Eick: Informed Search.
Heuristic Search In addition to depth-first search, breadth-first search, bound depth-first search, and iterative deepening, we can also use informed or.
Informed (Heuristic) Search
1 CS 2710, ISSP 2610 Chapter 4, Part 1 Heuristic Search.
Informed search strategies Idea: give the algorithm “hints” about the desirability of different states – Use an evaluation function to rank nodes and select.
Lecture 6-2CS250: Intro to AI/Lisp Programming in Your Favorite Language Lecture 5-2 February 11 th, 1999 CS250.
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.
Introduction to LISP. Lisp Extensible: It lets you define new operators yourself Lisp programs are expressed as lisp data structures –You can write programs.
UMBC CMSC Common Lisp II. UMBC CMSC Input and Output Print is the most primitive output function > (print (list 'foo 'bar)) (FOO BAR) The.
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*
Lecture 5-1CS250: Intro to AI/Lisp “If I Only had a Brain” Search Lecture 5-1 October 26 th, 1999 CS250.
1 Kuliah 4 : Informed Search. 2 Outline Best-First Search Greedy Search A* Search.
Search (continued) CPSC 386 Artificial Intelligence Ellen Walker Hiram College.
Informed Search Reading: Chapter 4.5 HW #1 out today, due Sept 26th.
Milos Hauskrecht (PDF) Hieu D. Vu (PPT) LISP PROGARMMING LANGUAGE.
Heuristic Search Foundations of Artificial Intelligence.
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.
Searching for Solutions
Basic Introduction to Lisp
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.
Chapter 3.5 and 3.6 Heuristic Search Continued. Review:Learning Objectives Heuristic search strategies –Best-first search –A* algorithm Heuristic functions.
Honors Track: Competitive Programming & Problem Solving Finding your way with A*-algorithm Patrick Shaw.
G5AIAI Introduction to AI Graham Kendall Heuristic Searches.
Heuristic Search  Best First Search –A* –IDA* –Beam Search  Generate and Test  Local Searches –Hill Climbing  Simple Hill Climbing  Steepest Ascend.
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
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.
Department of Computer Science
Artificial Intelligence Problem solving by searching CSC 361
Discussion on Greedy Search and A*
Discussion on Greedy Search and A*
CS 4100 Artificial Intelligence
Artificial Intelligence
(1) Breadth-First Search  S Queue S
HW 1: Warmup Missionaries and Cannibals
Informed Search Idea: be smart about what paths to try.
Common Lisp II.
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.
Presentation transcript:

Project 1: Background Informed search : 8- puzzle world BFS, DFS and A* algorithms Heuristics : Manhattan distance, Number of misplaced tiles Lisp programming Defstruct, defparameter, setf, list, zerop mapcar, append, cond, loop..do, aref Funcall, return-from, format and ….

A* search Combines –Uniform cost search g(n): Exact path cost from start state to node n Initial node: 0, later nodes: (parent g-value)+1 –Greedy search h(n): Heuristic path cost from node n to a goal state Initial node:0, later nodes: Manhattan distance/ Misplaced Number of tiles Heuristic function for A* f(n) = g(n) + h(n) choose h(n) so that it never overestimates (admissible) A*: Next node to expand is node with lowest f(n)

Some lisp Funcall(a b c d..) calls function “a” with arguments b,c,d.. Sort(list #’< :key x) sorts the “list” in “<“ order based on the x field of each item in “list” – destructive Append(list1 list2), cond (mapcar #’(lambda (x) (op)) ‘(list)) computes op on each item of list and returns new list (**Children fn**) ‘ quote (common mistake) protects from evaluation (Make-array ‘(2 3) :initial-element 0) 2 by 3 array (Aref array x y) returns x,y the element of array Equalp (cannot be used with arrays)

A* Search Code (defun A* (nodes goalp children-fn fvalue-fn) ( cond ((null nodes) nil) ;; Return the first node if it is a goal node. ((funcall goalp (first nodes)) (first nodes)) ;; Append the children to the set of old nodes (t (A* (sort (append (funcall children-fn (first nodes)) (rest nodes)) #'< :key fvalue-fn ) goalp children-fn fvalue-fn)))) (t (let ((temp (sort (append (funcall children-fn (first nodes) (rest nodes)) #'< :key fvalue-fn ))) (A* temp ‘goalp ‘children-fn ‘fvalue-fn))))) A list of nodes (state, action, parent, g-val, h-val, f-val) Functions : goalp: Compare current state to goal-state: returns true or nil children-fn: takes parent-node and returns a list of children nodes fvalue-fn: takes a node and returns its f-value ( a one line code) A*: Good place to find the maximum length of queue

Node structure & global parameters Node –State : Could be just an array (3*3) –Parent : again a node –Action :left, right, up, down from parent (string) –G-val : parent g-val + 1 –H-val : call manhattan distance or misplaced tiles –F-val: G-val + H-val –Start node(start state, NIL, NIL, 0,0,0) Global parameters (defparameter) Number of nodes generated Number of nodes expanded Maximum size of queue Goal state

goalp Goalp (state) –Compare state with goal (global) –Do NOT use equalp –Loop for each element in state to compare with corresponding element in goal state – generalize and write “equal-state” to compare any two states – return true / NIL (return-from)

Children Fn & puzzle children You have left-child, similarly right, up, down child puzzle children will call each of them on a given state (append left right down up) Good place to keep track of number of nodes generated and expanded

Heuristics Manhattan –for each element a at (x,y) in “state” Find position (another function) of a in goal state Say (x1,y1) Find (abs(x-x1)+abs(y-y1)) Number of misplaced tiles – modification of goalp – whenever 2 corresponding elements are not equal, increment a counter initially set to 0

Possible Order in writing functions Goalp Right, up, down children Children-fn Heuristics A* Then statistics