Search (Artificial Intelligence)

Search is about choice

A very important principle of problem-solving. A that is that if you want to solve a problem, the easiest way to solve a problem is, usually, ask somebody who knows the answer.

Check against the Oracle.

No Oracle

Dead horse principle: don't do any repetitive work.

the shortest potential

Generic Search Algorithm

function Search(graph, start, goal):
    0. Initialize:
        agenda = [ [start] ]
        extended_list = []
    
    while agenda is not empty:
        1. path = agenda.pop(0)
        2. if is-path-to-goal(path, goal)
            return path
        3. Otherwise, extend the current path If not already extended
            for each connected node
                make a new path (don't add paths with loops)
        4. add new paths from 3 to agenda and reorganize agenda 
            (algorithms differ here to see table below)
    
    fail!
Search Algorithm Properties Required Parameters what it does with the agenda in step 4.
Breadth-First Search Uninformed, Nonoptimal (Exception: Optimal only if you are counting total path length), Complete   Add all new paths to the BACK of the agenda, like a queue (FIFO)
Depth-First Search Uninformed, Non-optimal, Incomplete   Add all new paths to the FRONT of the agenda, like a stack (FILO)
Best-First Search Depending on definition of f(x) If f(x) = h(x) (estimated distance to goal) then likely not optimal, and potentially incomplete. However, A* is a type of best First search that is complete and optimal because of its choice of f(x) which combines g(x) and h (x) (see below) f(x) to sort the entire agenda by. f(x) to sort the entire agenda by.
n-Best-First f(x) to sort the entire agenda by. n = the maximum size of the agenda f(x) to sort the entire agenda by. n = the maximum size of the agenda Keep entire agenda sorted by f(x) and only keep the top n.
Hill Climbing Non-optimal, Incomplete Like DFS with a heuristic f(x) to sort the newly added path by. 1. Keep only newly added paths sorted by f(x) 2. Add sorted new paths to the FRONT of agenda
Beam Search Like BFS but expand nodes in f(x) order. Incomplete for small k; Complete and like BFS for k = infinity. Non-optimal When k = 1, Beam search is analogous to Hill Climbing without backtracking. 1. the beam width k 2. f(x) to sort the top paths by. 1. Keep only k-top paths that are of length n. (So keep a sorted list of paths for every path length) 2. Keep only top-k paths as sorted by f (x)
British Museum Brutally exhaustive, Uninformed, Complete   Most likely implemented using a breadth-first enumeration of all paths
Branch & Bound Optimal, g(x) = c(s, x) = the cost of path from s to node x. f(x) = g(x) + 0 Sort paths by f(x)
A* w/o extended list (or B&B w/o extended list + admissible heuristic) Optimal if h is admissible f(x) = g(x) + h(x,g) h(x,g) is the estimate of the cost from x to g. h(x) must be an admissible heuristic Sort paths by f(x)
A* w extended list Optimal if h is consistent f(x) = g(x) + h(x) h(x) must be a consistent heuristic Sort paths by f(x)

Admissible Heuristic:

  • For all nodes x in Graph, h(x) <= c(n, g)
  • i.e. the heuristic is an underestimate of the actual cost/distance to the goal

Consistent Heuristic:

  • For all nodes x in Graph, h(x) n ❍ h(m) - h(n) <= c(m,n)
  • You can verify consistency by checking each edge and see if the difference between h values on an edge <= the actual edge cost.

Consistency implies Admissibility If you can verify consistency, then the heuristic must be admissible. But Admissibility does not imply Consistency!

Pathmax in a nut shell: When you are extending nodes. If you find an edge that is not consistent, i.e. h(m) - h(n) > c(m,n); make it consistent by setting the end h(n) heuristic value to h(m). Hence the difference becomes 0, which is always <= c(m,n) and consistent

Short explanation on why Admissibility must be true for A* to be optimal:

Let C* is the actual cost of the optimal path from s to g.

A* search always extend paths in order of increasing f(x), where f(x) = g(x)+h(x) You can think of A* expanding paths on a fringe. Once it has extended some path of value f(x) we are guaranteed that it has seen all paths lower than f(x). If h(x) is admissible, (i.e. h(x) is an underestimate of the actual path cost to node g) then we know that any partial path leading to the optimal path solution must have f(x) C* Because of the fringe property, such a partial paths will be visited after we visit any path with cost C*. So we will end up by either by-passing the optimal solution and/or mistaken a nonoptimal path as the solution. Consistency ensures that f(x) is always non-decreasing. That is if p_1, p_2, p_3...p_n are partial paths leading to the optimal path, a consistent heuristic ensures that f(p_1) <= f(p_2) <=....<= f(p_n). This strictly non-decreasing property or monotonicity ensures that once a node has been extended it is the absolute best f(x) path out of that node; it is safe to not visit that node again. How Different Heuristics in A* affect performance

General rule: More closely h(x) approximates the actual cost to the goal the faster A* will find the solution (or A* will do less work extending paths).

猜你喜欢

转载自blog.csdn.net/Da_tianye/article/details/82025886