410 likes | 452 Views
Informed search algorithms. CSC 450 - AI. Outline. Heuristics Best-first search Greedy best-first search A * search Heuristics properties. Motivation. Uninformed Search Strategies can find solutions to problems by Systematically generating new states Testing them against the goal
E N D
Informed search algorithms CSC 450 - AI
Outline • Heuristics • Best-first search • Greedy best-first search • A* search • Heuristics properties
Motivation • Uninformed Search Strategies can find solutions to problems by • Systematically generating new states • Testing them against the goal • Incredibly inefficient in most cases. They will lead away from the goal as easily as it pursues options that lead towards the goal. • Informed Search Strategies • Uses problem-specific knowledge • Can find solutions more efficiently
Heuristics • From Greek heuriskein, “to find”. • Of or relating to a usually speculative formulation serving as a guide in the investigation or solution of a problem. • Computer Science: Relating to or using a problem-solving technique in which the most appropriate solution, of several found by alternative methods, is selected at successive stages of a program for use in the next step of the program.
Heuristic search • Introduction: • Al problem solvers employ heuristics in two situations:- • First: A problem may not have an exact solution, because of inherent ambiguities in the problem statement or available data. • Medical diagnosis is an example of this. A given set of symptoms may have several possible causes. Doctors use heuristics to chose the most likely diagnosis and formulate a plan of treatment.
Heuristic search • Introduction: • Al problem solvers employ heuristics in two situations:- • First: A problem may not have an exact solution, because of inherent ambiguities in the problem statement or available data. • Vision is another example of an inherently inexact problem. • Visual scenes are often ambiguous, allowing multiple interpretations of the connectedness, extent and orientation of objects.
Heuristic search • Introduction: • ALL problem solvers employ heuristics in two situations:- • First: A problem may not have an exact solution, because of inherent ambiguities in the problem statement or available data. • Optical illusions exemplify these ambiguities. • Vision systems use heuristics to select the most likely of several possible interpretations of a given scene.
Heuristic search • Introduction: • Al problem solvers employ heuristics in two situations:- • Second: A problem may have an exact solution, but the computational cost of finding it may be prohibitive. • In many problems, state space growth is combinatorically explosive, with the number of possible states increasing exponentially or factorially with the depth of the search.
Heuristic search • Introduction: • Al problem solvers employ heuristics in two situations:- • Second: A problem may have an exact solution, but the computational cost of finding it may be prohibitive. • Heuristic search handles above problem by guiding the search along the most “promising” path through the space.
Heuristic search • Introduction: • Al problem solvers employ heuristics in two situations:- • Second: A problem may have an exact solution, but the computational cost of finding it may be prohibitive. • By eliminating unpromising states and their descendants from consideration, a heuristic algorithm can defeat this combinatorial explosion and find an acceptable solution.
Heuristic search • Introduction: • Heuristics and the design of algorithms to implement heuristic search have been an important part of artificial intelligence research. • Game playing and theorem proving require heuristics to reduce search space to simplify the solution finding.
Heuristic search • Introduction: • Heuristics are fallible. • A heuristics is only an informed guess of the next step to be taken in solving a problem. It is often based on experience or intuition. • Heuristics are seldom able to predict the exact behavior of the state space farther along in the search. • A heuristics can lead a search algorithm to a sub optimal solutions. • At times a heuristic method may fail to find any solution at all.
Heuristic search strategies • Informedsearchtriestoreducetheamountof searchthatmustbedoneby: • Makingintelligentchoicesforthenodesthatare selectedforexpansion • Thisimpliestheexistenceofsomewayofevaluating thelikelihoodthatagivennodeisonthe solutionpath • In general this is done using a heuristic function
Best-first search • Idea: use an evaluation functionf(n) for each node • f(n) provides an estimate for the total cost. • Expand the node n with smallest f(n). • Implementation: Order the nodes in fringe increasing order of cost. • Special cases: • greedy best-first search • A* search
Best-first search algorithms with different evaluation functions Breadth-first search is a best-first search with: • f(n)=depth(n) • Depth-first search is best-first search with: • f(n)=-depth(n) • A key component of best-first-search algorithms is a heuristic function, denoted: • h(n)=estimated cost of the cheapest path from node n to a goal node • A heuristic function h(n) takes a node as input, but it depends only on the state at that node.
Greedy best-first search • Greedy best-first search tries to expand the node that is closest to the goal, on the grounds that this is likely to lead to a solution quickly. • f(n) = h(n) : estimate of cost from n to goal • e.g., f(n) = hSLD(n) straight-line distance from n to Bucharest • Greedy best-first search expands the node that appears to be closest to goal.
Greedy algorithms • A greedy algorithm follows the “eat dessert first, since you never know if you will get to finish your meal” mantra. That is, we make the best local decisions without worrying about the future (or what Mom will say if you eat dessert before finishing your broccoli). • Greedy best-first search expands the node that appears to be closest to goal.
Greedy Best-First Search example • hSLD(n)=straight-line distance from n to Bucharest. • The values of hSLD cannot be computed from the problem description itself. • It takes a certain amount of experience to know that hSLD is correlated with actual road distances and is, therefore, a useful heuristic,
GBFS is not complete d c g b a goal state start state f(n) = straightline distance
Properties of greedy best-first search • Complete? No – can get stuck in loops. • Time?O(bm), but a good heuristic can give dramatic improvement • Space?O(bm) - keeps all nodes in memory • Optimal? No e.g. AradSibiuRimnicu VireaPitestiBucharest is shorter!
Properties of greedy best-first search • Greedy best-first search resembles depth-first search in the way it prefers to follow a single path all the way to the goal, but will back up when it hits a dead hit. • The algorithm suffers from the same defects as depth-first search – it is not optimal, and it is incomplete.
A* search • Idea: avoid expanding paths that are already expensive • Evaluation function f(n) = g(n) + h(n) • g(n) = cost so far to reach n • h(n) = estimated cost from n to goal • f(n) = estimated total cost of path through n to goal • Best First search has f(n)=h(n) • Uniform Cost search has f(n)=g(n)
Admissible heuristics • A heuristic h(n) is admissible if for every node n, h(n) ≤ h*(n), where h*(n) is the true cost to reach the goal state from n. • An admissible heuristic never overestimates the cost to reach the goal, i.e., it is optimistic • Example: hSLD(n) (never overestimates the actual road distance) • Theorem: If h(n) is admissible, A* using TREE-SEARCH is optimal
Admissible heuristics E.g., for the 8-puzzle: • h1(n) = number of misplaced tiles • h2(n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) • h1(S) = ? • h2(S) = ?
Admissible heuristics E.g., for the 8-puzzle: • h1(n) = number of misplaced tiles • h2(n) = total Manhattan distance (i.e., no. of squares from desired location of each tile) • h1(S) = ? 8 • h2(S) = ? 3+1+2+2+2+3+3+2 = 18
Dominance • If h2(n) ≥ h1(n) for all n (both admissible) • then h2dominatesh1 • h2is better for search: it is guaranteed to expand less or equal nr of nodes. • Typical search costs (average number of nodes expanded): • d=12 IDS = 3,644,035 nodes A*(h1) = 227 nodes A*(h2) = 73 nodes • d=24 IDS = too many nodes A*(h1) = 39,135 nodes A*(h2) = 1,641 nodes
Relaxed problems • A problem with fewer restrictions on the actions is called a relaxed problem • The cost of an optimal solution to a relaxed problem is an admissible heuristic for the original problem • If the rules of the 8-puzzle are relaxed so that a tile can move anywhere, then h1(n) gives the shortest solution • If the rules are relaxed so that a tile can move to any adjacent square, then h2(n) gives the shortest solution
Consistent heuristics • A heuristic is consistent if for every node n, every successor n' of n generated by any action a, h(n) ≤ c(n,a,n') + h(n') • If h is consistent, we have f(n’) = g(n’) + h(n’) (by def.) = g(n) + c(n,a,n') + h(n’) (g(n’)=g(n)+c(n.a.n’)) ≥ g(n) + h(n) = f(n) (consistency) f(n’) ≥ f(n) • i.e., f(n) is non-decreasing along any path. • Theorem: If h(n) is consistent, A* using GRAPH-SEARCH is optimal It’s the triangle inequality ! keeps all checked nodes in memory to avoid repeated states
Properties of A* • Complete? Yes (unless there are infinitely many nodes with f ≤ f(G) , i.e. step-cost > ε) • Time/Space? Exponential Keeps all nodes in memory • Optimal? Yes
Optimality of A* (proof) • Suppose some suboptimal goal G2has been generated and is in the fringe. Let n be an unexpanded node in the fringe such that n is on a shortest path to an optimal goal G. • f(G2) = g(G2) since h(G2) = 0 • f(G) = g(G) since h(G) = 0 • g(G2) > g(G) since G2 is suboptimal • f(G2) > f(G) from above • h(n) ≤ h*(n) since h is admissible (under-estimate) • g(n) + h(n) ≤ g(n) + h*(n) from above • f(n) ≤ f(G) since g(n)+h(n)=f(n) & g(n)+h*(n)=f(G) • f(n) < f(G2) from We want to prove: f(n) < f(G2) (then A* will prefer n over G2)