search problem

Search problems

consist

  1. a state space: all possilbel states in the world
    world state: all info about the state in the world
    search state: only info needed for planning
    e.g. Pacman pathing / pacman eating dots
  2. successor/result function:
    input: action,state
    output: successor state,cost
  3. start state: agent exist initially
  4. goal test: whether ends

一些概念

plan: a path from the start state to the goal state(search problem 的目标)
strategy: state 的考虑/搜索顺序 e.g. DFS,BFS

state space size

fundamental enumerate principle: variable domains‘ size multiply together
如果我们有n个变量,每个变量的domain大小分别为 x 1 , x 2 , x 3 , ⋯ x_1,x_2,x_3,\cdots x1,x2,x3,
那么状态空间的大小 x 1 ∗ x 2 ∗ ⋯ x_1*x_2*\cdots x1x2

state space graphs and search trees(搜索问题的图表示)

state space graphs

  1. node: states
  2. directed edge: actions,cost
    weight: the cost of actions(和边相关)
    each state only occurs once

search trees:

node show plans from the root to achieve the node
root node: start state
children: successors
states cans occur many times
search trees are greater or equal size to the state space graphs
很多时候(循环),我们没有办法建立整个搜索树
successor function: only save the states we are working with, and use the successor function to compute new ones(节省存储空间)

注: goal test 很多时候就是一个terminal nodes的集合

搜索图和搜索树都太大而不能全部存储

uninformed search

fringe: the observed but unvisited node
expand: pop a node from the fringe
generate: get neighbors of the popped node
stategy: 先pop什么节点在这里插入图片描述

search algorithm properties:

  1. completeness: guarantee to find a solution
  2. optimal: find the lowest cost path
  3. time complexity: generate nodes
  4. space complexity:store nodes(size of fringe)
    branching factor b , 树的最大深度 m , 最优solution的深度 s
    o ( b m ) o(b^m) o(bm)nodes in a tree

depth first search

strategy: expand the deepest node first
implementation: fringe is LIFO stack
property:

  1. completeness:❌ m can be infinite(循环) 永远找不到解
  2. optimal:❌ find the depth path
  3. time complexity: exploring the whole tree o ( b m ) o(b^m) o(bm)才能找到解
  4. space complexity: o ( b m ) o(bm) o(bm)每层只扩展b个因子

breadth first search

strategy: expand the shallowest node first
implementation: fringe is FIFO stack(queue)
property:

  1. completeness:✅
  2. optimal: ✅前提不考虑每次拓展的cost,认为每个edge cost一致
  3. time complexity: exploring the whole tree o ( b s ) o(b^s) o(bs)
  4. space complexity: o ( b s ) o(b^s) o(bs)

expand 结束 do the goal test:
time complexity: o ( b s + 1 ) o(b^{s+1}) o(bs+1)
space complexity: o ( b s + 1 ) o(b^{s+1}) o(bs+1)

bfs robust but need more storage spaces

iterative deepening:
run a dfs with a depth limited 1,if no solution run a dfs with a depth limited 2
expand more nodes than bfs:
b , b + b 2 , b + b 2 + b 3 = b d + ( d − 1 ) b 2 + ⋯ = o ( b d ) b,b+b^2,b+b^2+b^3=bd+(d-1)b^2+\cdots=o(b^d) b,b+b2,b+b2+b3=bd+(d1)b2+=o(bd)
save storage space: o ( b d ) o(bd) o(bd)

uniform cost search

strategy: expand the lowest cost node first
implementation: fringe is priority queue (heap)
weight : path cost from the start node to the node or backward cost of v
从根节点扩展到该节点的开销
property:

  1. completeness:✅
  2. optimal: ✅(前提edge cost 不为负)如果有环就会导致来回走
    assume edge costs not negative
  3. time complexity: optimal path costs: C ∗ C^* C,least arc cost ϵ \epsilon ϵ o ( b C ∗ / ϵ ) o(b^{C^*/\epsilon}) o(bC/ϵ)
    expand 所有比cheapest goal浅的节点
  4. space complexity: o ( b s ) o(b^s) o(bs) o ( b C ∗ / ϵ ) o(b^{C^*/\epsilon}) o(bC/ϵ)

sum up

uninformed searchcompletenessoptimaltime complexityspace complexity
bfs o ( b s ) o(b^s) o(bs) o ( b s ) o(b^s) o(bs)
dfs o ( b m ) o(b^m) o(bm) o ( b m ) o(bm) o(bm)
ucs o ( b C ∗ / ϵ ) o(b^{C^*/\epsilon}) o(bC/ϵ) o ( b C ∗ / ϵ ) o(b^{C^*/\epsilon}) o(bC/ϵ)

informed search

我们可以知道一点离目标state多近的信息

Heuristics Function

估计当前state与目标state的距离cost
Heuristics Function
input: state
output: the estimate of the distance between state to the goal state
usually want a lower bound
一般要比真实的少一点
用一个relaxed problem去估计启发式函数

greedy search

