Pickup and Delivery Routing

A special case of the classical Vehicle Routing Problem is the Pickup and Delivery Problem. Each order has a pickup location and a drop-off location that are mutually dependent. An item can only be dropped off after it has been picked up by the same driver.

The Solvice solver will find the optimal routes to do all your orders, so it may often occur that you pick up multiple orders before you drop them off. If you specify capacity constraints, it will ensure that your vehicles won't try to carry more than they can hold.

Some example use-cases:

  • same-day courier
  • taxi services
  • moving companies
  • transportation services
  • third-party restaurant delivery
  • garbage pickups
  • etc...

First off, but most importantly, you should define that the problem is a PDP, by setting the solver property to "PDP" in the payload.

Usage of Pickup and Delivery API is mostly identical with the normal Vehicle Routing API, with only one difference: the way we define pickup and delivery orders. If an item has to reach a certain location, you have to pick it up first (i.e. create a pickup order with activity : "pickup") and then drop it of in another location (i.e. create a dropoff order with activity : "dropoff").

In the example on the right, you can see one order (order0) which has a pickup requirement in the centre of Ghent and a delivery requirement (see the next tab) in the city of Antwerp. It takes 10 minutes to pickup and 10 minutes to deliver and it accounts for 3 units of the load in a vehicle. Mind that the property ride alerts the solver that its about the same ride!

Input

An input for a solve request for a PDP problem requires several data:

  • locations
  • orders
  • vehicles

Locations

Define the list of locations.

Property

Description

name
(string)

Unique identifier for location name

latitude
(number)

Latitude in WSG84

longitude
(number)

Longitude in WSG84

Orders

Property

Description

Type

name

The unique name of the order

string

location

The name of the location where this order is located. (refers to location list)

string

ride

The name of the ride of a pickup or a dropoff.

string

activity

The activity of the order. "pickup" or "dropoff".

string

duration

Duration of the service (in minutes)

integer

type

Type restriction. Only vehicles with the same type string can perform the orders for which this type is present.

string

demand

Demand for capacity type 1. Can be in volumetric measures.

integer

windows

Time windows that restrict the time at which this order is scheduled.

array of Window

allowedVehicles

List of vehicle id's that are allowed to process this order.

array of string

disallowedVehicles

List of vehicle id's that are NOT allowed to process this order.

array of string

Fleet

The fleet consists of your vehicles, that you want to allocate the orders to. Each vehicle is defined by a starting and ending location (referencing a location on the network), and the shift start and end times.

Property

Description

Type

name

Unique identifier for vehicle name

string

startlocation

The name of the location where the vehicle starts

string

endlocation

The name of the location where the vehicle ends

string

shiftstart

Starting time of the shift in minutes (0-1439)

integer

shiftend

End time of the shift in minutes (0-1439)

integer

capacity

Capacity available in the vehicle.

integer

type

Type restrictions. These should match with the type requirements of an Order.

array of string

overtime

Checks whether this vehicle can go into overtime.

boolean

breaks

Break definitions

Break object

The end location is optional and may be omitted. This may be useful in cases when you care less about total distance traveled, and instead would like to prioritize your visits closeby to be done as soon as possible. The reason why this works is because Solvice OnRoute minimizes total travel time, and may leave closeby visits for on the way back.

Optionally, you may define the capacity of the vehicle (using the same unit as the "weight" for your orders). The algorithm will make sure that this capacity will not be exceeded. You can define 2 types of capacity: e.g. one for weight (in pounds, kilos, tons) and one for volume (square meters, cube meters)

If you are using type restrictions on your visits, make sure you also define the same types for your vehicles in the type parameter. This value is an array of strings for multiple types. Vehicles without any type will still be able to serve the visits that have no type restrictions. Examples of type restrictions: "Technician", "Maintenance", ...

If a vehicle can do overtime, then the shift end constraint is not seen as hard and then it is possible that some orders are scheduled after shift end. overtime_end determines the maximum of overtime.

Breaks

A break can be scheduled between a certain break interval (breakstart and breakend) and can take a pre-defined amount of time (breakduration).

Parameter

Description

Type

breakstart

Earliest starting time of a break

integer

breakend

Latest ending time of a break

