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 AlgorithmPropertiesRequired Parameterswhat it does with the agenda in step 4.
Breadth-First SearchUninformed, 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 SearchUninformed, Non-optimal, Incomplete Add all new paths to the FRONT of the agenda, like a stack (FILO)
Best-First SearchDepending 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-Firstf(x) to sort the entire agenda by. n = the maximum size of the agendaf(x) to sort the entire agenda by. n = the maximum size of the agendaKeep entire agenda sorted by f(x) and only keep the top n.
Hill ClimbingNon-optimal, Incomplete Like DFS with a heuristicf(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 SearchLike 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 MuseumBrutally exhaustive, Uninformed, Complete Most likely implemented using a breadth-first enumeration of all paths
Branch & BoundOptimal,g(x) = c(s, x) = the cost of path from s to node x. f(x) = g(x) + 0Sort paths by f(x)
A* w/o extended list (or B&B w/o extended list + admissible heuristic)Optimal if h is admissiblef(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 heuristicSort paths by f(x)
A* w extended listOptimal if h is consistentf(x) = g(x) + h(x) h(x) must be a consistent heuristicSort 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).

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值