技术教程 | 如何快速规划物流调度配送方案

百度地图提供的智能调度产品依托百度物流地图的货车限行数据和路线规划能力,考虑物流多场景下的业务优化目标和多种约束条件,基于百度云的算力优势和算法能力,快速生成合理调度方案,有效降低排单难度,提高排单效率,降低运输成本。

在物流行业中存在着很多细分领域,如快递、即时配送、零担等,每个细分领域的使用方式因场景的不同而略有差异,例如快消品运输的特点是配送网点众多,订货周期短,订货量周期变化明显等。传统的方式是调度员依靠经验手动完成排单排线的工作,排单耗时长,车辆数、总里程无法达到最优,甚至有可能因为经验不足等原因发生选错路或没有及时更新最新道路情况等问题,效果并不理想。而百度地图智能物流调度支持多种优化目标,可灵活配备约束条件,从各个角度贴近行业客户真实的配送场景,快速为客户从海量路线中选取最优行驶路线、避让全国物理限制信息、提升车辆装载率、降低行驶总里程并大幅节约调度时间,为客户降本增效。

本文将帮助开发者基于百度地图智能调度服务快速生成物流配送调度方案。

获取配送点的经纬度坐标

进行物流调度的第一步是获得配送点以及物流仓库的经纬度信息。对于少量点,我们可以使用百度地图的坐标拾取系统,通过在地图上选点获得配送点所对应的坐标。以上海市世纪公园为例:

 

在输入“世纪公园”并点击搜索后,选取右边列表中出现的“世纪公园”相关地点便可以在右上角得知选择点的具体经纬度信息。 如果需要转换的地址经纬度较多,无法手动在页面获取的话,也可以使用百度地图开放平台的正/逆地理编码服务批量转换地址为经纬度坐标。

调用排单接口

智能调度提供了基于相同路网、不同路网、单仓、多仓等不同约束条件下的多种排单API,这里我们介绍最易于上手的精准排单。其所针对的场景为仓库为单个仓库且每次派单地点不固定且数量不多(小于200)的场景。 我们以上海举例,选取了位于市区的5个公园作为假想配送点。它们分别是:
  • 世纪公园(121.558979,31.222046)
  • 顾村公园(121.383689,31.346915)
  • 长风公园(121.403703,31.230279)
  • 复兴公园(121.475647,31.222986)
  • 陆家嘴中心绿地(121.512881,31.243693)
同时我们把发货仓库地点定为上海浦东国际机场:
  • 上海浦东国际机场(121.81509,31.157478)
这些配送点在地图上的位置显示如下:

 

此时我们假定有两辆配送车辆:

其中车辆类型为一个枚举,目前支持GB01(默认车辆长6000mm,宽2100mm,高3000mm)以及SMALL(小轿车,车辆长4000mm,宽2000mm,高2000mm)两种车辆类型的轴重轴数均为2。该信息用于道路货车导航限行规避,一个车辆类型会对应一个或多个型号的货车,由用户自行决定车辆型号与车辆类型的映射关系。

 

具体的请求body定义可以参考快速排单API文档,最后的请求构造为:

POST api.map.baidu.com/ros/v1/scheduler/fastorder?ak={您的AK}
{
  "orderType" : "ACCURATE_ORDER",
  "depots" : [ {
    "depotId" : "depot1",
    "location" : {
      "latitude" : 31.157478,
      "longitude" : 121.81509
    },
    "depotTimeWindow" : {
      "startTime" : 0,
      "endTime" : 1440
    },
    "vehicleGroups" : [ {
      "vehicleTypeId" : "GB01",
      "vehicleModelId" : "vehicle1",
      "vehicleCount" : 1,
      "maxRunDistance" : 300000,
      "maxRunTime" : 300,
      "maxVisited" : 4,
      "returnToDepot" : 1,
      "departureLocationKey" : "depot1"
    }, {
      "vehicleTypeId" : "SMALL",
      "vehicleModelId" : "vehicle2",
      "vehicleCount" : 1,
      "maxRunDistance" : 300000,
      "maxRunTime" : 300,
      "maxVisited" : 4,
      "returnToDepot" : 2,
      "departureLocationKey" : "depot1"
    } ]
  } ],
  "vehicleModels" : [ {
    "vehicleModelId" : "vehicle1",
    "capacity" : {
      "weight" : 5000.0,
      "volume" : 10.0
    },
    "perDistanceUnitPrice" : 10.0,
    "perTimeUnitPrice" : 8.0,
    "fixedCost" : 100.0,
    "waitingCost" : 2.0,
    "averageVelocity" : 40.0
  }, {
    "vehicleModelId" : "vehicle2",
    "capacity" : {
      "weight" : 3000.0,
      "volume" : 3.0
    },
    "perDistanceUnitPrice" : 5.0,
    "perTimeUnitPrice" : 3.0,
    "fixedCost" : 80.0,
    "waitingCost" : 2.0,
    "averageVelocity" : 60.0
  } ],
  "serviceJobs" : [ {
    "serviceJobId" : "serviceJob1",
    "location" : {
      "latitude" : 31.222046,
      "longitude" : 121.558979
    },
    "serviceStayDuration" : 5,
    "demand" : {
      "weight" : 20.0,
      "volume" : 1.0
    }
  }, {
    "serviceJobId" : "serviceJob2",
    "location" : {
      "latitude" : 31.346915,
      "longitude" : 121.383689
    },
    "serviceStayDuration" : 5,
    "demand" : {
      "weight" : 20.0,
      "volume" : 1.0
    }
  }, {
    "serviceJobId" : "serviceJob3",
    "location" : {
      "latitude" : 31.230279,
      "longitude" : 121.403703
    },
    "serviceStayDuration" : 5,
    "demand" : {
      "weight" : 20.0,
      "volume" : 1.0
    }
  }, {
    "serviceJobId" : "serviceJob4",
    "location" : {
      "latitude" : 31.222986,
      "longitude" : 121.475647
    },
    "serviceStayDuration" : 5,
    "demand" : {
      "weight" : 20.0,
      "volume" : 1.0
    }
  }, {
    "serviceJobId" : "serviceJob5",
    "location" : {
      "latitude" : 31.243693,
      "longitude" : 121.512881
    },
    "serviceStayDuration" : 5,
    "demand" : {
      "weight" : 20.0,
      "volume" : 1.0
    }
  } ]
}

 

