费用模型参数

OptimizeToursRequest 消息(RESTgRPC)包含与费用相关的多个属性。这些费用参数共同代表请求的费用模型。费用模型捕获了请求的许多概要信息, 优化目标,例如:

  • 优先选择较快的Vehicle路线,而不是较短的路线,反之亦然 周围
  • 确定提交 Shipment 的费用是否值得 Shipment完成
  • 只有在特定时间范围内执行自提和配送操作 性价比高

查看包含费用的请求示例

{
  "model": {
    "globalStartTime": "2023-01-13T16:00:00-08:00",
    "globalEndTime": "2023-01-14T16:00:00-08:00",
    "shipments": [
      {
        "deliveries": [
          {
            "arrivalLocation": {
              "latitude": 37.789456,
              "longitude": -122.390192
            },
            "duration": "250s"
          }
        ],
        "pickups": [
          {
            "arrivalLocation": {
              "latitude": 37.794465,
              "longitude": -122.394839
            },
            "duration": "150s"
          }
        ],
        "penaltyCost": 100.0
      },
      {
        "deliveries": [
          {
            "arrivalLocation": {
              "latitude": 37.789116,
              "longitude": -122.395080
            },
            "duration": "250s"
          }
        ],
        "pickups": [
          {
            "arrivalLocation": {
              "latitude": 37.794465,
              "longitude": -122.394839
            },
            "duration": "150s"
          }
        ],
        "penaltyCost": 5.0
      },
      {
        "deliveries": [
          {
            "arrivalLocation": {
              "latitude": 37.795242,
              "longitude": -122.399347
            },
            "duration": "250s"
          }
        ],
        "pickups": [
          {
            "arrivalLocation": {
              "latitude": 37.794465,
              "longitude": -122.394839
            },
            "duration": "150s"
          }
        ],
        "penaltyCost": 50.0
      }
    ],
    "vehicles": [
      {
        "endLocation": {
          "latitude": 37.794465,
          "longitude": -122.394839
        },
        "startLocation": {
          "latitude": 37.794465,
          "longitude": -122.394839
        },
        "costPerHour": 40.0,
        "costPerKilometer": 10.0
      }
    ]
  }
}
    

Vehicle 个费用属性

Vehicle 消息(RESTgRPC)有几个费用属性:

  • Vehicle.cost_per_hour:表示车辆每小时的运营费用 包括交通、等待、造访和休息时间。
  • Vehicle.cost_per_kilometer:表示每公里行程的费用 。
  • Vehicle.cost_per_traveled_hour:表示驾驶车辆的费用 仅在运输途中(不包括等待、访问和休息时间)显示。

这些成本参数让优化器可以得出时间与旅行距离的异同 权衡。优化路由所产生的费用显示在响应中 以 metrics.costs 的身份发送消息:

随着 costPerHour 的增加,优化器会尝试查找更快的路由 该路由可能不是最短路由。在本示例中,最快的路线恰好也是最短的路线,因此更改费用参数的影响不大。

Shipment 费用属性

Shipment 消息(RESTgRPC)也有几项开销 参数:

  • Shipment.penalty_cost 表示因跳过 送货。
  • Shipment.VisitRequest.cost 表示特定自提的费用,或 主要用于在多次自提或配送之间权衡 送货选项。

Shipment 费用参数与 Vehicle 费用参数使用相同的无量纲单位。完成 Shipment 所产生的费用超过其处罚费用, Shipment 未包含在任何 Vehicle 的路线中,而是显示在 skipped_shipments 列表。

ShipmentModel 个费用属性

ShipmentModel 消息(RESTgRPC)包含单一费用 属性:globalDurationCostPerHour。此费用按 所有车辆完成ShipmentRoute所需的时间。上升 globalDurationCostPerHour会优先考虑提前完成所有配送。

路由优化响应费用属性

OptimizeToursResponse 消息(RESTgRPC)具有费用属性 表示在完成 ShipmentRoute 的过程中产生的费用。 metrics.costsmetrics.totalCost 属性分别表示 响应中所有路由所产生的费用单位。每个 routes 条目具有 表示相关费用的 routeCostsrouteTotalCosts 属性 特定路线。

查看包含费用的示例请求的响应

