-1

I am working with a fleet management system. I have a scenario that driver have to go multiple places to pickup and deliver the pickup product in multiple delivery location.

Here i have a scenario like that,

Order 1 - Pickup (P1 time range 10:00AM to 11:00 AM) 10 Product. it has 3 delivery point in different location in any time can be delivered with in shift (D1,D2,D3) all of the picked product will delivered in delivered location .

Order 2 - Pickup (P2 time range 11:00AM to 12:00 PM) 10 Product. it has 3 delivery point in different location in any time can be delivered with in shift (D4,D5,D6) all of the picked product will delivered in delivered location .

Order 3 - Pickup (P3 time range 10:30AM to 11:30 PM) 10 Product. it has 3 delivery point in different location in any time can be delivered with in shift (D7,D8,D9) all of the picked product will delivered in delivered location .

in above scenario we have a restriction that if pickup is not complete then we can't make the delivery of this order like if P1 is not complete then we can't complete D1,D2 or D3.

so our optimized list should be set priority wise. We are getting optimized stop but some time we are getting delivery stop is coming before pickup stop. so we want to prevent this things.

is there any instruction to do this using Here Tour Planning API.

Maruf Ahamed
  • 11
  • 1
  • 3

1 Answers1

0

VRP with Multi-Jobs

A multi-job as opposed to a simple job is a job that consists of multiple pickups and deliveries. The specific of such jobs is that they only can be considered as executed when all the tasks inside the job are done, otherwise, none of them will be executed. Also, the sum of demands for pickups and deliveries must be equal. A very common scenario for a multi-job problem could be executing multiple pickups at different locations followed by delivery to a single location.

We can imagine the multi-job VRP in real life as for example a daily routine of a school bus that has to pick up several children at different addresses and deliver them to school. As we can guess, taking the kids back to their homes from the school by the same school bus is a multi-job VRP as well.

Another example of multi-job VRP use in real life is the work of garbage collection companies when a vehicle has to execute several pickups and one delivery within the job (collect garbage from several locations in the city and deliver it to the dump location).

So let’s consider we have a multi-job with several pickups and one delivery in it. Let’s say we need to deliver 3 children to the local school from their specific address via the school bus. Regarding the vehicle, we need it to start and end the shift at one depo, that is at the same location. We specify the routine vehicle constraints like cost, distance, shift time, location, capacity and amount. Note that In the case of a school bus, for example, you may assume your capacity units as people/children.

