深蓝学院移动机器人路径规划笔记-图搜索

目录

  • Graph Search
    • Graph Search Basis
      • Configuration Space
      • Search-based Method
      • Graph Search Overview
      • Graph Traversal
        • Breadth First Search (BFS) vs. Depth First Search (DFS)
        • Depth First Search (DFS)
        • Breadth First Search (BFS)
        • BFS vs. DFS: which one is useful?
    • Heuristic search
      • Greedy Best First Search
    • Dijkstra and A*
      • Costs on Actions

Graph Search

包含以下四部分:

  1. Graph Search Basis
  2. Dijkstra and A*
  3. Jump Point Search
  4. Homework

Graph Search Basis

Configuration Space

C-空间: 可以阅读机器人学书籍学习,该知识针对机械臂这类高维空间里的运动规划很重要。
思想: 简单而言,就是为了将机器人描述为空间(不一定是欧式空间,可以是非欧式空间的表达)中的一个点。

Search-based Method

• Graphs have nodes and edges.
• State space graph: a mathematical representation of a search algorithm.

  1. For every search problem, there’s a corresponding state space graph.
  2. Connectivity between nodes in the graph is represented by (directed
    or undirected) edges.
    深蓝学院移动机器人路径规划笔记-图搜索_第1张图片

使用栅格地图表示图,栅格地图本身可以作为图:
Grid-based graph: use grid as vertices and grid connections as edges
深蓝学院移动机器人路径规划笔记-图搜索_第2张图片

使用PRM采样生成图:
深蓝学院移动机器人路径规划笔记-图搜索_第3张图片

Graph Search Overview

The search always start from start state X s X_{s} Xs

  • Searching the graph produces a search tree
  • Back-tracing a node in the search tree gives us a path from the start state to that node
  • For many problems we can never actually build the whole tree, too large or inefficient – we only want to reach the goal node asap.
    深蓝学院移动机器人路径规划笔记-图搜索_第4张图片
                    将图转换为树结构

算法三个步骤:

• Maintain a container to store all the nodes to be visited
• The container is initialized with the start state Xs
• Loop
	1. Visit:Remove a node from the container according to some pre-defined score function
		- Visit a node
	2. Expansion: Obtain all neighbors of the node
		- Discover all its neighbors
	3. Add:Push them (neighbors) into the container
• End Loop

算法的三个问题:
• Question 1: When to end the loop?

  • Possible option: End the loop when the container is empty
  • 除了上述的,可以采取不同的终止条件,比如到达目的地。

• Question 2: What if the graph is cyclic?

  • When a node is removed from the container (expanded / visited), it should never be added back to the container again
  • 因此,在程序中,除了维护一个储存将来所有可能会访问的节点的container,还维护一个储存已访问点的container。

• Question 3: In what way to remove the right node such that
the goal state can be reached as soon as possible, which
results in less expansion of the graph node.

  • 解决这个问题就是我们算法的关键:效率,快速。

Graph Traversal

图的遍历是算法的基础。
目前常见的两种算法是深度优先搜索和宽度优先搜索。

Breadth First Search (BFS) vs. Depth First Search (DFS)

两种遍历方法对比如下:
深蓝学院移动机器人路径规划笔记-图搜索_第5张图片
BFS的容器模型是队列(queue),遵循先进先出原则。所以,先进的节点会先出来。
DFS的容器模型是栈(stack),遵循后进先出原则。所以,后进的节点会先出来。

Depth First Search (DFS)

深蓝学院移动机器人路径规划笔记-图搜索_第6张图片
                DFS在搜索中的原理

Breadth First Search (BFS)

深蓝学院移动机器人路径规划笔记-图搜索_第7张图片
                BFS在搜索中的原理

BFS vs. DFS: which one is useful?

深蓝学院移动机器人路径规划笔记-图搜索_第8张图片
                DFS vs. BFS在搜索中的对比

  • BFS在遍历到目标时,可通过回溯找到最短路径。为什么是最短路径?从图BFS在搜索中的原理 可知,BFS从顶层逐层搜索下层,因此,最终回溯到的路径将是最短的。
  • DFS “一路走到黑”,搜索到目标时便停止搜索,当存在多条目标路径时,很有可能搜索出来的目标路径是非优的甚至很差。
  • 因此,后面的算法会以BFS为基础遍历节点。

Heuristic search

启发式算法,以贪心算法为例。
启发式算法与DFS、BFS区别:

  • BFS and DFS pick the next node off the frontiers based on which was “first in” or “last in”.
  • Greedy Best First picks the “best” node according to some rule, called a heuristic.

Greedy Best First Search

  • Definition: A heuristic is a guess of how close you are to the target.
  • guess: 在找到解之前,我们无法得知实际的最近距离,所以,只是一种当下猜想。
    深蓝学院移动机器人路径规划笔记-图搜索_第9张图片
    对于上图,加入我们想要猜测期待到最短的距离,通常可以采用两种方法
  • 欧氏距离(Euclidean Distance):直线
  • 曼哈顿距离(Manhattan Distance):▲x + ▲y

启发式算法的好处:

  • A heuristic guides you in the right direction.
  • A heuristic should be easy to compute.

问题:
如何设计一个好用的启发式函数呢?

深蓝学院移动机器人路径规划笔记-图搜索_第10张图片
深蓝学院移动机器人路径规划笔记-图搜索_第11张图片
对比上面两种情况来看,在复杂情况下(障碍物)贪心算法不一定能找到很好的路径。但这并不意味着贪心算法毫无用处,我们仍然可以借鉴它的思想设计出更好的启发式算法。

Dijkstra and A*

Costs on Actions

深蓝学院移动机器人路径规划笔记-图搜索_第12张图片

  • A practical search problem has a cost “C” from a node to its neighbor
    • Length, time, energy, etc.
  • When all weight are 1, BFS finds the optimal solution
  • For general cases, how to find the least-cost path as soon as possible?

在之前的算法里,我们没有考虑边的代价问题。为了解决这个问题,提出了Dijkstra and A*算法。

你可能感兴趣的:(自动驾驶,自动驾驶,算法)