Aug 29, 2003 ------------- - Recap goal-based agents: they - formulate goal (Goal Formulation) - formulate state, actions/operators (Problem Formulation) - try to achieve goal (Search) - Search - ubiquitous in AI - need a good understanding of it before moving onto other topics - Example search problems - channel surfing - 8-queens problem - 8-puzzle problem - traveling salesperson problem (TSP) - Formalizing a search problem GIVEN: - what is the start state? - what are the available operators? - what is the goal test? - i.e., how do you know you have succeeded? - "are we there yet?" FIND: a path/state that satisfies the goal test OPTIONAL and that is optimal - Revisiting the problems - goal is a state - channel surfing - 8-queens problem - goal is a path - 8-puzzle problem - goal is an optimal path - TSP - Two basic uninformed search methods - breadth first search (BFS) - uniform cost search (UCS) - Pseudocode for generic search algorithm - written very carefully! watch out! - Breadth first search - expand nodes of one level completely before moving to the next - time complexity - nodes expanded: O(b^d) - nodes generated: O(b^(d+1)) - space complexity - nodes expanded: O(b^d) - nodes generated: O(b^(d+1)) - complete?: yes - i.e., guaranteed to find a solution - finds optimal solution?: yes - because nodes at lower depths are expanded before ones at higher depths - Note: memory requirement is killing! - In the above - b: branching factor - d: depth at which solution is found - BFS assumptions - equates cost to depth - what if different edges in the search tree have different costs? - Solution: uniform cost search (UCS) - expand nodes based on cost - has a tendency to flip-flop its way - path costs must be non-decreasing down the tree, for UCS to make sense - easy to get by making the min. cost to be a small positive number - has same worst-case time and space complexity as BFS - Data structure support for search algorithms - BFS: use queue - UCS: use priority queue - Next class - DFS: uses a stack!