ルートを動的に再計画する

Tour Planningは、車両が1台でも複数でも、旅程計画に大きなメリットをもたらします。特に役立つのは、ドライバーが旅程中に必要な調整(停車地の追加、スケジュールの変更、到着時刻の更新など)を行える、動的な旅程再計画機能です。

この機能は、変更した瞬間に旅程全体をリアルタイムで最適化でき、ドライバーの遅延や交通状況の変化、旅程中のジョブのキャンセルなど、予期せぬ障害に対処するために不可欠です。再計画を実施するために、顧客は現在の旅程の状態を反映した、更新されたパラメーターを含む新しい問題リクエストをAPIに送信します。

ℹ️

用語

このドキュメントにおける「顧客」とは、旅程計画業務を管理するツアーオペレーターまたはシステムユーザーを指します。顧客には更新された問題リクエストをAPIに送信して、再計画を開始する責任があります。

顧客が再計画を選択すると、再計画プロセスは次のように行われます。

  1. 初期計画:旅程は最適化され、計画され、ドライバーが完了に向けて旅程を開始します。
  2. ドライバーの進行状況:最初のジョブを終えた後、ドライバーは旅程計画に従って次の場所に移動します。
  3. 再計画のトリガー:状況が変化すると(たとえば交通状況による遅延、キャンセルなど)、顧客は新しい問題リクエストをAPIに送信します。
  4. 更新されたパラメーター:新しいリクエストは同じ問題構造を使用しますが、次の点が更新されています。
    • シフト開始位置は車両の現在の位置に設定される
    • シフト開始時刻には現在の時刻が反映される
    • 完了済みのジョブはジョブリストから削除される
    • 車両の積載量には残りの積載可能容量が反映される
  5. 新しいソリューション:APIは現在の状況に基づき、残りのジョブに対して最適化されたソリューションを返します。

このアプローチにより、ドライバーは現実世界の状況に基づく、常に最新かつ最適化されたルートを把握できます。

サンプルシナリオ:変化する状況に適応する

次の例は、旅程遂行時の状況の変化に再計画がどのように適応するかを示しています。

この例は、次の図に示すように、10品目の積載能力のある車両が、さまざまな場所で6つのジョブを完了する必要があり、そのうちの1つ(Job_6)の優先度が高い("priority": 1)という単純な状況をモデル化します。

地図上に視覚化された倉庫とジョブのロケーション

次のセクションには、出発点となる問題のJSON全体を示します。

{
  "fleet": {
    "types": [
      {
        "id": "Vehicle_1",
        "profile": "car_1",
        "costs": {
          "fixed": 9.0,
          "distance": 0.004,
          "time": 0.005
        },
        "shifts": [
          {
            "start": {
              "time": "2021-08-27T08:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            },
            "end": {
              "time": "2021-08-27T18:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            }
          }
        ],
        "capacity": [
          10
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car_1"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "job_1",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T09:03:00Z",
                      "2021-08-27T18:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.59175589353722,
                    "lng": 13.350747750372257
                  },
                  "duration": 360
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_2",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T11:03:00Z",
                      "2021-08-27T20:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.43363386232821,
                    "lng": 13.403232562191313
                  },
                  "duration": 540
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_3",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.473321658918245,
                    "lng": 13.28972099097991
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_4",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.503321,
                    "lng": 13.299720
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_5",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.403321658918245,
                    "lng": 13.19972099097991
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_6",
        "priority": 1,
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T14:03:00Z",
                      "2021-08-27T17:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.54165532725351,
                    "lng": 13.365047170290309
                  },
                  "duration": 1140
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      }
    ]
  }
}

初期の最適化ソリューション

最適化後、ドライバーは旅程の実行を開始します。最初のソリューションでは、次のジョブシーケンスが指定されます。

flowchart LR
    D0("Depot")
    J2(("1<br/>Job_2"))
    J5(("2<br/>Job_3"))
    J3(("3<br/>Job_5"))
    J4(("4<br/>Job_4"))
    J1(("5<br/>Job_1"))
    J6(("6<br/>Job_6"))
    
    D0 ==> J2 ==> J5 ==> J3 ==> J4 ==> J1 ==> J6 ==> D0

    classDef depot fill:#2adace,stroke:#2da0a6,stroke-width:5px,color:#000,font-weight:bold;
    classDef stop fill:#2e9e58,stroke:#1f7a43,stroke-width:5px,color:#fff;
    classDef priority fill:#f4c430,stroke:#1f7a43,stroke-width:5px,color:#111,font-weight:bold;

    class D0 depot;
    class J2,J5,J3,J4,J1 stop;
    class J6 priority;
📘

注

