費用模式參數

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 鍵。出貨少 penaltyCostVehicle 40.0 costPerHour 和 10.0 相比的結果 costPerKilometer 相較於略過貨品,更符合成本效益 才能完成更新。

進階主題:費用與彈性限制

多個 OptimizeToursRequest 訊息 (RESTgRPC) 屬性 代表「軟性限制」,也就是執行規則時會產生費用的限制 不符合回應

例如,車輛 LoadLimit (RESTgRPC) 限制具有 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 項限制條件 請參閱「取貨和送達時間限制」一文。