L3.2 Uninformed Search Strategy- Key Points

Uninformed Search Strategy

  • Definition: A search strategy that does not use heuristic information.
  • Characteristics:
    • No direction knowledge
    • Works for general problems but inefficient
    • Useful when no heuristic function is available

Search Strategy

  • Choose an option → If incorrect, keep other options for later.
  • The challenge: Which option should be chosen first?

Node Components

  1. STATE - Current state in the search space.
  2. PARENT - Where it was generated from.
  3. ACTION - Action used to generate it.
  4. PATH-COST - Cost from the initial state to the node.
  5. DEPTH - Steps from the initial state.

Queue Types

  1. FIFO (First-In, First-Out) - Used in BFS.
  2. LIFO (Last-In, First-Out) - Used in DFS.
  3. Priority Queue - Used in A Search*.

搜索算法性能衡量与不同搜索策略

在人工智能和计算机科学中,搜索算法的性能决定了解决问题的效率。我们可以通过完备性(Completeness)、最优性(Optimality)、时间复杂度(Time Complexity)和空间复杂度(Space Complexity)等指标来衡量搜索策略的优劣。此外,搜索策略可以分为无信息搜索(Uninformed Search)有信息搜索(Informed Search),不同策略适用于不同的应用场景。本文将详细介绍这些概念。


1. 搜索算法的性能衡量标准

1.1 完备性(Completeness)

完备性指的是算法是否一定能找到解。如果一个搜索算法总是能够找到可达解,则它是完备的。
此外,还需要考虑:

  • 算法是否会陷入无限循环(如深度优先搜索可能会陷入死循环)。
  • 是否能够避免重复状态,提高搜索效率。

1.2 最优性(Optimality)

最优性指的是找到的解是否是最优解,即是否找到代价最小的路径。例如:

  • 广度优先搜索(BFS)代价一致时能保证最优解。
  • A 搜索算法* 在满足某些条件下可以找到最优解。

1.3 时间复杂度(Time Complexity)

时间复杂度表示搜索算法找到解所需的时间,通常用节点扩展的数量衡量。
时间复杂度的计算涉及以下参数:

  • b(分支因子):每个节点的平均子节点数。
  • d(目标节点的最浅深度):找到解时的最小步数。
  • m(状态空间的最大深度):问题的最大可能路径。

通常,时间复杂度表示为 O(b^d)O(b^m)

1.4 空间复杂度(Space Complexity)

空间复杂度表示搜索过程中需要存储的最大节点数,也可以用O(b^d) 或 O(b^m) 表示。


2. 时间与空间复杂度的计算

时间与空间复杂度通常由以下因素决定:

  1. b(分支因子):每个节点可扩展的最大子节点数。
  2. d(目标节点的深度):最优解所在的最小深度。
  3. m(状态空间的最大深度):搜索树的最大可能路径。

计算时通常使用 大 O 记号(Big-O notation) 来衡量复杂度。例如:

  • 广度优先搜索(BFS) 的时间复杂度为 O(b^d),空间复杂度也为 O(b^d)
  • 深度优先搜索(DFS) 的时间复杂度为 O(b^m),空间复杂度为 O(bm)(只存储路径上的节点)。

3. 搜索策略分类

3.1 无信息搜索(Uninformed Search)

无信息搜索(又称盲目搜索)不使用额外的启发信息,仅依赖基本的搜索规则遍历搜索空间。主要包括:

  • 广度优先搜索(BFS)
  • 深度优先搜索(DFS)
  • 一致代价搜索(Uniform Cost Search)
  • 深度限制搜索(Depth-limited Search)
  • 迭代加深搜索(Iterative Deepening Search)

3.2 有信息搜索(Informed Search / Heuristic Search)

有信息搜索使用启发式函数(Heuristic Function) 来指导搜索,使得算法更高效。
常见的启发式搜索算法:

  • A 搜索*
  • 贪心最佳优先搜索(Greedy Best-First Search)

4. 具体搜索算法解析

4.1 广度优先搜索(BFS)