job_6は最も優先度が高いものの、すべてのジョブをスケジュールどおりに完了するだけの時間の余裕があるため、ドライバーはこれを最後に実行します。旅程の順序は、ジョブの優先順位によって決まるわけではありません。最も重要なジョブが最適な方法で旅程に含まれるようにします。詳細については、「ジョブに優先順位を付ける」を参照してください。

ソリューションのJSON全体は次のセクションで参照してください。

{
  "statistic": {
    "cost": 385.917,
    "distance": 80348,
    "duration": 11105,
    "times": {
      "driving": 7085,
      "serving": 4020,
      "waiting": 0,
      "stopping": 0,
      "break": 0,
      "intraStop": 0
    },
    "intraStopDistance": 0
  },
  "tours": [
    {
      "vehicleId": "Vehicle_1_1",
      "typeId": "Vehicle_1",
      "stops": [
        {
          "time": {
            "arrival": "2021-08-27T08:03:00Z",
            "departure": "2021-08-27T11:21:07Z"
          },
          "load": [
            6
          ],
          "activities": [
            {
              "jobId": "departure",
              "type": "departure",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              },
              "time": {
                "start": "2021-08-27T08:03:00Z",
                "end": "2021-08-27T11:21:07Z",
                "arrival": "2021-08-27T08:03:00Z"
              }
            }
          ],
          "location": {
            "lat": 52.530971,
            "lng": 13.384915
          },
          "distance": 0
        },
        {
          "time": {
            "arrival": "2021-08-27T11:45:13Z",
            "departure": "2021-08-27T11:54:13Z"
          },
          "load": [
            5
          ],
          "activities": [
            {
              "jobId": "job_2",
              "type": "delivery",
              "location": {
                "lat": 52.43363386232821,
                "lng": 13.403232562191311
              },
              "time": {
                "start": "2021-08-27T11:45:13Z",
                "end": "2021-08-27T11:54:13Z",
                "arrival": "2021-08-27T11:45:13Z"
              }
            }
          ],
          "location": {
            "lat": 52.43363386232821,
            "lng": 13.403232562191311
          },
          "distance": 13567
        },
        {
          "time": {
            "arrival": "2021-08-27T12:12:30Z",
            "departure": "2021-08-27T12:23:30Z"
          },
          "load": [
            4
          ],
          "activities": [
            {
              "jobId": "job_3",
              "type": "delivery",
              "location": {
                "lat": 52.473321658918245,
                "lng": 13.28972099097991
              },
              "time": {
                "start": "2021-08-27T12:12:30Z",
                "end": "2021-08-27T12:23:30Z",
                "arrival": "2021-08-27T12:12:30Z"
              }
            }
          ],
          "location": {
            "lat": 52.473321658918245,
            "lng": 13.28972099097991
          },
          "distance": 27630
        },
        {
          "time": {
            "arrival": "2021-08-27T12:43:00Z",
            "departure": "2021-08-27T12:54:00Z"
          },
          "load": [
            3
          ],
          "activities": [
            {
              "jobId": "job_5",
              "type": "delivery",
              "location": {
                "lat": 52.40332165891824,
                "lng": 13.19972099097991
              },
              "time": {
                "start": "2021-08-27T12:43:00Z",
                "end": "2021-08-27T12:54:00Z",
                "arrival": "2021-08-27T12:43:00Z"
              }
            }
          ],
          "location": {
            "lat": 52.40332165891824,
            "lng": 13.19972099097991
          },
          "distance": 40010
        },
        {
          "time": {
            "arrival": "2021-08-27T13:12:44Z",
            "departure": "2021-08-27T13:23:44Z"
          },
          "load": [
            2
          ],
          "activities": [
            {
              "jobId": "job_4",
              "type": "delivery",
              "location": {
                "lat": 52.503321,
                "lng": 13.29972
              },
              "time": {
                "start": "2021-08-27T13:12:44Z",
                "end": "2021-08-27T13:23:44Z",
                "arrival": "2021-08-27T13:12:44Z"
              }
            }
          ],
          "location": {
            "lat": 52.503321,
            "lng": 13.29972
          },
          "distance": 57475
        },
        {
          "time": {
            "arrival": "2021-08-27T13:43:39Z",
            "departure": "2021-08-27T13:49:39Z"
          },
          "load": [
            1
          ],
          "activities": [
            {
              "jobId": "job_1",
              "type": "delivery",
              "location": {
                "lat": 52.59175589353722,
                "lng": 13.350747750372255
              },
              "time": {
                "start": "2021-08-27T13:43:39Z",
                "end": "2021-08-27T13:49:39Z",
                "arrival": "2021-08-27T13:43:39Z"
              }
            }
          ],
          "location": {
            "lat": 52.59175589353722,
            "lng": 13.350747750372255
          },
          "distance": 70991
        },
        {
          "time": {
            "arrival": "2021-08-27T14:03:00Z",
            "departure": "2021-08-27T14:22:00Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "job_6",
              "type": "delivery",
              "location": {
                "lat": 52.54165532725351,
                "lng": 13.365047170290309
              },
              "time": {
                "start": "2021-08-27T14:03:00Z",
                "end": "2021-08-27T14:22:00Z",
                "arrival": "2021-08-27T14:03:00Z"
              }
            }
          ],
          "location": {
            "lat": 52.54165532725351,
            "lng": 13.365047170290309
          },
          "distance": 78381
        },
        {
          "time": {
            "arrival": "2021-08-27T14:26:12Z",
            "departure": "2021-08-27T14:26:12Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "arrival",
              "type": "arrival",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              },
              "time": {
                "start": "2021-08-27T14:26:12Z",
                "end": "2021-08-27T14:26:12Z",
                "arrival": "2021-08-27T14:26:12Z"
              }
            }
          ],
          "location": {
            "lat": 52.530971,
            "lng": 13.384915
          },
          "distance": 80348
        }
      ],
      "statistic": {
        "cost": 385.917,
        "distance": 80348,
        "duration": 11105,
        "times": {
          "driving": 7085,
          "serving": 4020,
          "waiting": 0,
          "stopping": 0,
          "break": 0,
          "intraStop": 0
        },
        "intraStopDistance": 0
      },
      "shiftIndex": 0
    }
  ]
}

