本篇为在University of Birmingham 学习Advanced Nature-Inspired Search and Optimisation课程中的笔记之一
This is one of the notes from the Advanced Nature-Inspired Search and Optimisation course at the University of Birmingham
1 问题引出——螺栓螺母的匹配问题
1.1 一个螺栓与n个螺母
- 日常问题:给定一个螺栓和一组n个不同尺寸的螺母,找到一个与螺栓匹配的螺母
- 以数学形式:给定n个元素的数组,找到其值等于x的第一个元素
- 问:如何使用算法求解?如何有效解决?
1.2 n个螺栓与n个螺母
- 木有条理的木匠有n个不同大小的螺母和n个螺栓的集合,并且希望找到相应的一对螺栓和螺母。每个螺母正好匹配一个螺栓(反之亦然),并且他只能将螺母与螺栓进行比较,即,他既不能将螺母与螺母进行比较,也不能将螺栓与螺栓进行比较。
- 您能帮助木匠快速匹配螺母和螺栓吗?
- 这称为“螺母和螺栓问题”或“锁和钥匙问题”。
- 问:如何制定问题?如何使用算法求解?如何有效解决?
2 方案介绍——随机算法
“For many problems, a randomised algorithm is the simplest, the fastest or both.” —— Prabhakar Raghavan, Vice President of Engineering at Google.
2.1 算法一览
- 分治算法(e.g., quicksort algorithm, Merge-Sort)
- 数学规划算法(e.g., linear programming, Multi-objective programming, Dynamic programming algorithms)
- 搜索和枚举算法
- 蛮力算法
- 改进的蛮力算法
- 启发式算法_Heuristic algorithms
- 局部搜索(e.g., greedy search)
- **随机算法
2.2 启发式算法与随机算法
1). 启发式 在计算机中的解释:
一种(通常是简单的)算法,可以在合理的时间内为问题提供足够好的解决方案
- 解决方案(通常)不是最佳方案,但令人满意:
- 更快:替代蛮力(穷举)搜索
- 权衡最优性,完整性,准确性或精度以提高速度。
- 通常用于解决其他算法难以解决的问题,例如蛮力算法
- 包括确定性(例如本地搜索)和随机算法(Randomised Algorithm)
2). 随机算法
- Randomised algorithm: An heuristic algorithm that makes random choices during execution to produce a result_随机选择产生结果
- Takes a source of random numbers to make random choices
- Behaviour, e.g., output or running time can vary even on a fixed input
- The goal: design an algorithm and analyse it to show that its behaviour is likely to be good, on every input