description: expand the node with lowest heuristics value
fringe: prioritiy queue (estimate forward value)
property:

  1. completeness:not guaranteed
  2. optimal: not guaranteed
    主要取决于启发式函数的选择,有可能直接找到路径,也有可能永远找不到

A* search

description: expand the node with lowest total estimated cost
fringe: prioritiy queue (estimate total value)
f ( n ) = g ( n ) + h ( n ) f(n)=g(n)+h(n) f(n)=g(n)+h(n)
property:
3. completeness:✅
4. optimal: ✅
前提,启发式函数要满足一些性质
有点:速度很快,然后可以保证完备和最优
坏的启发式会破坏: h ( n ) = 1 − g ( n ) h(n)=1-g(n) h(n)=1g(n) f ( n ) = 1 f(n)=1 f(n)=1
对于边cost不一致的情况,会被破坏掉

Admissiblity and consistency

admissible: 0 ≤ h ( n ) ≤ h ∗ ( n ) 0\leq h(n)\leq h^*(n) 0h(n)h(n)
$ h^*(n)$到达goal state的最小值
theorem: for a given search problem, if the admissibility constraint is satisfied by a heuristic function h, using A ∗ A^* A tree search will yield an optimal solution.
proof:
A is the optimal goal state, B is a suboptimal goal state;n(include A) are ansesters of A, we claim that n must be chosen before B

  1. g ( A ) < g ( B ) g(A)<g(B) g(A)<g(B)
  2. h ( A ) = h ( B ) = 0 h(A)=h(B)=0 h(A)=h(B)=0
  3. f ( n ) ≤ f ( A ) f(n)\leq f(A) f(n)f(A) f ( n ) = h ( n ) + g ( n ) ≤ h ∗ ( n ) + g ( n ) = g ( A ) = f ( A ) f(n)=h(n)+g(n)\leq h^*(n)+g(n)=g(A)=f(A) f(n)=h(n)+g(n)h(n)+g(n)=g(A)=f(A)
    f ( A ) < f ( B ) → f ( n ) < f ( B ) f(A)<f(B)\rightarrow f(n)<f(B) f(A)<f(B)f(n)<f(B)

how to design admissible heuristic function

  1. from a relaxed problem
  2. from a subproblem

一些不一致的启发式函数也有可能很好用,因为可能减少了计算时间
graph search:
maintain a closed set for expanded nodes to avoid expand twice
在这里插入图片描述
closed must be a set, since checking list takes o ( n ) o(n) o(n) time
completeness: if exists , will be visited
optimality:however, graph search may ruin the optimality of A ∗ A* A, even the heuristic function is admissibility
e.g.
在这里插入图片描述
consistency: ∀ A , C \forall A,C A,C h ( A ) − h ( C ) ≤ c o s t ( A , C ) h(A)-h(C)\leq cost(A,C) h(A)h(C)cost(A,C)
theorem: for a given search problem, if the consistency constraint is satisfied by a heuristic function h, using A ∗ A^* A graph search will yield an optimal solution.

proof:

h ( n ) ≤ h ( n ′ ) + c o s t ( n , n ′ ) h(n)\leq h(n')+cost(n,n') h(n)h(n)+cost(n,n)
n ′ n' n is a successor of n
f ( n ′ ) = h ( n ′ ) + g ( n ′ ) = g ( n ) + h ( n ) + c o s t ( n , n ′ ) ≥ g ( n ) + h ( n ) = f ( n ) f(n')=h(n')+g(n')= g(n)+h(n)+cost(n,n')\geq g(n)+h(n)=f(n) f(n)=h(n)+g(n)=g(n)+h(n)+cost(n,n)g(n)+h(n)=f(n)
so f(n) is nondecreasing along the path
so whenever a node is removed from the fringe, it’s optimal path has already been found
so we only need to show, optimal solution A will be found before B
h ( A ) = h ( B ) = 0 h(A)=h(B)=0 h(A)=h(B)=0
f ( A ) < f ( B ) f(A)<f(B) f(A)<f(B)

Under admissibility and consistency, h ( A ) = h ( B ) = 0 h(A)=h(B)=0 h(A)=h(B)=0
consistency implies adimissiblity
图搜索能保证 ucs的最优性和完备性,因为ucs h = 0 h=0 h=0既一致又最优

diminance

dominant ∀ n h a ( n ) ≥ h b ( n ) \forall n h_a(n)\geq h_b(n) nha(n)hb(n)
trivial heuristic: h(n)=0,reduce A ∗ A^* A to U C S UCS UCS
max of admissible heuristics is admissible
可以写多个一致或可达的启发式函数取max,仍然可以保证一致性可可达性

A ∗ A^* A的computation cost会多一些
bfs不会有cycle问题,因为我们会访问比他们的相邻节点更早,cycle会有更大的cost
图搜索不会破坏完备性,但却会破坏最优性

图搜索对于dfs
可以破掉循环,可以保证完备性
图搜索对于bfs
可以保证最优性和完备性

题目复习

A ∗ A^* A可以保证比 ucs 产生更少的nodes
注意搜索问题性质改变会导致是否能够解改变,搜索图没有办法完全决定能不能求解

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值