CRP算法及工程实现

提示: 欢迎朋友们 提问、交流、指正

摘要:CPR在路径规划方面的优势

  • 大陆[欧洲、亚洲等级]级尺度的路网数据快速路径规划
  • 敏捷的路网权值模型,应该对路况及用户偏好的快速变化

1. 引言

CRP将预处理分为两个阶段:

  • p1:只考虑路网的拓扑信息
  • p2:在阶段1基础上进一步构建权值模型

其中p1阶段仅针对拓扑图信息,更新频率低,因此可以对计算量不敏感;而p2阶段的权值模型会频繁变化,因此该阶段更新尽可能轻量保证更新效率。

路网中的路口可能存在禁行,比如禁止掉头、左转等,因此不能简单的使用顶点代表路口。为了应对这种情况,我们将路口的单个顶点扩展为二分图,如图1所示。二分图中边的权重可以表示路口禁行信息,比如我们不能通过入点1左转进入出点b时,则将该边对应的权值设置为无穷大。


图1:路口示意图

2. CRP

CRP是基于分治思想的规划算法,即将整个图切分为若干小块(cell),通过迭代的方式实现多层分块操作构建覆盖图(overlay graph)。overlay graph是在某一cell内中若干跨cell的顶点构成的图,如图2所示。overlay graph中的edge权值为cell内顶点uv的最短路径长度,这确保了覆盖图和原始图中最短路径长度一致。


图2:overlay graph示意图

2.1 预处理

  1. 迭代分层方式对graph进行切分,形成多层的graph结构,层号为1到l,层数越小表示cell尺度越小;显然,1为包含最小尺度cell的层
  2. 寻找cut-edge,即跨cell的edge;将cut-edge的端点作为顶点添加到overlay graph中。换而言之,overlay graph中的每个顶点都来自cut-edge(其他层)或者original-edge(1层)。如果cut-edge uv为入边,则对应的overlay graph顶点v为入点,反之则为出点。
  3. 每个cell C的出入均通过入点和出点,因此连接所有的入点和出点就会形成cell C的二分图。这个二分图中边的权重取决于具体选择的标准,标准的选择在customization阶段。
  4. 构建原图顶点与overlay graph顶点间的映射关系。

2.2 定制化

计算overlay graph中边的权值。cell C 中overlay edge(u,v)的权值取决于C中u到v在原始graph中的最短路径,通过自下而上的方式计算权值。首先计算level 1的权值信息,然后基于level 1进一步计算level 2,以此递推。

2.3 算路

  • 起点:附近edge su,则起始顶点定义为s;
  • 终点:附近edge vt;则目标顶点定位为t;

基于起始点s和目标点t在graph中使用Dijkstra算法进行算路操作。

如图3所示,由起点s出发,使用Dijkstra算法在原图上进行寻路,直到到达cell的边界点v1,v1的相邻点之一为v2,该相邻点为其他的cell中。v2之后就在地一层的overlay graph中运用。需要注意的是,我们不能在第二层overlay graph对v2进行操作,因为s和v2均在第二层overlay graph的cell中。自顶点v3找到其他cell中的相邻顶点v4,此时v4是第二层的断点。进一步在第二层overlay graph中寻找v4的邻接点。这一过程按照以上方式达到原图的t是终止。这一算路逻辑也适用于在overlay graph中多次上升下降的应用。


图3:基于overlay graph 最短路径的s到t最短路径计算示意图

为了构建路口(顶点)的turn cost,必须知道那些边进入了路口顶点。由于存在多条边进入路口顶点的情况,因此仅使用一个路口顶点不能作为key值。解决方式就是使用元组(v, i),其中i表示第i个入边。特别之处,这一信息仅在我们在原图做路径规划时才会用到。因为overlay graph顶点与相邻顶点的权值已经考虑了turn cost。

3. 实施

  • 数据结构
  • CRP三阶段

3.1 数据结构

3.2 预处理

解析:OSMParser类负责解析编码为XML文件的OSM路网地图,OSM数据中包含路口的禁转信息及道路类型,比如道路类型;这些信息用于定制化阶段的权值计算。解析任务主要是为了提取graph中的顶点和边信息,还包括属性及路口禁行等信息。
路口v的turn restriction表示为inDeg(v)*outDeg(v)维的向量,其元素存储禁转信息,比如“禁止左转”。对于一个路口的turn restriction矩阵的变化是有限的,因此给每一个路口单独构建turn restriction是没有必要,这在资源上也是浪费的。通过对turn restirction矩阵进行hash编码避免重复分配资源。两个路口的turn restriction的维度及条目是一样的,但是其在矩阵中的排列顺序会有差异,因此我们通常先对矩阵排序在hash编码,这样这两个路口就可以公用turn restirction矩阵。

3.3 定制化

3.4 算路

实验

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
# CRP Open source C++ Implementation of Customizable Route Planning (CRP) by Delling et al. This project was part of a practical course at Karlsruhe Institute of Technology (KIT). Requirements ============ In order to build CRP you need to have the following software installed: - Boost C++ Library (http://www.boost.org), more specifically Boost Iostreams. - Scons (http://scons.org) - g++ >= 4.8 (https://gcc.gnu.org) Building CRP ============ If the Boost Library is not in your PATH, make sure to edit the *SConstruct* file in the root directory to point the build script to the correct location of Boost. There is a section *Libraries* in the *SConstruct* file where you can specify the paths. Once you have installed all the software packages listed above, you can build the CRP programs by typing ``` scons --target=CRP --optimize=Opt -jX ``` into your terminal where `X` is the number of cores you want to use for building the project. If you want to use a specific g++ compiler version you can add `--compiler=g++-Version`. We also support a debug and profiling build that you can call with `--optimize=Dbg` and `--optimize=Pro` respectively. This command will build three programs in the folder *deploy*: - *osmparser*: Used to parse an OpenStreetMap (OSM) bz2-compressed map file. Call it with `./deploy/osmparser path_to_osm.bz2 path_to_output.graph.bz2` - *precalculation*: Used to build an overlay graph based on a given partition. Call it with `./deploy/precalculation path_to_graph path_to_mlp output_directory`. Here, *path_to_mlp* is the path to a *MultiLevelPartition* file for the graph that you need to provide. For more details, take a look into our project documentation. - *customization*: Used to precompute the metric weights for the overlay graph. Call it with `./deploy/customization path_to_graph path_to_overlay_graph metric_output_directory metric_type`. We currently support the following metric types: *hop* (number of edges traversed), *time* and *dist*.

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值