{
  "fleet": {
    "types": [
      {
        "id": "b0130d2f754d",
        "profile": "car_1",
        "costs": {
          "fixed": 5.0,
          "distance": 0.007,
          "time": 0.002
        },
        "shifts": [
          {
            "start": {
              "time": "2021-08-27T08:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            },
            "end": {
              "time": "2021-08-27T16:03:00Z",
              "location": {
                "lat": 52.48693181589403,
                "lng": 13.308748991045801
              }
            }
          }
        ],
        "capacity": [
          20
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car_1"
      }
    ]
  },

Regarding the jobs, in this very case, you can set them depending on your needs. One way is to add all of your pickups as separate jobs and then add a delivery job. The other way is to use a multi-job. In this way, you may add a multi-job with all the pickups and one delivery at the end. Let's build a problem where we would have one multi-job with 3 pickups and 1 delivery to deliver all those pickups in one location. Problem

{
  "fleet": {
    "types": [
      {
        "id": "b0130d2f754d",
        "profile": "car_1",
        "costs": {
          "fixed": 5.0,
          "distance": 0.007,
          "time": 0.002
        },
        "shifts": [
          {
            "start": {
              "time": "2021-08-27T08:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            },
            "end": {
              "time": "2021-08-27T16:03:00Z",
              "location": {
                "lat": 52.530971,
                "lng": 13.384915
              }
            }
          }
        ],
        "capacity": [
          30
        ],
        "amount": 1
      }
    ],
    "profiles": [
      {
        "type": "car",
        "name": "car_1"
      }
    ]
  },
  "plan": {
    "jobs": [
      {
        "id": "job_1",
        "tasks": {
          "pickups": [
            {
              "places": [
                {
                  "location": {
                    "lat": 52.47706593757918,
                    "lng": 13.390815701172201
                  },
                  "duration": 660,
                  "tag": "Address_1"
                }
              ],
              "demand": [
                1
              ]
            },
            {
              "places": [
                {
                  "location": {
                    "lat": 52.473571009931106,
                    "lng": 13.389035169086807
                  },
                  "duration": 1140,
                  "tag": "Address_2"
                }
              ],
              "demand": [
                1
              ]
            },
            {
              "places": [
                {
                  "location": {
                    "lat": 52.53090538774364,
                    "lng": 13.384692097156309
                  },
                  "duration": 840,
                  "tag": "Address_3"
                }
              ],
              "demand": [
                1
              ]
            }
          ],
          "deliveries": [
            {
              "places": [
                {
                  "location": {
                    "lat": 52.58919138279804,
                    "lng": 13.462161100698735
                  },
                  "duration": 1020,
                  "tag": "Address_4"
                }
              ],
              "demand": [
                3
              ]
            }
          ]
        }
      }
    ]
  }
}

Solution

The solution for this problem will look as follows:

{
    "statistic": {
        "cost": 273.77500000000003,
        "distance": 36041,
        "duration": 8244,
        "times": {
            "driving": 4584,
            "serving": 3660,
            "waiting": 0,
            "break": 0
        }
    },
    "tours": [
        {
            "vehicleId": "b0130d2f754d_1",
            "typeId": "b0130d2f754d",
            "stops": [
                {
                    "location": {
                        "lat": 52.530971,
                        "lng": 13.384915
                    },
                    "time": {
                        "arrival": "2021-08-27T08:03:00Z",
                        "departure": "2021-08-27T08:03:00Z"
                    },
                    "load": [
                        0
                    ],
                    "activities": [
                        {
                            "jobId": "departure",
                            "type": "departure"
                        }
                    ]
                },
                {
                    "location": {
                        "lat": 52.53090538774364,
                        "lng": 13.384692097156307
                    },
                    "time": {
                        "arrival": "2021-08-27T08:03:02Z",
                        "departure": "2021-08-27T08:17:02Z"
                    },
                    "load": [
                        1
                    ],
                    "activities": [
                        {
                            "jobId": "job_1",
                            "type": "pickup",
                            "jobTag": "Address_3"
                        }
                    ]
                },
                {
                    "location": {
                        "lat": 52.473571009931106,
                        "lng": 13.389035169086808
                    },
                    "time": {
                        "arrival": "2021-08-27T08:34:57Z",
                        "departure": "2021-08-27T08:53:57Z"
                    },
                    "load": [
                        2
                    ],
                    "activities": [
                        {
                            "jobId": "job_1",
                            "type": "pickup",
                            "jobTag": "Address_2"
                        }
                    ]
                },
                {
                    "location": {
                        "lat": 52.47706593757918,
                        "lng": 13.3908157011722
                    },
                    "time": {
                        "arrival": "2021-08-27T08:54:51Z",
                        "departure": "2021-08-27T09:05:51Z"
                    },
                    "load": [
                        3
                    ],
                    "activities": [
                        {
                            "jobId": "job_1",
                            "type": "pickup",
                            "jobTag": "Address_1"
                        }
                    ]
                },
                {
                    "location": {
                        "lat": 52.58919138279804,
                        "lng": 13.462161100698737
                    },
                    "time": {
                        "arrival": "2021-08-27T09:40:21Z",
                        "departure": "2021-08-27T09:57:21Z"
                    },
                    "load": [
                        0
                    ],
                    "activities": [
                        {
                            "jobId": "job_1",
                            "type": "delivery",
                            "jobTag": "Address_4"
                        }
                    ]
                },
                {
                    "location": {
                        "lat": 52.530971,
                        "lng": 13.384915
                    },
                    "time": {
                        "arrival": "2021-08-27T10:20:24Z",
                        "departure": "2021-08-27T10:20:24Z"
                    },
                    "load": [
                        0
                    ],
                    "activities": [
                        {
                            "jobId": "arrival",
                            "type": "arrival"
                        }
                    ]
                }
            ],
            "statistic": {
                "cost": 273.77500000000003,
                "distance": 36041,
                "duration": 8244,
                "times": {
                    "driving": 4584,
                    "serving": 3660,
                    "waiting": 0,
                    "break": 0
                }
            }
        }
    ]
}

From this solution we can see that the vehicle starts its way from a depot, after that it executes 3 pickup and 1 delivery multi-job, and arrives back to the depot.

See also the documentation here

  • i see this solution in the documentation but in my case each pickup has multiple delivery, how to solve this problem. – Maruf Ahamed Aug 17 '22 at 11:36
  • Please, use the example provided in documentation leave only one 1 pickup task and add your deliveries as tasks to “deliveries” array. –  Aug 24 '22 at 09:27