integer

breakduration

Duration of a break

integer

Introducing breaks will require more computation time, as they are seen as visits in the solution.

Options

Specific options can be added to guide the solving process.

Property

Description

Type

traffic

Traffic modifier. Default at 1.0. All travel times get multiplied with the traffic parameter.

double

overconstrained

Indicates to not plan all orders, but only the feasible ones.

boolean

minimize_driver_wait_time

Wait time should be minimized.

boolean

minimize_vehicle_use

The least number of vehicles should be used.

boolean

Output

After checking that the status is solved, you can fetch the solution in the solution endpoint. The solution endpoint will return a list of visits per vehicle. Additionally, the score function will be presented as well as the unresolved constraints.

Score

Scoring an optimisation solution is done by dividing between soft and hard constraints.
Hard constraints are required constraints, while soft constraints force the solution in a certain direction as objective functions. For more information, see the section on What is Optimisation?

In the following example, the score is given for a simple optimisation question where you can see that there is no hard constraint violation (resulting in a hard score of 0) and the soft score results in 59 score points while aiming to reach to zero. This means that the solution is feasible according to the constraints.

{
    "score": {
        "hardScore": 0,
        "softScore": -59,
        "feasible": true
    }
}

Unresolved constraints

Some constraints cannot be resolved and are left violated. In the unresolved section in the solution, we show the constraints that are violated in a list with their respective score value.

"unresolved": [
    {
      "name": "Vehicle Capacity",
      "value": -4,
      "level": "HARD"
    }
  ]

Solution

The actual solution is a map of a list of visits to the vehicle name.

{
  "solution ": {
    "driver1": [
      {
        "location ": "loc0 ",
        "order ": null,
        "arrival ": 510,
        "finish ": 510,
        "wait ": 0,
        "drive ": 0,
        "distance ": 0
      },
      {
        "location ": "loc1 ",
        "order ": "order1 ",
        "arrival ": 504,
        "finish ": 534,
        "wait ": 0,
        "drive ": 24,
        "distance ": 24
      }
    ]
  }
}

Visit object

Property

Description

Type

location

The location name of the visit

string

order

The order name of the visit.

string

arrival

The arrival time of that visit in minutes starting from midnight.

integer

finish

The finish time of that visit in minutes starting from midnight. >= arrival

integer

wait

The waiting time at that visit, if applicable in minutes.

integer

drive

The driving / travel time from this visit to the next visit in minutes

integer

distance

The travel distance from this visit to the next visit in minutes.

integer

Example

{
    "solver": "VRP",
    "options": {
        "capacitySpread": true
    },
    "locations": [
        {
            "name": "loc0",
            "latitude": 51.12317420299715,
            "longitude": 5.281797793554478
        },
        {
            "name": "loc1",
            "latitude": 50.65329310557439,
            "longitude": 4.517600740757033
        },
        {
            "name": "loc2",
            "latitude": 51.20586951408341,
            "longitude": 5.050825570502835
        },
        {
            "name": "loc3",
            "latitude": 51.116048511299724,
            "longitude": 3.4438340449873435
        }
    ],
    "fleet": [
        {
            "name": "drive John",
            "startlocation": "loc0",
            "shiftstart": 500,
            "shiftend": 1439,
            "type": [
                "Technician"
            ]
        },
        {
            "name": "driver Joe",
            "startlocation": "loc2",
            "endlocation": "loc1",
            "shiftstart": 500,
            "shiftend": 900,
            "type": [
                "Maintenance"
            ]
        }
    ],
    "orders": [
        {
            "name": "order0 pickup",
            "location": "loc2",
            "windows": [
                {
                    "starttime": 480,
                    "endtime": 720,
                    "hard": true
                },
                {
                    "starttime": 780,
                    "endtime": 1020,
                    "hard": true
                }
            ],
            "duration": 30,
            "type": [
                "Technician"
            ]
        },
        {
            "name": "order1",
            "location": "loc1",
            "duration": 30
        },
        {
            "name": "order2",
            "location": "loc0",
            "demand": 2,
            "duration": 30
        },
        {
            "name": "order3",
            "location": "loc1",
            "demand": 2,
            "duration": 5
        }
    ]
}