ステップ2:job_2を完了した後の最初の再計画

job_2の完了後、顧客は現在の交通状況を考慮してルートを再計画する必要があります(図を参照)。再計画を開始するために、顧客は運行管理設定に以下の更新を加えた新しい問題リクエストをTour Planning APIに送信します。

  • シフト開始位置:元の倉庫からドライバーの現在の場所(job_2:52.43363386232821, 13.403232562191311)に更新しました。
  • シフトの開始時刻:元の開始時刻(08:03:00Z)からドライバーが出発した現在の時刻job_2 (11:54:13Z)に更新しました。
  • ジョブリスト:すでに完了しているjob_2は除きます。
  • 車両積載量:job_2で1つのアイテムを配送したため[10]のままですが、5個のアイテムが配送待ちです。

次のセクションに更新された問題設定を記載しています。

{
  "fleet": {
    "types": [
      {
        "id": "Vehicle_1",
        "profile": "car_1",
        "costs": {
          "fixed": 9.0,
          "distance": 0.004,
          "time": 0.005
        },
        "shifts": [
          {
            "start": {
              "time": "2021-08-27T11:54:13Z",
              "location": {
                "lat": 52.43363386232821,
                "lng": 13.403232562191311
              }
            },
            "end": {
              "time": "2021-08-27T18:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            }
          }
        ],
        "capacity": [
          10
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car_1"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "job_1",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T09:03:00Z",
                      "2021-08-27T18:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.59175589353722,
                    "lng": 13.350747750372257
                  },
                  "duration": 360
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_3",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.473321658918245,
                    "lng": 13.28972099097991
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_4",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.503321,
                    "lng": 13.299720
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_5",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.403321658918245,
                    "lng": 13.19972099097991
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_6",
        "priority": 1,
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T14:03:00Z",
                      "2021-08-27T17:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.54165532725351,
                    "lng": 13.365047170290309
                  },
                  "duration": 1140
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      }
    ]
  }
}

次のチャートに示すとおり、残りのジョブがjob_3、job_5、job_4、job_1、job_6の順に並べられ、最適化された新しいソリューションとしてAPIにより返されます。

flowchart LR
    J2completed(("-<br>Job_2"))
    D0("Depot")
    J2("Job_2 lat/lon")
    J3(("1<br/>Job_3"))
    J5(("2<br/>Job_5"))
    J4(("3<br/>Job_4"))
    J1(("4<br/>Job_1"))
    J6(("5<br/>Job_6"))
    
    J2completed -. Completed<br>+ heavy traffic .->  J2 ==> J3 ==> J5 ==> J4 ==> J1 ==> J6 ==> D0

    classDef depot fill:#2adace,stroke:#2da0a6,stroke-width:5px,color:#000,font-weight:bold;
    classDef stop fill:#2e9e58,stroke:#1f7a43,stroke-width:5px,color:#fff;
    classDef priority fill:#f4c430,stroke:#1f7a43,stroke-width:5px,color:#111,font-weight:bold;
    classDef completed fill:#eeeeee,stroke:#cccccc,stroke-width:2px,color:#999;

    class J2completed completed;
    class D0,J2 depot;
    class J5,J3,J4,J1 stop;
    class J6 priority

