640 likes | 818 Views
Introduction to Artificial Intelligence. Uninformed Search (AIMA, Sections 3.3-3.4). Alan M Frisch, Dimitar Kazakov kazakov@cs.york.ac.uk Department of Computer Science University of York. Outline for this Topic (2 lectures). What is search? What is uninformed search?
E N D
Introduction to Artificial Intelligence Uninformed Search(AIMA, Sections 3.3-3.4) Alan M Frisch, Dimitar Kazakov kazakov@cs.york.ac.uk Department of Computer Science University of York
Outline for this Topic (2 lectures) • What is search? • What is uninformed search? • Five uniformed search algorithms • Breadth-first search (BFS) • Uniform-cost search (UCS) • Depth-first search (DFS) • Depth-limited search (DLS) • Iterative deepening search (IDS) • Handling repeated states
What Is Search? • Given a problem representation, search is the process that builds some or all of the search tree for the representation in order to do one of the following: • If the search tree has one or more goals, identify one (or all of them) and the sequence of operators that produce each. • If the search tree has one or more goals, identify a least costly one and the sequence of operators that produces it. • If the search tree is finite and does not contain a goal, recognise this.
Tree Search Algorithms • Basic idea: • offline, simulated exploration of state space by generating successors of already-explored states (a.k.a. ‘expanding’states)
Generic Search Algorithm General idea: maintain a list L containing the fringe nodes. • Set L to the list containing only the initial node of the problem representation. • While L is not empty do • Pick a node n from L. • If n is a goal node, stop and return it along with the path from the initial node to n. • Otherwise, remove n from L expand n to generate its children add to L all children of n • Return fail
Implementation: states vs. nodes • A state is a (representation of) a physical configuration • A node is a data structure constituting part of a search tree includes state, parent node, action, path cost g(x), depth • The Expand function creates new nodes, filling in the various fields and using the Successorfunction of the problem representation to create the corresponding states.
Search Algorithms: Informed vs Uninformed • Search algorithms differ by how they pick which node to expand. • Uniformed Search Algorithms: In making this decision, these look only at the structure of the search tree and not at the states inside the nodes. • AKA blind search algorithms. • This unit examines 5 of these • Informed Search Algorithms: In making this decision these look at the states inside the nodes. • AKA heuristic search algorithms. • Unit 6 (Advanced Search) examines these.
Evaluating Search Strategies • Strategies are evaluated along the following dimensions: • completeness: does it always find a solution if one exists? • time complexity: number of nodes generated(not expanded) • space complexity: maximum number of nodes in memory • optimality: does it always find a least-cost solution? • Time and space complexity are measured in terms of • b: maximum branching factor of the search tree • d: depth of the least-cost solution (root is depth 0) • m: maximum depth of the state space (may be ∞)
Breadth-First Search • Expand shallowest unexpanded node
Breadth-First Search: Implementation • Expand shallowest unexpanded node • Implementation: ?
Breadth-First Search: Implementation • Expand shallowest unexpanded node • Implementation: fringe is a FIFO queue, so new nodes go at end, nodes selected from front
Properties of breadth-first search if b is constant • Complete? Yes (if b is finite) • Time? 1+b+b2+b3+… +bd = O(bd+1) = O(b. bd) = O(bd) • Space? O(bd+1) or O(bd) - if only fringe is in memory • Optimal? Yes, if all operators have the same cost. • Space is the bigger problem (more than time) What if we want to find the optimal solution and operators have different costs?
Uniform-cost search • Expand least-cost unexpanded node • Implementation?
Uniform-cost search • Expand least-cost unexpanded node • Implementation:fringe is queue ordered by increasing path cost. Nodes selected from front.
Properties of Uniform-cost search • Equivalent to breadth-first if step costs all equal • Complete? Yes, if step cost ≥ ε • Time? # of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε)) where C* is the cost of the optimal solution. Or O(bd). • Space? # of nodes with g≤ cost of optimal solution, O(bceiling(C*/ ε)). Or O(bd). • Optimal? Yes, since nodes are expanded in increasing order of g(n)
Depth-first search • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-First Search: Example • Expand deepest unexpanded node
Depth-first search: Implementation • Expand deepest unexpanded node • Implementation: ?
Depth-first search: Implementation • Expand deepest unexpanded node • Implementation: Fringe is a LIFO queue, so new nodes are put at front and nodes removed from front.
Properties of depth-first search • Complete? No: could run forever without finding solution in trees with infinite-depth. Complete in finite spaces. • Time?O(bm): terrible if m is much larger than d (especially if m = ∞) • but if solutions are dense, may be much faster than breadth-first • Space?O(bm), i.e., linear space! • Optimal? No
Depth-limited search • depth-first search with depth limit l. That is, nodes whose depth is greater than l are ignored. • Implementation: same as depth-first search but if a node has depth l then it is not expanded.
Properties of depth-limited search • Complete?No: solution not found if d>l • Time? O(bl) • Space? O(bl), i.e., linear space! • Optimal? No.
Iterative deepening search • To overcome incompleteness of depth-limited search, if no solution is found, redo the search with an increased depth limit. • Implementation: set l to 0 do perform depth-limited search with limit l increment l until solution found or no nodes at depth l have children