Problem solving and search Recall Problem solving Goal
Problem solving and search
Recall Problem solving: Goal formulation Problem formulation (states, operators) Search for solution Problem formulation: Initial state Operators Goal test Path cost Problem Types: Single State Multiple State Contingency Exploration : accessible and deterministic environment : inaccessible and nondeterministic environment : unknown state space
Recall : Finding a solution Solution: is a sequence of operators that bring you from current state to the goal state Basic idea: offline, systematic exploration of simulated state-space by generating successors of explored states (expanding) Function General-Search(problem, strategy) returns a solution, or failure initialize the search tree using the initial state problem loop do if there are no candidates for expansion then return failure choose a leaf node for expansion according to strategy if the node contains a goal state then return the corresponding solution else expand the node and add resulting nodes to the search tree end Strategy: The search strategy is determined by the order in which the nodes are expanded.
Recall : Evaluation of search strategies A search strategy is defined by picking the order of node expansion. � � Search criteria: ◦ ◦ � ◦ ◦ ◦ algorithms are commonly evaluated according to the following four Completeness: does it always find a solution if one exists? Time complexity: how long does it take as function of num. of nodes? Space complexity: how much memory does it require? Optimality: does it guarantee the least-cost solution? Time and space complexity are measured in terms of: b – max branching factor of the search tree d – depth of the least-cost solution m – max depth of the search tree (may be infinity)
Recall : Uniformed search strategies Use only information available in the problem formulation • Breadth-first • Uniform-cost • Depth-first • Depth-limited • Iterative deepening
Heuristic search Informed Search Use heuristics to guide the search Greedy Best-First A* Memory-bounded heuristic search Heuristics Functions
Review: Tree search A strategy is defined by picking the order of node expansion
Best-first search � Idea: use an evaluation function for each node ◦ estimate of “desirability” Expand most desirable unexpanded node. � Implementation: fringe is a queue sorted in decreasing order of desirability � Special cases: greedy search A* search
Romania with step costs in km
Greedy search � Evaluation function h(n) (heuristic) � = estimate of cost from n to closest goal For example: h. SLD(n) = straight-line distance from n to Bucharest Greedy search expands first the node that appears to be closest to the goal, according to h(n). �
Greedy search example
Greedy search example
Greedy search example
Greedy search example
Properties of greedy search • Complete? ? No-can get stuck in loops, e. g. , Iasi Neamt Complete in finite space with repeated-state checking • Time? ? O(bm), but a good heuristic can give dramatic improvement • Space? ? O(bm), keeps all nodes in memory • Optimal? ? No
A* search Idea: avoid expanding paths that are already expensive evaluation function: f(n) = g(n) + h(n) where: • g(n) – cost so far to reach n • h(n) – estimated cost to goal from n • f(n) – estimated total cost of path through n to goal A* search uses an admissible heuristic, that is, h(n) ≤ h*(n) where h*(n) is the true cost from n. For example: h. SLD (n) never overestimates actual road distance. Theorem: A* search is optimal
A* search example
A* search example
A* search example
A* search example
A* search example
A* search example
When should A* terminate? • Should we stop when we en-queue a goal? • No: only stop when we de-queue a goal
Optimality of A* (standard proof) • Suppose some suboptimal goal G 2 has been generated and is in the queue. Let n be an unexpanded node on a shortest path to an optimal goal G 1.
Properties of A* Complete? Yes, unless there are infinitely many nodes with f ≤ f(G) Time? Exponential in [relative error in h x length of soln. ] Space? Keeps all nodes in memory. Optimal? Yes – cannot expand fi+1 until fi is finished. A* expands all nodes with f(n) < C* A* expands some nodes with f(n) = C* A* expands no nodes with f(n) > C*
Proof of lemma: Consistency A heuristic is consistent if h(n) ≤ c(n, a, n’) + h(n’) If h is consistent, we have f(n’) = g(n’) + h(n’) = g(n) + c(n, a, n’) + h(n’) ≥ g(n) + h(n) = f(n) I. e. , f(n) is non-decreasing along any path.
Admissible heuristics E. g. , for the 8 -puzzle: h 1(n) = number of misplaced tiles h 2(n) = total Manhattan distance (i. e. , no. of squares from desired location of each tile) h 1(S) =? ? h 2(S) =? ?
Admissible heuristics E. g. , for the 8 -puzzle: h 1(n) = number of misplaced tiles h 2(n) = total Manhattan distance (i. e. , no. of squares from desired location of each tile) h 1(S) = 6 h 2(S) = 4+0+3+3+1+0+2+1 = 14
Dominance
Relaxed problems Admissible heuristics can be derived from the exact solution cost of a relaxed version of the problem If the rules of the 8 -puzzle are relaxed so that a tile can move anywhere, then h 1(n) gives the shortest solution If the rules are relaxed so that a tile can move to any adjacent square, then h 2(n) gives the shortest solution Key point: the optimal solution cost of a relaxed problem is no greater than the optimal solution cost of the real problem
Relaxed problems contd. Well-known example: travelling salesperson problem (TSP) Find the shortest tour visiting all cities exactly once Minimum spanning tree can be computed in O(n 2) and is a lower bound on the shortest (open) tour
Summary Heuristic functions estimate costs of shortest paths Good heuristics can dramatically reduce search cost Greedy best-first search expands lowest h incomplete and not always optimal A search expands lowest g + h complete and optimal also optimally efficient (up to tie-breaks, forward search) Admissible heuristics can be derived from exact solution of relaxed problems
- Slides: 33