チャートには完了済みのJob_2が表示されていますが、旅程計画には含まれていません。

ソリューションのJSON全体は次のセクションで参照してください。

{
  "statistic": {
    "cost": 321.71900000000005,
    "distance": 66781,
    "duration": 9119,
    "times": {
      "driving": 5639,
      "serving": 3480,
      "waiting": 0,
      "stopping": 0,
      "break": 0,
      "intraStop": 0
    },
    "intraStopDistance": 0
  },
  "tours": [
    {
      "vehicleId": "Vehicle_1_1",
      "typeId": "Vehicle_1",
      "stops": [
        {
          "time": {
            "arrival": "2021-08-27T11:54:13Z",
            "departure": "2021-08-27T11:54:13Z"
          },
          "load": [
            5
          ],
          "activities": [
            {
              "jobId": "departure",
              "type": "departure",
              "location": {
                "lat": 52.43363386232821,
                "lng": 13.403232562191311
              },
              "time": {
                "start": "2021-08-27T11:54:13Z",
                "end": "2021-08-27T11:54:13Z",
                "arrival": "2021-08-27T11:54:13Z"
              }
            }
          ],
          "location": {
            "lat": 52.43363386232821,
            "lng": 13.403232562191311
          },
          "distance": 0
        },
        {
          "time": {
            "arrival": "2021-08-27T12:12:30Z",
            "departure": "2021-08-27T12:23:30Z"
          },
          "load": [
            4
          ],
          "activities": [
            {
              "jobId": "job_3",
              "type": "delivery",
              "location": {
                "lat": 52.473321658918245,
                "lng": 13.28972099097991
              },
              "time": {
                "start": "2021-08-27T12:12:30Z",
                "end": "2021-08-27T12:23:30Z",
                "arrival": "2021-08-27T12:12:30Z"
              }
            }
          ],
          "location": {
            "lat": 52.473321658918245,
            "lng": 13.28972099097991
          },
          "distance": 14063
        },
        {
          "time": {
            "arrival": "2021-08-27T12:43:00Z",
            "departure": "2021-08-27T12:54:00Z"
          },
          "load": [
            3
          ],
          "activities": [
            {
              "jobId": "job_5",
              "type": "delivery",
              "location": {
                "lat": 52.40332165891824,
                "lng": 13.19972099097991
              },
              "time": {
                "start": "2021-08-27T12:43:00Z",
                "end": "2021-08-27T12:54:00Z",
                "arrival": "2021-08-27T12:43:00Z"
              }
            }
          ],
          "location": {
            "lat": 52.40332165891824,
            "lng": 13.19972099097991
          },
          "distance": 26443
        },
        {
          "time": {
            "arrival": "2021-08-27T13:12:44Z",
            "departure": "2021-08-27T13:23:44Z"
          },
          "load": [
            2
          ],
          "activities": [
            {
              "jobId": "job_4",
              "type": "delivery",
              "location": {
                "lat": 52.503321,
                "lng": 13.29972
              },
              "time": {
                "start": "2021-08-27T13:12:44Z",
                "end": "2021-08-27T13:23:44Z",
                "arrival": "2021-08-27T13:12:44Z"
              }
            }
          ],
          "location": {
            "lat": 52.503321,
            "lng": 13.29972
          },
          "distance": 43908
        },
        {
          "time": {
            "arrival": "2021-08-27T13:43:39Z",
            "departure": "2021-08-27T13:49:39Z"
          },
          "load": [
            1
          ],
          "activities": [
            {
              "jobId": "job_1",
              "type": "delivery",
              "location": {
                "lat": 52.59175589353722,
                "lng": 13.350747750372255
              },
              "time": {
                "start": "2021-08-27T13:43:39Z",
                "end": "2021-08-27T13:49:39Z",
                "arrival": "2021-08-27T13:43:39Z"
              }
            }
          ],
          "location": {
            "lat": 52.59175589353722,
            "lng": 13.350747750372255
          },
          "distance": 57424
        },
        {
          "time": {
            "arrival": "2021-08-27T14:03:00Z",
            "departure": "2021-08-27T14:22:00Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "job_6",
              "type": "delivery",
              "location": {
                "lat": 52.54165532725351,
                "lng": 13.365047170290309
              },
              "time": {
                "start": "2021-08-27T14:03:00Z",
                "end": "2021-08-27T14:22:00Z",
                "arrival": "2021-08-27T14:03:00Z"
              }
            }
          ],
          "location": {
            "lat": 52.54165532725351,
            "lng": 13.365047170290309
          },
          "distance": 64814
        },
        {
          "time": {
            "arrival": "2021-08-27T14:26:12Z",
            "departure": "2021-08-27T14:26:12Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "arrival",
              "type": "arrival",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              },
              "time": {
                "start": "2021-08-27T14:26:12Z",
                "end": "2021-08-27T14:26:12Z",
                "arrival": "2021-08-27T14:26:12Z"
              }
            }
          ],
          "location": {
            "lat": 52.530971,
            "lng": 13.384915
          },
          "distance": 66781
        }
      ],
      "statistic": {
        "cost": 321.71900000000005,
        "distance": 66781,
        "duration": 9119,
        "times": {
          "driving": 5639,
          "serving": 3480,
          "waiting": 0,
          "stopping": 0,
          "break": 0,
          "intraStop": 0
        },
        "intraStopDistance": 0
      },
      "shiftIndex": 0
    }
  ]
}