广度优先搜索使用FIFO 队列(先进先出),按照层次展开搜索,确保最优解。

BFS 伪代码
BREADTH-FIRST-SEARCH(problem)
  1. 初始化:
     - 创建一个 FIFO 队列 frontier,存入初始节点
     - 创建 explored 集合,存储已访问节点
  2. 进入循环:
     - 若 frontier 为空,返回失败
     - 取出队列头部节点 node
     - 若 node 是目标状态,返回成功
     - 遍历 node 的所有子节点 child:
         - 若 child 不在 frontier 和 explored 中,加入 frontier

BFS 的时间复杂度和空间复杂度:O(b^d)

4.2 深度优先搜索(DFS)

深度优先搜索使用LIFO 栈(后进先出),优先沿着路径向下探索,适合解决空间复杂度较大的问题。

DFS 伪代码
DEPTH-FIRST-SEARCH(problem)
  1. 初始化:
     - 创建一个 LIFO 栈 frontier,存入初始节点
     - 创建 explored 集合,存储已访问节点
  2. 进入循环:
     - 若 frontier 为空,返回失败
     - 取出栈顶节点 node
     - 若 node 是目标状态,返回成功
     - 遍历 node 的所有子节点 child:
         - 若 child 不在 frontier 和 explored 中,加入 frontier

DFS 的时间复杂度:O(b^m),空间复杂度 O(bm)


5. 总结

  1. 衡量搜索算法的性能主要考虑

    • 完备性(能否找到解)
    • 最优性(找到的解是否最优)
    • 时间复杂度(搜索所需时间)
    • 空间复杂度(存储需求)
  2. 时间复杂度计算时,主要参数包括

    • b(分支因子):每个节点的最大子节点数
    • d(最小目标深度)
    • m(最大路径长度)
  3. 搜索策略分类

    • 无信息搜索(Uninformed Search):不依赖启发信息(如 BFS, DFS)。
    • 有信息搜索(Informed Search):使用启发式指导搜索(如 A*)。
  4. 广度优先搜索(BFS)适用于:需要最优解的情况,但占用较大内存

  5. 深度优先搜索(DFS)适用于:内存受限的问题,但不保证最优解


📌 英文翻译:Searching Algorithm Performance & Strategies

1. Performance Metrics

  • Completeness: Can a solution always be found?
  • Optimality: Is the solution the best among possible solutions?
  • Time Complexity: How long does it take to find a solution?
  • Space Complexity: How much memory is required?

2. Time & Space Complexity Calculation

  • b: Branching factor (number of successors per node)
  • d: Depth of the shallowest goal node
  • m: Maximum path length

Complexity measured using Big-O notation:

  • BFS: O(b^d)
  • DFS: O(b^m)

3. Search Strategies

  • Uninformed Search: No heuristic, includes BFS, DFS.
  • Informed Search: Uses heuristics, includes A*.

4. BFS vs DFS

  • BFS: Guarantees optimal solution, but uses more memory.
  • DFS: Uses less memory, but may not find the best solution.

📚 考试笔记(Exam Notes)

  • BFS: FIFO Queue, O(b^d).
  • DFS: LIFO Stack, O(b^m).
  • Time Complexity: O(b^d) vs O(b^m).
  • Uninformed vs Informed Search: Blind vs Guided.

1.2 Optimality Conditions of A Search Algorithm*

English Explanation
  1. Admissible Heuristic
    The heuristic function h(n)h(n) must never overestimate the true cost h∗(n)h^*(n) from node nn to the goal.
    Example: In grid-based maps, Manhattan distance or Euclidean distance is commonly used as a heuristic estimate.

  2. Consistent Heuristic
    For every pair of adjacent nodes nn and mm, the heuristic must satisfy:

    h(n)≤c(n,m)+h(m)h(n) \leq c(n, m) + h(m)

    where c(n,m)c(n, m) is the movement cost between nodes nn and mm. This ensures path expansion consistency and prevents unnecessary backtracking.

  3. Finite Problem Domain
    The graph must contain a finite number of nodes; otherwise, the algorithm may enter an infinite loop.

  4. Non-Negative Path Costs
    The actual cost g(n)g(n) of all paths must be non-negative, ensuring the validity of physical quantities such as time and distance.


