C-盲目搜索-人工智能(AI)
合集下载
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Breadth-First Strategy
新生成的节点放到FRING E队列的最后
1
广度优先策略
2
4 5 6
3
7
FRINGE = (4, 5, 6, 7)
24
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Important Parameters
1)所有状态中的最大后继函数个数 搜索树的分支因子 b
A solution is a sequence of actions leading from the initial state to a goal state
6
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Tree search example
Arad Zerind
Sibiu
Timisoara
关描述信息来确定FRINGE队列的排序,而 只根据搜索树中节点的位置来进行搜索
盲目 vs. 启发式策略
启发式或(有信息) 策略利用状态的有关
描述信息来确定FRINGE队列的排序(最有 “希望”的节点被放在FRINGE队列的开始)
16
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Example
2
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
秀灵路明秀路口 衡阳路友爱路口
大学路明秀路口
衡阳路秀灵路口
衡阳路北大路口
中华路友爱路口 中华路朝阳路口 人民路友爱路口
北大路中华路口 明秀路新阳路口 新阳路龙腾路口 新阳中华路口 新阳路北大路口
人民朝阳路口
3
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Example: route-finding problem
On holiday in Romania; currently in Arad. Flight leaves tomorrow from Bucharest Formulate goal: be in Bucharest Formulate problem: states: various cities actions: drive between cities Find solution: sequence of cities, e. g., Arad, Sibiu, Fagaras, Bucharest
8 3 5 2 4 1 8 3 5 4 1 6
6
7
若状态允许重复访问,则即使状态空间 有限,搜索树也将会是无限的
2 7 6 3 5
8
4 1
2
7 6
8 4 3 5 1ቤተ መጻሕፍቲ ባይዱ
2
7 6
8 2 3 4 7 5 1
10
6
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Data Structure of a Node
Evaluation
b: 分支因子 d: 最浅目标节点的深度 广度优先搜索: • 完备 Complete • 最优 若每一步的耗散为1 生成的节点个数: ???
评价
26
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Evaluation
b: 分支因子 d: 最浅目标节点的深度 广度优先搜索: • 完备 Complete • 最优 若每一步的耗散为1 生成的节点个数:
8 2 3 4 7 5 1 6
记录 子节点 CHILDREN 状态 STATE 父节点 PARENT-NODE
一个节点的数据结构
动作 深度
右移 5 5
yes
...
路径耗散
已扩展?
一个节点N的深度=从根节点到N的路径长度 (根节点的深度为0)
11
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Breadth-First Strategy
新生成的节点放到FRING E队列的最后
1
广度优先策略
2
4 5 6
3
7
FRINGE = (1)
21
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Breadth-First Strategy
新生成的节点放到FRING E队列的最后
1
广度优先策略
搜索算法
#2
14
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Performance Measures
完备性 Completeness
一个搜索问题只要有解,搜索算法就一定能找到 解的路径,则称该搜索算法是完备的
[那么当问题无解的时候,将会怎样呢?]
搜索算法性能评价
最优性 Optimality
STATE
N1
而启发式策略 会计算节点状 态与目标状态相比较,不在位 的数码牌个数,认为N2比N1更 有希望(达到目标)
1 2 5 3 6
1
2
3
STATE
4 N2
4
7
5
8 6
7
8
Goal state
18
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
说明
一些搜索问题,比如(n2-1)-puzzle ,是NPhard问题 这类问题的计算量至少为指数层次 ,没有人 能够将这类问题的计算量降低到方次层次
8 2
搜索节点状态
3 4 7 5 1
8 3 5 2 4 1 8 3 5 4 1 6 2 7 6 3 5
6
7
8
4 1
2
7 6
8 4 3 5 1
2
7 6
8 2 3 4 7 5 1
9
6
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Search Nodes States
8 2
3 4 7 5 1
8 3 5 2 4 1 7 6
STATE
对于盲目策略,N1和N2只是 两个节点(在搜索树上的某 个位置),仅此而已
N1 1 2 5 3 6
1
2
3
STATE
4 N2
4
7
5
8 6
7
8
Goal state
17
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Example
8 3 5 2 4 1 7 6
盲目(无信息)搜索
Blind (Uninformed) Search
(系统化的对可能的选择进行探索)
R&N: Chap. 3, Sect. 3.3–5
1
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Simple Problem-Solving-Agent Agent Algorithm
1. 2. 3. 4. 5. s0 sense/read initial state GOAL? select/read goal test Succ read successor function solution search(s0, GOAL?, Succ) perform(solution)
4
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Example: route-finding problem
5
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Single-state problem formulation
A problem is defined by four items: initial state e.g., “at Arad” successor function S(x) = set of action-state pairs e.g., S(Arad) = {<Arad Zerind, Zerind>,…} goal test, can be explicit, e.g., x = “at Bucharest” implicit, e.g., No Dirt(x) path cost (additive) e.g., sum of distances, number of a actions executed, etc. c(x,a,y) is the step cost, assumed to be 0
2
4 5 6
3
7
FRINGE = (2, 3)
22
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Breadth-First Strategy
新生成的节点放到FRING E队列的最后
1
广度优先策略
2
4 5 6
3
7
FRINGE = (3, 4, 5)
23
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
3 5 1
2
7 6
8 2
3 4 7 5 1
12
6
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Search Strategy
边缘(fringe) 指所有还未扩展的节点 边缘用一个优先队列实现
• INSERT(node,FRINGE) • REMOVE(FRINGE)
搜索策略
队列FRINGE中节点的排列顺序决定了 搜索策略
Arad
Fagaras
Oradea
Rimnicu
Bucharest
7
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Search Tree
搜索树
State graph
Search tree
注意一些状态可能 会被多次访问
8
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Search Nodes States
• 深度限制 Depth-limited • 迭代深入 Iterative deepening
弧耗散 Arc cost = 1
弧耗散 代价一致 Uniform-Cost Arc cost (广度优先的一种变化) = c(action) 0
20
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
只能是针对具体的问题实例尽可能高效的去 求得问题的解答
这就是搜索策略的目标
19
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Blind Strategies
广度优先 Breadth-first
• 双向搜索 Bidirectional
盲目策略
深度优先 Depth-first
13
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Search Algorithm #1
SEARCH#1 1. If GOAL?(initial-state) then return initial-state 2. INSERT(initial-node,FRINGE) 3. Repeat: a. If empty(FRINGE) then return failure Expansion of N b. N REMOVE(FRINGE) c. s STATE(N) d. For every state s’ in SUCCESSORS(s) i. Create a new node N’ as a child of N ii. If GOAL?(s’) then return path or goal state iii. INSERT(N’,FRINGE)
1 + b + b2 + … + bd = ???
评价
27
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Evaluation
b: 分支因子 d: 最浅目标节点的深度 广度优先搜索: • 完备 Complete • 最优 若每一步的耗散为1 生成的节点个数:
1 + b + b2 + … + bd = (bd+1-1)/(b-1) = O(bd)
branching factor b of the search tree
一些重要参数
2)初始状态与目标状态之间路径的最短长度 (≠ 耗散) 搜索树中最浅的目标节点的深度d
depth d of the shallowest goal node in the search tree
25
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
只要问题有解,搜索算法就一定能找到路径耗散 最小的解,则称该搜索算法是最优的
复杂度 Complexity 复杂度是评价算法所需要的时间及占用的 内存空间大小
15
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou
Blind vs. Heuristic Strategies
盲目或(无信息) 策略没有利用状态的有
搜索树的一个节点N的扩展包括: 1)评估状态(N)的后继函数 N 2)根据后继函数返回值,每一个状态生 成一个子节点 节点生成 节点扩展 node generation node expansion
8
3 5 4 1
Node expansion
节点扩展
8 3 5 4 1
2 7 6
2
7 6
8 4
评价
28
人工智能原理2010年春季 广西大学 计算机学院 Dr.Ou