ステップ3:job_3の配送の問題の後、2回目の再計画

job_3の完了時に配達先が不在だったため、指定された住所では荷物の直接配達を完了できませんでした(図を参照)。代わりにドライバーはアイテムを近くの集荷場所に配達したため、業務時間を延長する必要がありました。そのため顧客は、これらの新しい制約(配達場所の変更や予想される出発時刻の遅延など)を考慮しながら、旅程を再計算するための新しい問題リクエストを提出する必要があります。

これに基づくと、現在の問題の制約は次のように定義されます。

  • シフト開始位置:元のジョブ座標をJob_3の一時的な集荷場所(52.4696、13.30432)に更新しました。
  • シフトの開始時刻:出発時刻は、前のタスクの実際の完了時刻とその後の遅延を反映させるように調整されます(T12:38:38Zに更新)。
  • 残りのジョブ:最適化エンジンは、この新しい開始点の時刻と空間に基づいて、未配達のすべてのジョブ(job_5、job_4、job_1、job_6)の順序を再設定する必要があります。

更新された問題ファイル全体については、次のセクションを参照してください。

{
  "fleet": {
    "types": [
      {
        "id": "Vehicle_1",
        "profile": "car_1",
        "costs": {
          "fixed": 9,
          "distance": 0.004,
          "time": 0.005
        },
        "shifts": [
          {
            "start": {
              "time": "2021-08-27T12:38:38Z",
              "location": {
                "lat": 52.4696,
                "lng": 13.30432
              }
            },
            "end": {
              "time": "2021-08-27T18:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            }
          }
        ],
        "capacity": [
          10
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car_1"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "job_1",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T09:03:00Z",
                      "2021-08-27T18:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.59175589353722,
                    "lng": 13.350747750372257
                  },
                  "duration": 360
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_4",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.503321,
                    "lng": 13.29972
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_5",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.403321658918244,
                    "lng": 13.19972099097991
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_6",
        "priority": 1,
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T14:03:00Z",
                      "2021-08-27T17:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.54165532725351,
                    "lng": 13.365047170290309
                  },
                  "duration": 1140
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      }
    ]
  }
}

更新されたソリューションでは、以下のチャートに示すとおり、すでに完了したJob_2とJob_3に加え、残りのジョブがjob_5、job_4、job_1、job_6の順序に並べられています。

flowchart LR
    J2completed(("-<br>Job_2"))
    J3completed(("-<br>Job_3"))
    D0("Depot")
    J3("Backup location for Job_3")
    J5(("1<br/>Job_5"))
    J4(("2<br/>Job_4"))
    J1(("3<br/>Job_1"))
    J6(("4<br/>Job_6"))
    
    J2completed -. Completed<br>+ heavy traffic .->  J3completed -. Completed<br> at backup location .-> J3 ==> J5 ==> J4 ==> J1 ==> J6 ==> D0

    classDef depot fill:#2adace,stroke:#2da0a6,stroke-width:5px,color:#000,font-weight:bold;
    classDef stop fill:#2e9e58,stroke:#1f7a43,stroke-width:5px,color:#fff;
    classDef priority fill:#f4c430,stroke:#1f7a43,stroke-width:5px,color:#111,font-weight:bold;
    classDef completed fill:#eeeeee,stroke:#cccccc,stroke-width:2px,color:#999;

    class J3completed,J2completed completed;
    class D0,J3 depot;
    class J5,J4,J1 stop;
    class J6 priority

ソリューション全体を確認するには、次のセクションを参照してください。