📌 考试笔记(Exam Notes) 

BFS

  • FIFO queue, expands level by level.
  • Complexity: O(b^d) (time & space).
  • Best for shortest path problems.

UCS

  • Uses priority queue, always expands the lowest-cost node.
  • Guarantees optimal path.
  • Time complexity: O(b^d).

DFS

  • LIFO stack, expands deepest nodes first.
  • Complexity: O(b^m) time, O(bm) space.
  • Best for deep search spaces.


一、问题定义的四个要素​(就像规划一次旅行)

  1. 初始状态

    • 你现在的位置,比如“在家门口”。
  2. 可能的行动

    • 你能做的动作,比如“开车、坐地铁、步行”。
  3. 目标状态

    • 你想去的地方,比如“市中心的书店”。
  4. 路径代价

    • 每种选择的成本,比如“开车要油费,坐地铁要时间,步行免费但累”。

例子
走迷宫问题 = 初始位置(入口)→ 行动(上下左右移动)→ 目标(出口)→ 代价(步数最少)。


二、测量问题解决的性能​(像评价导航APP的好坏)

  1. ​**时间快吗?**​(时间复杂度)

    • 比如:BFS(广度优先)像地毯式搜索,速度慢;DFS(深度优先)像一条路走到底,可能更快找到解,但不一定最优。
  2. ​**内存大吗?**​(空间复杂度)

    • BFS需要记住所有可能的路径,内存爆炸;DFS只需要记住当前路径,内存小。
  3. ​**能保证找到最优解吗?**​(最优性)

    • BFS和Uniform-cost(均一成本)像“强迫症”,必须找到最短路径;DFS可能找到一条路就停,不保证最短。
  4. ​**能解决问题吗?**​(完备性)

    • 比如:无限深的树中,DFS可能永远找不到解,BFS则能保证找到(如果解存在)。

三、六大搜索策略的原则​(像不同的找人策略)

  1. 广度优先(BFS)​

    • 原则:像“水波纹扩散”,一层层找。
    • 例子:在迷宫中,先检查所有离起点1步的位置,再检查2步的位置……保证找到最短路径,但内存消耗大。
  2. 均一成本(Uniform-cost)​

    • 原则:优先走“当前已知最便宜的路”。
    • 例子:导航APP实时计算路线,优先推荐高速费最少(或时间最短)的路径,类似Dijkstra算法。
  3. 深度优先(DFS)​

    • 原则:像“钻牛角尖”,一条路走到黑,走不通再回头。
    • 例子:迷宫中选择一个方向走到死胡同,再回上一个岔路换方向。内存小,但可能绕远路。
  4. 深度限制(Depth-limited)​

    • 原则:给DFS加一个“探索深度上限”,避免无限下钻。
    • 例子:找人时规定“最多找3条街”,找不到就放弃。
  5. 迭代加深(Depth-Deepening)​

    • 原则:结合BFS和DFS,先浅层DFS,再逐步加深深度。
    • 例子:找钥匙时,先翻抽屉第一层,没有就翻第二层……直到找到。
  6. 深度延长(排版疑似错误,可能指其他策略)​

    • (此处可能是排版问题,或指动态调整搜索深度,暂不展开)

四、这些策略的对比​(像选不同的交通工具)

策略优点缺点适用场景
广度优先保证最短路径内存爆炸小规模迷宫、树搜索
均一成本边权不同时仍最优比BFS稍慢带权重的路径规划
深度优先内存小,适合深问题可能绕远路、死循环解空间深,不求最优
迭代加深内存小且保证最优重复搜索浅层节点未知深度的问题

通俗总结

  • 搜索策略的核心矛盾
    “快和省内存不可兼得”——想要快(DFS),可能绕路;想要省内存(DFS),可能不最优;想要又省内存又最优(迭代加深),就得牺牲时间。

  • 实际应用
    导航软件用均一成本(Dijkstra/A*)找最短路径;游戏AI用BFS/DFS生成地图;智能客服用深度限制搜索快速回答用户问题。

 

