330 likes | 448 Vues
This document provides a comprehensive overview of search algorithms in Artificial Intelligence, focusing on uniformed and informed search techniques. It discusses various search strategies like breadth-first search, depth-first search, and uniform-cost search, detailing their implementations, properties, and complexities, including completeness, time, and space analysis. The insights into search tree structure, node expansion, and handling of repeated states highlight the practical aspects of search problem-solving in AI. The discussion also references important algorithms from "Artificial Intelligence: A Modern Approach." ###
E N D
Introduction to Artificial IntelligenceCS 438 Spring 2008 • Today • AIMA, Ch. 3 • Uniformed Search • Next Week • AIMA, Ch. 4 • Informed Search • Home Work: • 4.1 and 4.3 “Russian researcher developed a system that can correctly identify images from Yahoo’s CAPTCHA system 35% of the time.”
Search (reminder) • Search Tree • Root is the initial state • Each expanded state is a search node • Search Node • Encodes the state, parent node, action applied, depth, and path cost • Expanding a state • Generating new states by applying possible (valid) actions to current state using the successor function S(x)
Search strategies • A search strategy is defined by picking the order of node expansion • How the IA will explore the search space • Strategies are evaluated along the following dimensions: • completeness: does it always find a solution if one exists? • time complexity: How long does it take to find a solution; measured as worst case analysis in the number of nodes generated • 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 search tree
Tree search algorithms • Basic idea
Implementation: general tree search Important: How the nodes are ordered in the fringe will determine the search strategy.
Uninformed search strategies • Uninformed search strategies use only the information available in the problem definition • Breadth-first search • Uniform-cost search • Depth-first search • Depth-limited search • Iterative deepening search
Breadth-first search • Expand shallowest unexpanded node • Why is this called “Breadth-first”? • Implementation: • fringe is a FIFO queue, i.e., new successors go at end • What is FIFO?
Properties of breadth-first search • Complete? • Yes; if b, the branching factor, is finite • Time? • 1+b+b2+b3+… +bd + (bd+1- b) = O(bd+1) • Space? • O(bd+1) (keeps every node in memory) • Optimal? • Yes: if cost = 1 per step • Space is the bigger problem (more than time)
Uniform-cost Search • Variation of Breadth-first search by expanding the node with the lowest path cost: g(n) • Implementation: • Nodes on the fringe queue are ordered by path cost
Uniform-cost search Equivalent to breadth-first if step costs all equal • Complete? • Yes, if step cost ≥ ε • What would happen if there was a zero cost action? • Time? • # of nodes with g ≤ cost of optimal solution, O(bceiling(C*/ ε)) where C* is the cost of the optimal solution • This can be much larger than bd; Why? • Space? # of nodes with g≤ cost of optimal solution, O(bceiling(C*/ ε)) • Optimal? Yes – nodes expanded in increasing order of g(n)
Depth-first Search • Expand deepest unexpanded node • Implementation: • Nodes on the fringe are ordered in a LIFO queue; new successors go to the end. • What is LIFO?
Properties of depth-first search • Complete? No • Why? • Can it be modified to be complete? • Time? • O(bm), where m is the length of the longest path: • terrible if m is much larger than d but if solutions are dense, may be much faster than breadth-first • Space? • O(bm), i.e., linear space! • Optimal? • Yes or no?
Repeated states • Failure to detect repeated states can turn a linear problem into an exponential one!
Avoiding Redundant States • Dynamic Programming Principle • When looking for the best path from S to G, ignore all paths from S to any intermediate node, K, other than the minimum-length path from S to K
Three Levels of DPP • Do not return to a state you just came from • Check parent (easiest to implement) • Do not return to a state that you have already visited along the path • Check ancestors • Do not go to any state that has already been generated before • Check all prior states • IMPORTANT: must compare path cost
General Graph search Add a closed list Fringe list is sometimes referred as the open list
Depth-limited search • A variation on depth-first search with depth limit l, • nodes at depth l have no successors • What does this solve? • Recursive implementation:
Iterative deepening depth-first search • Number of nodes generated in a depth-limited search to depth d with branching factor b: NDLS = b0 + b1 + b2 + … + bd-2 + bd-1 + bd • Number of nodes generated in an iterative deepening search to depth d with branching factor b: NIDS = (d+1)b0 + d b^1 + (d-1)b^2 + … + 3bd-2 +2bd-1 + 1bd • For b = 10, d = 5, • NDLS = 1 + 10 + 100 + 1,000 + 10,000 + 100,000 = 111,111 • NIDS = 6 + 50 + 400 + 3,000 + 20,000 + 100,000 = 123,456 • Overhead = (123,456 - 111,111)/111,111 = 11%
Properties of IDDF search • Complete? • Yes • Time? • (d+1)b0 + d b1 + (d-1)b2 + … + bd = O(bd) • Space? • O(bd) • Optimal? • Yes, if step cost = 1