{
  "routes": [
    {
      "vehicleStartTime": "2023-01-14T00:00:00Z",
      "vehicleEndTime": "2023-01-14T00:28:22Z",
      "visits": [
        {
          "isPickup": true,
          "startTime": "2023-01-14T00:00:00Z",
          "detour": "0s"
        },
        {
          "shipmentIndex": 2,
          "isPickup": true,
          "startTime": "2023-01-14T00:02:30Z",
          "detour": "150s"
        },
        {
          "startTime": "2023-01-14T00:08:55Z",
          "detour": "150s"
        },
        {
          "shipmentIndex": 2,
          "startTime": "2023-01-14T00:21:21Z",
          "detour": "572s"
        }
      ],
      "transitions": [
        {
          "travelDuration": "0s",
          "waitDuration": "0s",
          "totalDuration": "0s",
          "startTime": "2023-01-14T00:00:00Z"
        },
        {
          "travelDuration": "0s",
          "waitDuration": "0s",
          "totalDuration": "0s",
          "startTime": "2023-01-14T00:02:30Z"
        },
        {
          "travelDuration": "235s",
          "travelDistanceMeters": 795,
          "waitDuration": "0s",
          "totalDuration": "235s",
          "startTime": "2023-01-14T00:05:00Z"
        },
        {
          "travelDuration": "496s",
          "travelDistanceMeters": 1893,
          "waitDuration": "0s",
          "totalDuration": "496s",
          "startTime": "2023-01-14T00:13:05Z"
        },
        {
          "travelDuration": "171s",
          "travelDistanceMeters": 665,
          "waitDuration": "0s",
          "totalDuration": "171s",
          "startTime": "2023-01-14T00:25:31Z"
        }
      ],
      "metrics": {
        "performedShipmentCount": 2,
        "travelDuration": "902s",
        "waitDuration": "0s",
        "delayDuration": "0s",
        "breakDuration": "0s",
        "visitDuration": "800s",
        "totalDuration": "1702s",
        "travelDistanceMeters": 3353
      },
      "routeCosts": {
        "model.vehicles.cost_per_kilometer": 33.53,
        "model.vehicles.cost_per_hour": 18.911111111111111
      },
      "routeTotalCost": 52.441111111111113
    }
  ],
  "skippedShipments": [
    {
      "index": 1
    }
  ],
  "metrics": {
    "aggregatedRouteMetrics": {
      "performedShipmentCount": 2,
      "travelDuration": "902s",
      "waitDuration": "0s",
      "delayDuration": "0s",
      "breakDuration": "0s",
      "visitDuration": "800s",
      "totalDuration": "1702s",
      "travelDistanceMeters": 3353
    },
    "usedVehicleCount": 1,
    "earliestVehicleStartTime": "2023-01-14T00:00:00Z",
    "latestVehicleEndTime": "2023-01-14T00:28:22Z",
    "totalCost": 57.441111111111113,
    "costs": {
      "model.vehicles.cost_per_kilometer": 33.53,
      "model.vehicles.cost_per_hour": 18.911111111111111,
      "model.shipments.penalty_cost": 5
    }
  }
}
    

在示例响应中,顶级 metrics.costs 如下:

{
  "metrics": {
    ...
    "costs": {
      "model.vehicles.cost_per_hour": 18.911111111111111,
      "model.vehicles.cost_per_kilometer": 33.53,
      "model.shipments.penalty_cost": 5
    }
  }
}

model.shipments.penalty_cost 值表示由于以下原因产生的费用: 跳过的运单skippedShipments属性会列出哪些运单 已跳过。

在此示例中,系统仅会跳过示例请求中的 model.shipments[1]model.shipments[1] 的惩罚性费用为 5 个单位,这与总和 model.shipments.penalty_cost 键。商品出货量较低 penaltyCost,而 Vehicle 的 40.0 costPerHour 和 10.0 costPerKilometer,比起直接送货,省去送货的成本效益更高 。

高级主题:费用和软限制条件

多个 OptimizeToursRequest 消息(RESTgRPC)属性 代表软约束,也就是 都无法得到满足

例如,车辆 LoadLimitRESTgRPC)约束条件 softMaxLoadcostPerUnitAboveSoftMax 属性。同时,它们会产生 与超过 softMaxLoad 的加载单元成比例,从而允许 只有在从成本角度看有意义的做法时,才应超过限制。

同样,TimeWindow 约束条件(RESTgRPC)具有 soft_start_timesoft_end_time 属性,相应的 cost_per_hour_before_soft_start_timecost_per_hour_after_soft_end_time 会根据受约束事件相对于 TimeWindow 的发生时间而产生。

与所有成本模型参数一样,软约束成本以 使用与其他费用参数相同的无维度单位。

如需详细了解 LoadLimit 约束条件,请参阅 负载需求和限制。详细介绍了 TimeWindow 约束条件 提货和送货时间范围限制部分。