Below is a concise cheat sheet for quick memorization, focusing on the key ideas and properties of Depth-Limited Search, Iterative Deepening Search, and Iterative Lengthening Search—especially useful for exam revision.


Depth-Limited Search (DLS)

  • Definition: A form of Depth-First Search (DFS) with a fixed maximum depth dd.
  • Pros:
    • Straightforward modification of DFS.
    • Can avoid infinite-depth pitfalls.
  • Cons:
    • Not guaranteed to find a solution if the true solution depth > dd.
    • Not optimal (might miss shallower solutions).
  • Completeness: Only if dd is large enough and state space is finite.
  • Use Case: When you have a reasonable guess for the solution depth.

Iterative Deepening Search (IDS)

  • Definition: Increases the depth limit step by step: try d=0, then d=1, d=2, etc.
  • Pros:
    • Combines BFS’s completeness/optimality (for uniform-cost edges) with DFS’s low memory usage.
    • Finds the shallowest goal first ⇒ optimal when all edges have the same cost.
  • Cons:
    • May repeat states multiple times (due to repeated DFS at each depth).
  • Completeness: Yes, when the branching factor is finite.
  • Use Case: When you don’t know the solution depth but still want BFS-like optimality in a large search space.

Iterative Lengthening Search (ILS)

  • Definition: Similar to IDS but with path cost as the limit (rather than depth). Increments the maximum cost allowed each iteration.
  • Pros:
    • An iterative version of Uniform-Cost Search (UCS).
    • Finds the least-cost path (like UCS).
    • Uses lower memory than a single full UCS run.
  • Cons:
    • Each increase in cost limit restarts the search ⇒ repeated work.
  • Completeness/Optimality:
    • Optimal when path costs are non-negative.
    • Complete in a finite state space.
  • Use Case: When path costs vary widely or are unknown, and you want guaranteed least-cost solutions.

Remember

  • DLS: DFS + depth cap; easy but not optimal.
  • IDS: Depth-limited DFS repeated; BFS-like guarantees, DFS-like memory.
  • ILS: Cost-limited search repeated; UCS-like optimality, iterative overhead.

 

汉字字库存储芯片扩展实验 # 汉字字库存储芯片扩展实验 ## 实验目的 1. 了解汉字字库的存储原理和结构 2. 掌握存储芯片扩展技术 3. 学习如何通过硬件扩展实现大容量汉字字库存储 ## 实验原理 ### 汉字字库存储基础 - 汉字通常采用点阵方式存储(如16×16、224、32×32点阵) - 每个汉字需要占用32字节(16×16)到128字节(32×32)不等的存储空间 - 国标GB2312-80包含6763个汉字,需要较大存储容量 ### 存储芯片扩展方法 1. **位扩展**:增加数据总线宽度 2. **字扩展**:增加存储单元数量 3. **混合扩展**:同时进行位扩展和字扩展 ## 实验设备 - 单片机开发板(如STC89C52) - 存储芯片(如27C256、29C040等) - 逻辑门电路芯片(如74HC138、74HC373等) - 示波器、万用表等测试设备 - 连接线若干 ## 实验步骤 ### 1. 单芯片汉字存储实验 1. 连接27C256 EPROM芯片到单片机系统 2. 将16×16点阵汉字字库写入芯片 3. 编写程序读取并显示汉字 ### 2. 存储芯片字扩展实验 1. 使用地址译码器(如74HC138)扩展多片27C256 2. 将完整GB2312字库分布到各芯片中 3. 编写程序实现跨芯片汉字读取 ### 3. 存储芯片位扩展实验 1. 连接两片27C256实现16位数据总线扩展 2. 优化字库存储结构,提高读取速度 3. 测试并比较扩展前后的性能差异 ## 实验代码示例(单片机部分) ```c #include <reg52.h> #include <intrins.h> // 定义存储芯片控制引脚 sbit CE = P2^7; // 片选 sbit OE = P2^6; // 输出使能 sbit
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值