{
  "statistic": {
    "cost": 258.379,
    "distance": 53066,
    "duration": 7423,
    "times": {
      "driving": 4603,
      "serving": 2820,
      "waiting": 0,
      "stopping": 0,
      "break": 0,
      "intraStop": 0
    },
    "intraStopDistance": 0
  },
  "tours": [
    {
      "vehicleId": "Vehicle_1_1",
      "typeId": "Vehicle_1",
      "stops": [
        {
          "time": {
            "arrival": "2021-08-27T12:38:38Z",
            "departure": "2021-08-27T12:38:38Z"
          },
          "load": [
            4
          ],
          "activities": [
            {
              "jobId": "departure",
              "type": "departure",
              "location": {
                "lat": 52.4696,
                "lng": 13.30432
              },
              "time": {
                "start": "2021-08-27T12:38:38Z",
                "end": "2021-08-27T12:38:38Z",
                "arrival": "2021-08-27T12:38:38Z"
              }
            }
          ],
          "location": {
            "lat": 52.4696,
            "lng": 13.30432
          },
          "distance": 0
        },
        {
          "time": {
            "arrival": "2021-08-27T12:59:09Z",
            "departure": "2021-08-27T13:10:09Z"
          },
          "load": [
            3
          ],
          "activities": [
            {
              "jobId": "job_5",
              "type": "delivery",
              "location": {
                "lat": 52.40332165891824,
                "lng": 13.19972099097991
              },
              "time": {
                "start": "2021-08-27T12:59:09Z",
                "end": "2021-08-27T13:10:09Z",
                "arrival": "2021-08-27T12:59:09Z"
              }
            }
          ],
          "location": {
            "lat": 52.40332165891824,
            "lng": 13.19972099097991
          },
          "distance": 12728
        },
        {
          "time": {
            "arrival": "2021-08-27T13:28:53Z",
            "departure": "2021-08-27T13:39:53Z"
          },
          "load": [
            2
          ],
          "activities": [
            {
              "jobId": "job_4",
              "type": "delivery",
              "location": {
                "lat": 52.503321,
                "lng": 13.29972
              },
              "time": {
                "start": "2021-08-27T13:28:53Z",
                "end": "2021-08-27T13:39:53Z",
                "arrival": "2021-08-27T13:28:53Z"
              }
            }
          ],
          "location": {
            "lat": 52.503321,
            "lng": 13.29972
          },
          "distance": 30193
        },
        {
          "time": {
            "arrival": "2021-08-27T13:59:48Z",
            "departure": "2021-08-27T14:05:48Z"
          },
          "load": [
            1
          ],
          "activities": [
            {
              "jobId": "job_1",
              "type": "delivery",
              "location": {
                "lat": 52.59175589353722,
                "lng": 13.350747750372255
              },
              "time": {
                "start": "2021-08-27T13:59:48Z",
                "end": "2021-08-27T14:05:48Z",
                "arrival": "2021-08-27T13:59:48Z"
              }
            }
          ],
          "location": {
            "lat": 52.59175589353722,
            "lng": 13.350747750372255
          },
          "distance": 43709
        },
        {
          "time": {
            "arrival": "2021-08-27T14:19:09Z",
            "departure": "2021-08-27T14:38:09Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "job_6",
              "type": "delivery",
              "location": {
                "lat": 52.54165532725351,
                "lng": 13.365047170290309
              },
              "time": {
                "start": "2021-08-27T14:19:09Z",
                "end": "2021-08-27T14:38:09Z",
                "arrival": "2021-08-27T14:19:09Z"
              }
            }
          ],
          "location": {
            "lat": 52.54165532725351,
            "lng": 13.365047170290309
          },
          "distance": 51099
        },
        {
          "time": {
            "arrival": "2021-08-27T14:42:21Z",
            "departure": "2021-08-27T14:42:21Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "arrival",
              "type": "arrival",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              },
              "time": {
                "start": "2021-08-27T14:42:21Z",
                "end": "2021-08-27T14:42:21Z",
                "arrival": "2021-08-27T14:42:21Z"
              }
            }
          ],
          "location": {
            "lat": 52.530971,
            "lng": 13.384915
          },
          "distance": 53066
        }
      ],
      "statistic": {
        "cost": 258.379,
        "distance": 53066,
        "duration": 7423,
        "times": {
          "driving": 4603,
          "serving": 2820,
          "waiting": 0,
          "stopping": 0,
          "break": 0,
          "intraStop": 0
        },
        "intraStopDistance": 0
      },
      "shiftIndex": 0
    }
  ]
}

ステップ4:job_5で大幅な遅延が発生後、3回目の再計画

交通状況の変化や車両の問題により、残りのジョブの完了が遅れるとします(図を参照)。その結果、ドライバーはかなり遅れてjob_5を完了します。予想された完了時刻は13:10でしたが、ドライバーはこれをT16:15:00Zに完了しました。

