Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 2-2CS250: Intro to AI/Lisp Implementing Search Lecture 2-2 January 14 th /19 th, 1999 CS250.

Similar presentations


Presentation on theme: "Lecture 2-2CS250: Intro to AI/Lisp Implementing Search Lecture 2-2 January 14 th /19 th, 1999 CS250."— Presentation transcript:

1 Lecture 2-2CS250: Intro to AI/Lisp Implementing Search Lecture 2-2 January 14 th /19 th, 1999 CS250

2 Lecture 2-2CS250: Intro to AI/Lisp 8-Puzzle States? Operators? Goal test? Path cost?

3 Lecture 2-2CS250: Intro to AI/Lisp 8-Queens Place 8 queens on a chess board, with no one attacking any other Goal test? Path cost? States Operators?

4 Lecture 2-2CS250: Intro to AI/Lisp Cryptarithmetic Puzzles with numbers replaced by letters FORTY + TEN ===== SIXTY

5 Lecture 2-2CS250: Intro to AI/Lisp Missionaries & Cannibals Three missionaries and three cannibals wish to cross a river in a boat that won’t hold all three States? Operators? Goal test? Path cost?

6 Lecture 2-2CS250: Intro to AI/Lisp Real-World Problems Route finding TSP VLSI Robot navigation Paint booth scheduling

7 Lecture 2-2CS250: Intro to AI/Lisp Search Trees

8 Lecture 2-2CS250: Intro to AI/Lisp What’s in a Node? State - what state are we in? Parent - Which node generated the current node? Operator - Action which generated node from parent Node depth - Number of nodes from root Cost - Path cost from initial node

9 Lecture 2-2CS250: Intro to AI/Lisp Lieutenant Node & General Search function GENERAL-SEARCH(problem, QUEUEING-FN) returns solution or failure nodes  MAKE-QUEUE(MAKE-NODE(INITIAL-STATE[problem])) loop do if nodes is empty then return failure node  REMOVE-FRONT(nodes) if GOAL-TEST[problem] applied to STATE(node) succeeds then return node nodes  QUEUING-FN(nodes, EXPAND(node, OPERATORS[problem])) end

10 Lecture 2-2CS250: Intro to AI/Lisp Coding Goals Create the initial node list –Need the right ordering Write a loop If test Functions for: –QUEUEING-FN, REMOVE-FRONT, GOAL-TEST, EXPAND, MAKE-NODE

11 Lecture 2-2CS250: Intro to AI/Lisp In Lisp... (defun general-search (problem queuing-fn) "Expand nodes according to the specification of PROBLEM until we find a solution or run out of nodes to expand. The QUEUING-FN decides whichnodes to look at first. [p 73]” (let ((nodes (make-initial-queue problem queuing-fn)) node) (loop (if (empty-queue? nodes) (RETURN nil)) (setq node (remove-front nodes)) (if (goal-test problem (node-state node)) (RETURN node)) (funcall queuing-fn nodes (expand node problem)))))

12 Lecture 2-2CS250: Intro to AI/Lisp A Few Lisp Ends (setq var1 form1 var2 form2...) return terminates a loop and returns the value of the specified expression as the value of the loop special form: A list (but not a macro), which is a form with special syntax or special evaluation rules or both, possibly manipulating the evaluation environment or control flow or both. The first element of a special form is a special operator.

13 Lecture 2-2CS250: Intro to AI/Lisp Dumb & Smart Searching Does the search algorithm use information beyond GOAL-TEST? –Uninformed/blind searching does not –Informed/heuristic search does

14 Lecture 2-2CS250: Intro to AI/Lisp Factors in Search Strategy Completeness - Are we guaranteed to find a solution, if one exists? Time complexity - How long does it take? Space complexity - How much memory? Optimality - Find the best of several solutions?

15 Lecture 2-2CS250: Intro to AI/Lisp Different Strokes for Different Searches Why is GENERAL-SEARCH general?

16 Lecture 2-2CS250: Intro to AI/Lisp Breadth-First Search Go sideways before you go down –How do we do this in GENERAL- SEARCH? How good is it? –Completeness? –How long does it take? –How much memory? –Optimality?

17 Lecture 2-2CS250: Intro to AI/Lisp Uniform Cost BFS: No shorter path is a solution, but what about cost? Uniform cost expands the lowest cost node When is BFS also uniform? g(node) = DEPTH(node)

18 Lecture 2-2CS250: Intro to AI/Lisp Depth-first Search Go down before you go sideways Saves memory over BFS - why? How good is it? –Completeness? –How long does it take? –Optimality? Depth-limited search

19 Lecture 2-2CS250: Intro to AI/Lisp Iterative Deepening Search Repeated depth-limited search –Depth 0, depth 1, depth 2, … Same states expanded multiple times –Higher branching factors make repeated expansion less important How good is it? Good choice when: –Big search space – Unknown solution depth

20 Lecture 2-2CS250: Intro to AI/Lisp Bidirectional Search Start from the beginning and the end, meet in the middle Divide and conquer –Cut the depth of each search in half –From O(b d ) to O(2b d/2 ) –For b = 10, d = 6: BFS searches1,111,111 Bidirectional searches2,222

21 Lecture 2-2CS250: Intro to AI/Lisp Sounds Great, Where do I Sign Up? Searching backwards? Calculating predecessors can be tricky Many goal states are a problem Generate a node and ask, “Is it in the other half of the tree?” Different halves can have different searches

22 Lecture 2-2CS250: Intro to AI/Lisp Search Comparison d= depth of the goal m= max tree depth l= depth limit

23 Lecture 2-2CS250: Intro to AI/Lisp And the Winner is... Depth-first iterative deepening –Asymptotically optimal in time –Asymptotically optimal in space among blind searches that find optimal solutions

24 Lecture 2-2CS250: Intro to AI/Lisp Constraint Satisfaction Search Constraint Satisfaction Problem (CPS): additional structural properties –States are values of a set of variables –Goal test specifies constraints on variable values Unary - cryptarithmetic Binary - 8-Queens 3rd and higher-order Absolute or just nice to have

25 Lecture 2-2CS250: Intro to AI/Lisp Why Bother? Less general than the notion of ‘problem’ More efficient algorithms –Constraints are fine-grained

26 Lecture 2-2CS250: Intro to AI/Lisp Domains Variables V i have domains, D i Discrete or continuous?

27 Lecture 2-2CS250: Intro to AI/Lisp AIMA Code (for homework) Code from AIMA /courses/current/CS250/Code/AIMA/doc/overview.html


Download ppt "Lecture 2-2CS250: Intro to AI/Lisp Implementing Search Lecture 2-2 January 14 th /19 th, 1999 CS250."

Similar presentations


Ads by Google