Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2004.

Slides:



Advertisements
Similar presentations
Artificial Intelligent
Advertisements

Solving problems by searching Chapter 3. Outline Problem-solving agents Problem types Problem formulation Example problems Basic search algorithms.
Additional Topics ARTIFICIAL INTELLIGENCE
Review: Search problem formulation
Uninformed search strategies
Problem Solving Agents A problem solving agent is one which decides what actions and states to consider in completing a goal Examples: Finding the shortest.
1 Lecture 3 Uninformed Search. 2 Uninformed search strategies Uninformed: While searching you have no clue whether one non-goal state is better than any.
Solving Problems by Searching Currently at Chapter 3 in the book Will finish today/Monday, Chapter 4 next.
Properties of breadth-first search Complete? Yes (if b is finite) Time? 1+b+b 2 +b 3 +… +b d + b(b d -1) = O(b d+1 ) Space? O(b d+1 ) (keeps every node.
CS 480 Lec 3 Sept 11, 09 Goals: Chapter 3 (uninformed search) project # 1 and # 2 Chapter 4 (heuristic search)
G5BAIM Artificial Intelligence Methods Graham Kendall Blind Searches.
Blind Search1 Solving problems by searching Chapter 3.
Search Strategies Reading: Russell’s Chapter 3 1.
May 12, 2013Problem Solving - Search Symbolic AI: Problem Solving E. Trentin, DIISM.
1 Chapter 3 Solving Problems by Searching. 2 Outline Problem-solving agentsProblem-solving agents Problem typesProblem types Problem formulationProblem.
Solving Problem by Searching Chapter 3. Outline Problem-solving agents Problem formulation Example problems Basic search algorithms – blind search Heuristic.
Lets remember about Goal formulation, Problem formulation and Types of Problem. OBJECTIVE OF TODAY’S LECTURE Today we will discus how to find a solution.
1 Lecture 3: 18/4/1435 Uninformed search strategies Lecturer/ Kawther Abas 363CS – Artificial Intelligence.
Implementation and Evaluation of Search Methods. Use a stack data structure. 1. Push root node of tree on the stack. 2. Pop the top node off the stack.
Touring problems Start from Arad, visit each city at least once. What is the state-space formulation? Start from Arad, visit each city exactly once. What.
Artificial Intelligence for Games Uninformed search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
Artificial Intelligence (CS 461D)
Search Strategies CPS4801. Uninformed Search Strategies Uninformed search strategies use only the information available in the problem definition Breadth-first.
UNINFORMED SEARCH Problem - solving agents Example : Romania  On holiday in Romania ; currently in Arad.  Flight leaves tomorrow from Bucharest.
Artificial Intelligence Lecture No. 7 Dr. Asad Safi ​ Assistant Professor, Department of Computer Science, COMSATS Institute of Information Technology.
Artificial Intelligence for Games Depth limited search Patrick Olivier
14 Jan 2004CS Blind Search1 Solving problems by searching Chapter 3.
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
CS 380: Artificial Intelligence Lecture #3 William Regli.
Review: Search problem formulation
Searching the search space graph
Artificial Intelligence Chapter 3: Solving Problems by Searching
1 Lecture 3 Uninformed Search. 2 Complexity Recap (app.A) We often want to characterize algorithms independent of their implementation. “This algorithm.
Blind Search-Part 2 Ref: Chapter 2. Search Trees The search for a solution can be described by a tree - each node represents one state. The path from.
Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2002.
1 Lecture 3 Uninformed Search
Lecture 3 Uninformed Search.
Review: Search problem formulation Initial state Actions Transition model Goal state (or goal test) Path cost What is the optimal solution? What is the.
Search Tamara Berg CS 560 Artificial Intelligence Many slides throughout the course adapted from Dan Klein, Stuart Russell, Andrew Moore, Svetlana Lazebnik,
Artificial Intelligence
AI in game (II) 권태경 Fall, outline Problem-solving agent Search.
Vilalta&Eick:Uninformed Search Problem Solving By Searching Introduction Solutions and Performance Uninformed Search Strategies Avoiding Repeated States/Looping.
Carla P. Gomes CS4700 CS 4700: Foundations of Artificial Intelligence Prof. Carla P. Gomes Module: Search I (Reading R&N: Chapter.
Lecture 3: Uninformed Search
An Introduction to Artificial Intelligence Lecture 3: Solving Problems by Sorting Ramin Halavati In which we look at how an agent.
SOLVING PROBLEMS BY SEARCHING Chapter 3 August 2008 Blind Search 1.
A General Introduction to Artificial Intelligence.
1 Solving problems by searching Chapter 3. Depth First Search Expand deepest unexpanded node The root is examined first; then the left child of the root;
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).
Solving problems by searching 1. Outline Problem formulation Example problems Basic search algorithms 2.
1 search CS 331/531 Dr M M Awais REPRESENTATION METHODS Represent the information: Animals are generally divided into birds and mammals. Birds are further.
Uninformed search strategies A search strategy is defined by picking the order of node expansion Uninformed search strategies use only the information.
Problem Solving as Search. Problem Types Deterministic, fully observable  single-state problem Non-observable  conformant problem Nondeterministic and/or.
Uninformed Search Methods
Problem Solving by Searching
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.
Implementation: General Tree Search
Fahiem Bacchus © 2005 University of Toronto 1 CSC384: Intro to Artificial Intelligence Search II ● Announcements.
Solving problems by searching A I C h a p t e r 3.
Search Part I Introduction Solutions and Performance Uninformed Search Strategies Avoiding Repeated States Partial Information Summary.
Chapter 3 Solving problems by searching. Search We will consider the problem of designing goal-based agents in observable, deterministic, discrete, known.
Artificial Intelligence Solving problems by searching.
Lecture 3: Uninformed Search
EE562 ARTIFICIAL INTELLIGENCE FOR ENGINEERS
Uninformed Search Chapter 3.4.
Solving problems by searching
Artificial Intelligence
Principles of Computing – UFCFA3-30-1
Presentation transcript:

Introduction to Artificial Intelligence Blind Search Ruth Bergman Fall 2004

Search Strategy Partial search tree for route finding from Arad to Bucharest. Arad (a) The initial state (search node) (b) After expanding Arad (c) After expanding Sibiu Arad SibiuTimisoaraZerind Arad SibiuTimisoaraZerind AradFagarasOradea Rimnicu Vilcea goal test choosing one option Which node to expand? Which nodes to store in memory?

Search Trees Search node – book-keeping data structure used to represent the search tree –State is a configuration of the world (defstruct node state ;;; state (domain dependent) ancestor ;;; the ancestor node in the search graph f ;;; the cost of the node action ;;; the specific action that led to this node from its ) ;;; ancestor

Depth-first Search Searching Strategies Expand deepest node first. DFS (state path) if goalp(state) return path else for c in succ(state) return DFS(c, path | state)

DFS implementation in Lisp (defun dfs (node) (cond ((goalp (node-state node)) node) (t (let ((children (successor-fn node))) (dfs2 children))))) (defun dfs2 (states) ;; input list of nodes (cond ((null states) nil) ((dfs (car states))) ((dfs2 (cdr states)))))

Criteria –Completeness: if there is a solution will the algorithm find it? –Time complexity: how much time does the algorithm take to arrive at a solution, if one exists? –Space complexity: how much space does the algorithm require? –Optimality: is the solution optimal? Search Strategy Properties

In-Completeness of DFS DFS is not complete –fails in infinite-depth spaces, spaces with loops Variants –limit depth of search –avoid re-visiting nodes. –avoid repeated states along path => complete in finite spaces

DFS with depth limit (defun dfs (node depth) (cond ((goalp (node-state node)) node) ((zerop depth) nil) ((let ((children (successor-fn node))) (dfs2 children (- depth 1))))) (defun dfs2 (states depth) (cond ((null states) nil) ((dfs (car states) depth)) ((dfs2 (cdr states) depth))))

Properties –Complete: No Guaranteed to stop Complete only if exists solution at level l<d (where d is the maximum depth) –Time complexity: O(b^d) Best case l Worst case (b^(d+1)-1)/(b-1) Where b is the branching factor improved performance when there are many solutions –Space complexity: O(bd) i.e., linear space –Optimal: No DFS with depth limit Performance Searching Strategies

DFS with no revisits avoid nodes that have already been expanded. => exponential space complexity. – Not practical.

DFS with no repeated states (defun dfs (node path) (cond ((goalp (node-state node)) path) ((let ((children (successor-fn node))) (dfs2 children (cons (node-state node) path))))) (defun dfs2 (states path) (cond ((null states) nil) ((member (car states) path) nil) ((dfs (car states) path)) ((dfs2 (cdr states) path)))) => Complete in finite spaces

Backtracking Search Searching Strategies When states are expanded by applying operators The algorithm expands one child at a time (by applying one operator) If search fails, backtrack and expand other children Backtracking search results in even lower memory requirements than DFS DFS node discovery Backtracking search node discovery

Advantages –Low space complexity –Good chance of success when there are many solutions. –Complete if there is a solution shorter than the depth limit. Disadvantages –Without the depth limit search may continue down an infinite branch. –Solutions longer than the depth limit will not be found. –The solution found may not be the shortest solution. DFS Summary Searching Strategies

Breadth-first Search Searching Strategies Expand node with minimal depth. avoid revisiting nodes. Since every node is in memory, the additional cost is negligible.

BFS implementation in Lisp (defun bfs (queue) (let* ((node (car queue)) (state (node-state node))) (cond ((null queue) nil) ((goalp state) node) ((let ((children (successor-fn node))) (bfs (append (cdr queue) children)))))))

BFS Performance Searching Strategies Properties –Complete: Yes (if b is finite) –Time complexity: 1+b+b^2+…+b^l = O(b^l) –Space complexity: O(b^l) (keeps every node in memory) –Optimal: Yes (if cost=1 per step); not optimal in general where b is branching factor and l is the depth of the shortest solution

Uniform cost Search A GS C B SS SS A AA B BB C CC GGG Expand least-cost unexpanded node –the breadth-first search is just uniform cost search with f(n)=DEPTH(n) –Node discovery –Stop at first expanded goal node Searching Strategies

Uniform cost Search Properties of Uniform-Cost Search –Complete: Yes, if step cost >= e (epsilon) –Time complexity: # of nodes with f <= C* C* = cost of optimal solution Worst case O(b^(C*/e)) O(b^l) if step costs are equal –Space complexity: # of nodes with f <= C*, O(b^l) –Optimal: Yes, if step cost >= e (epsilon) Searching Strategies

Combine the best of both worlds –Depth first search has linear memory requirements –Breadth first search gives an optimal solution. Iterative Deepening Search executes depth first search with depth limit 1, then 2, 3, etc. until a solution is found. The algorithm has no memory between searches. Iterative Deepening Search Searching Strategies

Limit=0 Limit=1 Limit=2 Limit=3 Iterative Deepening Search … Searching Strategies

Properties –Complete: Yes –Time complexity: (l+1)*b^0+l*b+(l- 1)*b^2+…+1*b^l = O(b^l) –Space complexity: O(bl) –Optimal: Yes, if step cost = 1 Can be modified to explore uniform-cost tree Iterative Deepening Search Searching Strategies

Numerical demonstration: Let b=10, l=5. –BFS resource use (memory and # nodes expanded) = 111,111 –Iterative Deepening resource use Memory requirement: 10*5 = 50 # expanded nodes = 123,456 => re-searching cost is small compared with the cost of expanding the leaves Iterative Deepening Search - Discussion Searching Strategies

Simultaneously search both forward from the initial state and backward from the goal, and stop when the two searches meet in the middle. Bidirectional Search StartGoal Searching Strategies

Properties –Complete: Yes (using a complete search procedure for each half) –Time complexity: O(b^(l/2)) –Space complexity: O(b^(l/2)) –Optimal: Yes, if step cost = 1 Can be modified to explore uniform-cost tree Bidirectional Search Performance Searching Strategies

Bidirectional Search Discussion Numerical Example (b=10, l = 6) –Bi-directional search finds solution at d=3 for both forward and backward search. Assuming BFS in each half 22,200 nodes are generated. –Compare with 11,111,100 for a standard BFS. Implementation issues: –Operators are reversible. –There may be many possible goal states. –Check if a node appears in the “other” search tree. –What’s the best search strategy in each half.

–b is the branching factor; –l is the depth of solution; –m is the maximum depth of the search tree; –d is the depth limit. Comparison Search Strategies Criterion Breadth- First Uniform- Cost Depth- First Depth- Limited Iterative Deepening Bi- directional (if applicable) Timeb^l b^mb^db^lb^(l/2) Spaceb^l bmbdblb^(l/2) Optimal?Yes No Yes Complete?Yes No Yes, if d>=l Yes Searching Strategies

Herbert A reactive-based robot that collects soda cans, sometimes.

Alternate implementations of Search Algorithms Iteration Unnamed functions (lambda expressions) Mapping functions

DFS implementation in Lisp (defun dfs (state) (cond ((goalp state) (list state)) (t (do* ((children (new-states state) (cdr children))) (solution (dfs (car children)) (dfs (car children))) ((or solution (null children)) (if solution (cons state solution) nil))))))

DFS with depth limit (defun dfs-d (state depth) (cond ((goalp state) (list state)) ((zerop depth) nil) (t (do* ((children (new-states state) (cdr children))) (solution (dfs (car children) (1- depth)) (dfs (car children) (1- depth))) ((or solution (null children)) (if solution (cons state solution) nil))))))

DFS with no repeated states (defun dfs-d-g (state depth path) (cond ((goalp state) (list state)) ((zerop depth) nil) (t (do* ((children (new-states state) (cdr children))) (solution (if (member (car children) path) nil (dfs (car children) (1- depth) (cons state path)) …)) ((or solution (null children)) (if solution (cons state solution) nil)))))) => Complete in finite spaces

BFS implementation in Lisp (defun bfs (state) (let ((queue (list (list state nil)))) (do* ((state (caar queue) …) (children (new-states state) …)) ((or (null queue) (goalp state)) (if (null queue) nil (car state)) (setq queue (append (cdr queue) (mapcar #'(lambda (state) (cons state (car queue))) children)))))))