返回示例为:

{
    "id" : "{problemId}",
    "status" : "RUNNING",
    "errorCode" : "",
    "errorMessage" : ""
}

 

任务创建成功后,可以通过快速排单查询API来获取任务完成后的结果:

GET https://api.map.baidu.com/ros/v3/scheduler/fastorder?ak={您的AK}&problemId={problemId}

 

排单结果可视化

但是,仅仅看json输出还是无法有一个直观的认识,所以我们同时提供了一个可视化的WebSDK可以一目了然得看出排单结果。在使用SDK前,还需要申请一个地图Javascript API。 可以创建一个名为demo.html的文件,并将如下代码贴入其中:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>baidu ros</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
        }
        #baidu-ros {
            width: 100%;
            height: 100vh;
        }
</style>
</head>
<body>
    <div id="baidu-ros"></div>
    <script src="https://api.map.baidu.com/static/sdk/baidu-ros-sdk.min.js"></script>
    <script>
        new window.BAIDU_ROS_SDK({
            ak: '{您的智能调度AK}',
            domId: 'baidu-ros',
            taskId: '{problemId}',
            commitId: '',
            mapak: '{您的Javascript API AK}'
        });
</script>
</body>
</html>

 

保存文件并用浏览器打开该文件,就可以在百度地图上可视化看到排单结果:

 

从结果中可以看到为每辆车分派了一条运输线路:
  • vehicle1送货的路径为世纪公园 - 陆家嘴中心绿地,最后回到浦东国际机场,送货总里程为85.36km,耗时3.2小时。
  • vehicle2送货的路径为复兴公园 - 长风公园 - 顾村公园,送货总里程为78.67km,耗时1.56小时。

总结

本教程展示了如何使用智能调度的快速排单功能快速得对一个单仓小规模派送场景进行排单排线的过程。在实际的使用中,还能够适用更多的场景例如多个仓库、边取边送、冷链配送等。更多的信息可以查看百度地图开放平台 Web服务API 文档。若您需要试用本服务也可点击 申请开通试用权限,欢迎广大开发者使用。 如有任何问题或建议也可以通过官网 反馈平台与我们取得联系。
共21条回复 最后由x****a 回复于2020-05-18 10:57
#2 c****7 回复于2020-05-02

龙梁河 118°35′37.79″E 34°35′12.04″N

0
#3 x****a 回复于2020-05-08

http://chengdufpw7.wikidot.com/
http://chengdufpw8.wikidot.com/
http://chengdufpw9.wikidot.com/
http://xiankfpw.wikidot.com/
http://kunmingfpw.wikidot.com/
http://dongguanfpw.wikidot.com/
http://yangzhoukfpw.wikidot.com/
http://lianyunguangfpw.wikidot.com/

0
#4 x****a 回复于2020-05-08

http://chengdufpw.wikidot.com/
http://chengdufpw1.wikidot.com/
http://chengdufpw2.wikidot.com/
http://chengdufpw3.wikidot.com/
http://chengdufpw4.wikidot.com/
http://chengdufpw5.wikidot.com/
http://chengdufpw6.wikidot.com/

0
#5 x****a 回复于2020-05-16