このステップで説明したシナリオに基づいて、顧客は問題設定に次の変更を加えた新しい問題リクエストを送信します。

  • シフト開始時刻の更新:シフト開始時刻はjob_3の実際の完了時刻(T16:15:00Z)を反映するように更新されました。
  • 新しいシフト開始場所:遅延したもののjob_5は正常に完了したため、その場所の制約が再計画の新たな出発点として更新された問題に組み込まれました。
  • 残りのジョブ:最適化エンジンは、この新しい開始点の時刻と空間に基づいて、未配達のすべてのジョブ(job_4、job_1、job_6)の順序を再設定する必要があります。

更新された問題のJSON全体については、次のセクションを参照してください。

{
  "fleet": {
    "types": [
      {
        "id": "Vehicle_1",
        "profile": "car_1",
        "costs": {
          "fixed": 9.0,
          "distance": 0.004,
          "time": 0.005
        },
        "shifts": [
          {
            "start": {
              "time": "2021-08-27T16:15:00Z",
              "location": {
                "lat": 52.403321658918245,
                "lng": 13.19972099097991
              }
            },
            "end": {
              "time": "2021-08-27T18:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            }
          }
        ],
        "capacity": [
          10
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car_1"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "job_1",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T09:03:00Z",
                      "2021-08-27T18:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.59175589353722,
                    "lng": 13.350747750372257
                  },
                  "duration": 360
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_4",
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T10:03:00Z",
                      "2021-08-27T16:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.503321,
                    "lng": 13.299720
                  },
                  "duration": 660
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      },
      {
        "id": "job_6",
        "priority": 1,
        "tasks": {
          "deliveries": [
            {
              "places": [
                {
                  "times": [
                    [
                      "2021-08-27T14:03:00Z",
                      "2021-08-27T17:03:00Z"
                    ]
                  ],
                  "location": {
                    "lat": 52.54165532725351,
                    "lng": 13.365047170290309
                  },
                  "duration": 1140
                }
              ],
              "demand": [
                1
              ]
            }
          ]
        }
      }
    ]
  }
}

この再計画により、動的な最適化の力が実証されました。遅延により、優先度の低い残りのジョブを時間枠内で完了することが不可能になるため、APIはjob_4(優先度なし)よりもjob_6(優先度1)を優先します。

次のチャートは、すでに完了したジョブと、未割り当てとしてマークされたJob_4を含む、更新された旅程の順序を示しています。

flowchart LR
    J2completed(("-<br>Job_2"))
    J3completed(("-<br>Job_3"))
    J5completed(("-<br>Job_5"))
    D0("Depot")
    J5("Job_5 lat/lon")
    J4(("!<br/>Job_4"))
    J1(("2<br/>Job_1"))
    J6(("1<br/>Job_6"))
    
    J2completed -. Completed<br>+ heavy traffic .->  J3completed -. Completed<br> at backup location .-> J5completed -. Completed<br>+ severe delay .-> J5 ==> J6 ==> J1 ==> D0

    classDef depot fill:#2adace,stroke:#2da0a6,stroke-width:5px,color:#000,font-weight:bold;
    classDef stop fill:#2e9e58,stroke:#1f7a43,stroke-width:5px,color:#fff;
    classDef priority fill:#f4c430,stroke:#1f7a43,stroke-width:5px,color:#111,font-weight:bold;
    classDef completed fill:#eeeeee,stroke:#cccccc,stroke-width:2px,color:#999;
    classDef unassigned fill:#a52520,stroke:#9298b3,stroke-width:5px,color:#111,font-weight:bold;

    class J2completed,J5completed,J3completed completed;
    class D0,J5 depot;
    class J1 stop;
    class J6 priority;
    class J4 unassigned;

次のセクションに完全なソリューションのJSONを示します。