https://support.qq.com/products/149496
https://support.qq.com/products/148758
https://support.qq.com/products/148757
https://support.qq.com/products/148755
https://support.qq.com/products/148754
https://support.qq.com/products/148752
https://support.qq.com/products/148751
https://support.qq.com/products/148750
https://support.qq.com/products/148749
https://support.qq.com/products/148748
https://support.qq.com/products/148747
https://support.qq.com/products/148746
https://support.qq.com/products/148745
https://support.qq.com/products/148744
https://support.qq.com/products/148743
https://support.qq.com/products/148742
https://support.qq.com/products/46622
https://support.qq.com/products/46620
https://support.qq.com/products/46618
https://support.qq.com/products/46616

0
#6 x****a 回复于2020-05-16

https://support.qq.com/products/46614
https://support.qq.com/products/46612
https://support.qq.com/products/46610
https://support.qq.com/products/46608
https://support.qq.com/products/46606
https://support.qq.com/products/149497
https://support.qq.com/products/149498
https://support.qq.com/products/149500
https://support.qq.com/products/149502
https://support.qq.com/products/149503
https://support.qq.com/products/149504
https://support.qq.com/products/149505
https://support.qq.com/products/149506
https://support.qq.com/products/149507
https://support.qq.com/products/149508
https://support.qq.com/products/149509
https://support.qq.com/products/149510
https://support.qq.com/products/149511
https://support.qq.com/products/149512
https://support.qq.com/products/149513

0
#7 x****a 回复于2020-05-16

https://support.qq.com/products/149515
https://support.qq.com/products/149516
https://support.qq.com/products/149517
https://support.qq.com/products/149518
https://support.qq.com/products/149519
https://support.qq.com/products/149520
https://support.qq.com/products/149521
https://support.qq.com/products/149522
https://support.qq.com/products/149523
https://support.qq.com/products/149524
https://support.qq.com/products/149525
https://support.qq.com/products/149526
https://support.qq.com/products/149527
https://support.qq.com/products/149528
https://support.qq.com/products/149529
https://support.qq.com/products/149530
https://support.qq.com/products/149531
https://support.qq.com/products/149532
https://support.qq.com/products/149533
https://support.qq.com/products/149534

0
#8 x****a 回复于2020-05-16

https://support.qq.com/products/149535
https://support.qq.com/products/149536
https://support.qq.com/products/149537
https://support.qq.com/products/149538
https://support.qq.com/products/149539
https://support.qq.com/products/149540
https://support.qq.com/products/149541
https://support.qq.com/products/149542
https://support.qq.com/products/149543
https://support.qq.com/products/149544
https://support.qq.com/products/149545
https://support.qq.com/products/149546
https://support.qq.com/products/149547
https://support.qq.com/products/149548
https://support.qq.com/products/149549
https://support.qq.com/products/149550
https://support.qq.com/products/149551
https://support.qq.com/products/149554
https://support.qq.com/products/149555
https://support.qq.com/products/149556

0
#9 x****a 回复于2020-05-16

https://support.qq.com/products/149557
https://support.qq.com/products/149558
https://support.qq.com/products/149559
https://support.qq.com/products/149560
https://support.qq.com/products/149561
https://support.qq.com/products/149562
https://support.qq.com/products/149563
https://support.qq.com/products/149564
https://support.qq.com/products/149565
https://support.qq.com/products/149566
https://support.qq.com/products/149568
https://support.qq.com/products/149569
https://support.qq.com/products/149570
https://support.qq.com/products/149571
https://support.qq.com/products/149572
https://support.qq.com/products/149573
https://support.qq.com/products/149574
https://support.qq.com/products/149575
https://support.qq.com/products/149576
https://support.qq.com/products/149577

0
#10 x****a 回复于2020-05-16

https://support.qq.com/products/149578
https://support.qq.com/products/149579
https://support.qq.com/products/149580
https://support.qq.com/products/149581
https://support.qq.com/products/149582
https://support.qq.com/products/149584
https://support.qq.com/products/149716
https://support.qq.com/products/149717
https://support.qq.com/products/149718
https://support.qq.com/products/149719
https://support.qq.com/products/149720
https://support.qq.com/products/149721
https://support.qq.com/products/149723
https://support.qq.com/products/149726
https://support.qq.com/products/149727
https://support.qq.com/products/149729
https://support.qq.com/products/149730
https://support.qq.com/products/149731
https://support.qq.com/products/149732
https://support.qq.com/products/149733
https://support.qq.com/products/149734

0
#11 x****a 回复于2020-05-16

https://support.qq.com/products/149735
https://support.qq.com/products/149736
https://support.qq.com/products/149739
https://support.qq.com/products/149741
https://support.qq.com/products/149742
https://support.qq.com/products/149744
https://support.qq.com/products/149745
https://support.qq.com/products/149748
https://support.qq.com/products/149750
https://support.qq.com/products/149751
https://support.qq.com/products/149752
https://support.qq.com/products/149754
https://support.qq.com/products/149755
https://support.qq.com/products/149756
https://support.qq.com/products/149757
https://support.qq.com/products/149758
https://support.qq.com/products/149761
https://support.qq.com/products/149762
https://support.qq.com/products/149763
https://support.qq.com/products/149764
https://support.qq.com/products/149769

0