{
  "statistic": {
    "cost": 201.655,
    "distance": 42000,
    "duration": 4931,
    "times": {
      "driving": 3431,
      "serving": 1500,
      "waiting": 0,
      "stopping": 0,
      "break": 0,
      "intraStop": 0
    },
    "intraStopDistance": 0
  },
  "tours": [
    {
      "vehicleId": "Vehicle_1_1",
      "typeId": "Vehicle_1",
      "stops": [
        {
          "time": {
            "arrival": "2021-08-27T16:15:00Z",
            "departure": "2021-08-27T16:15:00Z"
          },
          "load": [
            2
          ],
          "activities": [
            {
              "jobId": "departure",
              "type": "departure",
              "location": {
                "lat": 52.40332165891824,
                "lng": 13.19972099097991
              },
              "time": {
                "start": "2021-08-27T16:15:00Z",
                "end": "2021-08-27T16:15:00Z",
                "arrival": "2021-08-27T16:15:00Z"
              }
            }
          ],
          "location": {
            "lat": 52.40332165891824,
            "lng": 13.19972099097991
          },
          "distance": 0
        },
        {
          "time": {
            "arrival": "2021-08-27T16:42:28Z",
            "departure": "2021-08-27T17:01:28Z"
          },
          "load": [
            1
          ],
          "activities": [
            {
              "jobId": "job_6",
              "type": "delivery",
              "location": {
                "lat": 52.54165532725351,
                "lng": 13.365047170290309
              },
              "time": {
                "start": "2021-08-27T16:42:28Z",
                "end": "2021-08-27T17:01:28Z",
                "arrival": "2021-08-27T16:42:28Z"
              }
            }
          ],
          "location": {
            "lat": 52.54165532725351,
            "lng": 13.365047170290309
          },
          "distance": 25315
        },
        {
          "time": {
            "arrival": "2021-08-27T17:14:23Z",
            "departure": "2021-08-27T17:20:23Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "job_1",
              "type": "delivery",
              "location": {
                "lat": 52.59175589353722,
                "lng": 13.350747750372255
              },
              "time": {
                "start": "2021-08-27T17:14:23Z",
                "end": "2021-08-27T17:20:23Z",
                "arrival": "2021-08-27T17:14:23Z"
              }
            }
          ],
          "location": {
            "lat": 52.59175589353722,
            "lng": 13.350747750372255
          },
          "distance": 32982
        },
        {
          "time": {
            "arrival": "2021-08-27T17:37:11Z",
            "departure": "2021-08-27T17:37:11Z"
          },
          "load": [
            0
          ],
          "activities": [
            {
              "jobId": "arrival",
              "type": "arrival",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              },
              "time": {
                "start": "2021-08-27T17:37:11Z",
                "end": "2021-08-27T17:37:11Z",
                "arrival": "2021-08-27T17:37:11Z"
              }
            }
          ],
          "location": {
            "lat": 52.530971,
            "lng": 13.384915
          },
          "distance": 42000
        }
      ],
      "statistic": {
        "cost": 201.655,
        "distance": 42000,
        "duration": 4931,
        "times": {
          "driving": 3431,
          "serving": 1500,
          "waiting": 0,
          "stopping": 0,
          "break": 0,
          "intraStop": 0
        },
        "intraStopDistance": 0
      },
      "shiftIndex": 0
    }
  ],
  "unassigned": [
    {
      "jobId": "job_4",
      "reasons": [
        {
          "code": "TIME_WINDOW_CONSTRAINT",
          "description": "cannot be assigned due to violation of time window"
        }
      ]
    }
  ],
  "notices": [
    {
      "code": "jobHasIncorrectTimeWindows",
      "title": "Job job_4 has time window(s) not supported by any vehicle",
      "action": "Check whether the job or vehicles have correct time windows"
    }
  ]
}

ソリューションには、Job_4が割り当て解除された原因となった違反に関する情報と、推奨されるトラブルシューティング手順が含まれています。

"unassigned": [
  {
    "jobId": "job_4",
    "reasons": [
      {
        "code": "TIME_WINDOW_CONSTRAINT",
        "description": "cannot be assigned due to violation of time window"
      }
    ]
  }
],
"notices": [
  {
    "code": "jobHasIncorrectTimeWindows",
    "title": "Job job_4 has time window(s) not supported by any vehicle",
    "action": "Check whether the job or vehicles have correct time windows"
  }
]

概要

次のステップは、提示されたユースケースに基づく動的再計画プロセスを示しています。

初期再計画フェーズ

制約のもとで再計画

この例は、Tour Planning APIで動的再計画がどのように機能するかを示しています。

  • 再計画は、顧客が新しい問題リクエストをAPIに送信したときにトリガーされます。再計画は自動的なバックグラウンドプロセスで行われるのではありません。
  • 再計画リクエストのたびに、顧客が主要なパラメーターを更新する必要があります。
    • シフト開始位置:車両の現在位置に設定します。
    • シフトの開始時刻:現在の時刻に設定します。
    • ジョブリスト:完了済みのジョブを除外します。
    • 車両積載量:配送完了後の残りの積載量を反映します。
  • APIは、更新された制約に基づいて最適化された新しいソリューションを返すため、顧客は次のことに適応できます。
    • 交通状況の変化
    • 配送に関する問題
    • 大幅な遅延
    • ジョブのキャンセル

動的再計画により、顧客はドライバーが残りのジョブに最適なルートを常に把握できるようにすることで、現実の状況変化に対応できます。

次のステップ


このページは役に立ちましたか?