Delivery Only

In this example, we have a fleet of heterogeneous vehicles that deliver two item types, box (volume of 1 unit) and big_box (volume of 2 units) as seen in the items array below

{
    "items": [
        {
            "item_type": "box",
            "volume": 1
        },
        {
            "item_type": "big_box",
            "volume": 2
        }
    ]
}

The vehicles are constrained both in terms of how much of each item they can carry as well as by maximum volume carried. Each vehicle’s capacity is expressed separately allowing for a truly heterogeneous fleet. Our vehicle object now looks like this

{
    "type": "car",
    "shifts": [
        {
            "break_end": [
                "2017-08-24T13:00:00-04:00"
            ],
            "break_start": [
                "2017-08-24T12:00:00-04:00"
            ],
            "shift_end": "2017-08-24T17:10:00-04:00",
            "shift_start": "2017-08-24T08:05:00-04:00",
            "shift_id": "v1shift"
        }
    ],
    "vehicle_id": "Vehicle1",
    "max_volume_carried": 40,
    "capacity_by_item": [
        {
            "quantity": 36,
            "item_type": "box"
        },
        {
            "quantity": 18,
            "item_type": "big_box"
        }
    ]
}

The orders also have a demand for some number of items of these types – this is expressed in their delivery_item_quantities as seen in the full request below. Note that there are no pickup_item_quantities at any of the orders so that this is a pure delivery problem where the optimization engine will determine how much of each item type each vehicle must start the route with.

{
    "orders": [
        {
            "order_id": "688798",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc1",
            "delivery_item_quantities": [
                {
                    "quantity": 3,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "689105",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc3",
            "delivery_item_quantities": [
                {
                    "quantity": 2,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "692039",
            "duration": 1800,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc5",
            "delivery_item_quantities": [
                {
                    "quantity": 4,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "583368",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc6",
            "delivery_item_quantities": [
                {
                    "quantity": 3,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "677048",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc7",
            "delivery_item_quantities": [
                {
                    "quantity": 2,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "685086",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc8",
            "delivery_item_quantities": [
                {
                    "quantity": 3,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "690020",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc9",
            "delivery_item_quantities": [
                {
                    "quantity": 4,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "674660",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc11",
            "delivery_item_quantities": [
                {
                    "quantity": 2,
                    "item_type": "big_box"
                },
                {
                    "quantity": 3,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "413170",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc13",
            "delivery_item_quantities": [
                {
                    "quantity": 6,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "685945",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc14",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "692592",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc15",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "678545",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc17",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                },
                {
                    "quantity": 5,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "692829",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc18",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "695124",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc19",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "693192",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc21",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "649953",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc22",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "694498",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc23",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "693854",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc24",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "688899",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc25",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "617086",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc26",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "340637",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc27",
            "delivery_item_quantities": [
                {
                    "quantity": 2,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "693098",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc28",
            "delivery_item_quantities": [
                {
                    "quantity": 3,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "683931",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc29",
            "delivery_item_quantities": [
                {
                    "quantity": 3,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "685382",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc30",
            "delivery_item_quantities": [
                {
                    "quantity": 4,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "691449",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc31",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "509217",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc32",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "691287",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc33",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "640723",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc34",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "665537",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc35",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "693858",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc36",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "392888",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc37",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "623404",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc38",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "695743",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc39",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "box"
                }
            ],
            "pickup_item_quantities": []
        },
        {
            "order_id": "692431",
            "duration": 600,
            "max_visits": 1,
            "min_visits": 1,
            "location_id": "loc40",
            "delivery_item_quantities": [
                {
                    "quantity": 1,
                    "item_type": "big_box"
                }
            ],
            "pickup_item_quantities": []
        }
    ],
    "vehicles": [
        {
            "type": "car",
            "shifts": [
                {
                    "break_end": [
                        "2017-08-24T13:00:00-04:00"
                    ],
                    "break_start": [
                        "2017-08-24T12:00:00-04:00"
                    ],
                    "shift_end": "2017-08-24T17:10:00-04:00",
                    "shift_start": "2017-08-24T08:05:00-04:00",
                    "shift_id": "v1shift"
                }
            ],
            "vehicle_id": "Vehicle1",
            "max_volume_carried": 40,
            "capacity_by_item": [
                {
                    "quantity": 36,
                    "item_type": "box"
                },
                {
                    "quantity": 18,
                    "item_type": "big_box"
                }
            ]
        },
        {
            "type": "car",
            "shifts": [
                {
                    "break_end": [
                        "2017-08-24T13:00:00-04:00"
                    ],
                    "break_start": [
                        "2017-08-24T12:00:00-04:00"
                    ],
                    "shift_end": "2017-08-24T17:10:00-04:00",
                    "shift_start": "2017-08-24T08:05:00-04:00",
                    "shift_id": "v2shift"
                }
            ],
            "vehicle_id": "Vehicle2",
            "max_volume_carried": 28,
            "capacity_by_item": [
                {
                    "quantity": 24,
                    "item_type": "box"
                },
                {
                    "quantity": 14,
                    "item_type": "big_box"
                }
            ]
        },
        {
            "type": "car",
            "shifts": [
                {
                    "break_end": [
                        "2017-08-24T10:00:00-04:00"
                    ],
                    "break_start": [
                        "2017-08-24T09:00:00-04:00"
                    ],
                    "shift_end": "2017-08-24T14:10:00-04:00",
                    "start_location_id": "loc16",
                    "end_location_id": "loc16",
                    "shift_start": "2017-08-24T07:05:00-04:00",
                    "shift_id": "v3shift"
                }
            ],
            "vehicle_id": "Vehicle3",
            "max_volume_carried": 30,
            "capacity_by_item": [
                {
                    "quantity": 28,
                    "item_type": "box"
                },
                {
                    "quantity": 14,
                    "item_type": "big_box"
                }
            ]
        },
        {
            "type": "car",
            "shifts": [
                {
                    "break_end": [
                        "2017-08-24T13:00:00-04:00"
                    ],
                    "break_start": [
                        "2017-08-24T12:00:00-04:00"
                    ],
                    "shift_end": "2017-08-24T17:10:00-04:00",
                    "start_location_id": "loc100",
                    "end_location_id": "loc100",
                    "shift_start": "2017-08-24T08:05:00-04:00",
                    "shift_id": "v4shift"
                }
            ],
            "vehicle_id": "Vehicle4",
            "max_volume_carried": 20,
            "capacity_by_item": [
                {
                    "quantity": 20,
                    "item_type": "box"
                },
                {
                    "quantity": 10,
                    "item_type": "big_box"
                }
            ]
        }
    ],
    "locations": [
        {
            "location_id": "loc1",
            "longitude": -84.07639,
            "latitude": 33.3300399
        },
        {
            "location_id": "loc2",
            "longitude": -84.4153667,
            "latitude": 33.5179638
        },
        {
            "location_id": "loc3",
            "longitude": -84.52763,
            "latitude": 34.07687
        },
        {
            "location_id": "loc4",
            "longitude": -85.15883,
            "latitude": 33.73872
        },
        {
            "location_id": "loc5",
            "longitude": -84.1256499,
            "latitude": 34.02463
        },
        {
            "location_id": "loc6",
            "longitude": -84.30268,
            "latitude": 33.78583
        },
        {
            "location_id": "loc7",
            "longitude": -84.5738499,
            "latitude": 34.07687
        },
        {
            "location_id": "loc8",
            "longitude": -83.7661399,
            "latitude": 33.98557
        },
        {
            "location_id": "loc9",
            "longitude": -84.69128,
            "latitude": 34.02403
        },
        {
            "location_id": "loc11",
            "longitude": -84.26431,
            "latitude": 33.57832
        },
        {
            "location_id": "loc12",
            "longitude": -84.51451,
            "latitude": 33.56882
        },
        {
            "location_id": "loc13",
            "longitude": -84.30606,
            "latitude": 33.8200999
        },
        {
            "location_id": "loc14",
            "longitude": -84.02126,
            "latitude": 33.98078
        },
        {
            "location_id": "loc15",
            "longitude": -84.20871,
            "latitude": 33.98596
        },
        {
            "location_id": "loc16",
            "longitude": -83.789905,
            "latitude": 34.098671
        },
        {
            "location_id": "loc17",
            "longitude": -84.3739,
            "latitude": 33.68959
        },
        {
            "location_id": "loc18",
            "longitude": -84.08495,
            "latitude": 33.8965699
        },
        {
            "location_id": "loc19",
            "longitude": -84.5491,
            "latitude": 34.0078
        },
        {
            "location_id": "loc20",
            "longitude": -84.78468,
            "latitude": 33.44852
        },
        {
            "location_id": "loc21",
            "longitude": -84.7372199,
            "latitude": 33.45099
        },
        {
            "location_id": "loc22",
            "longitude": -84.44377,
            "latitude": 33.7084199
        },
        {
            "location_id": "loc23",
            "longitude": -84.37416,
            "latitude": 34.0286
        },
        {
            "location_id": "loc24",
            "longitude": -84.23121,
            "latitude": 33.82054
        },
        {
            "location_id": "loc25",
            "longitude": -84.21402,
            "latitude": 33.83828
        },
        {
            "location_id": "loc26",
            "longitude": -84.31995,
            "latitude": 34.05614
        },
        {
            "location_id": "loc27",
            "longitude": -84.6712,
            "latitude": 33.7435386
        },
        {
            "location_id": "loc28",
            "longitude": -84.8082699,
            "latitude": 33.99045
        },
        {
            "location_id": "loc29",
            "longitude": -84.7469,
            "latitude": 33.84614
        },
        {
            "location_id": "loc30",
            "longitude": -84.23972,
            "latitude": 33.68736
        },
        {
            "location_id": "loc31",
            "longitude": -84.3845599,
            "latitude": 33.7757999
        },
        {
            "location_id": "loc32",
            "longitude": -84.1556,
            "latitude": 34.19941
        },
        {
            "location_id": "loc33",
            "longitude": -84.35911,
            "latitude": 33.75112
        },
        {
            "location_id": "loc34",
            "longitude": -83.707189,
            "latitude": 33.9854531
        },
        {
            "location_id": "loc35",
            "longitude": -84.36567,
            "latitude": 33.52079
        },
        {
            "location_id": "loc36",
            "longitude": -84.2661811,
            "latitude": 34.104
        },
        {
            "location_id": "loc37",
            "longitude": -84.20234,
            "latitude": 33.88826
        },
        {
            "location_id": "loc38",
            "longitude": -84.32034,
            "latitude": 33.4439
        },
        {
            "location_id": "loc39",
            "longitude": -84.23654,
            "latitude": 33.96681
        },
        {
            "location_id": "loc40",
            "longitude": -83.81919,
            "latitude": 34.1162
        },
        {
            "location_id": "loc99",
            "longitude": -85.0148499,
            "latitude": 34.07697
        },
        {
            "location_id": "loc100",
            "longitude": -84.52097,
            "latitude": 33.9157
        }
    ],
    "items": [
        {
            "item_type": "box",
            "volume": 1
        },
        {
            "item_type": "big_box",
            "volume": 2
        }
    ],
    "constraints": [
        {
            "constraint_name": "Make travel efficient",
            "max_travel_time_seconds": 0,
            "constraint_type": "Travel_Time",
            "violation_increment": 1,
            "penalty_per_violation": 1
        },
        {
            "constraint_name": "Visit as many orders as possible",
            "constraint_type": "Visit_Range",
            "violation_increment": 1,
            "penalty_per_violation": 100000
        }
    ]
}

img

In this case we use all 4 vehicles but are unable to visit 4 of the orders due to the capacity constraints on the vehicles. Below, we see the impact of doubling each vehicle’s capacity – we are now able to visit all the orders and actually only need 3 of the 4 vehicles to do so.

img

The impact of doubling vehicle capacity. In the API response, the items_delivered at each stop is given in an array

{
    "items_delivered": [
        {
            "item_type": "box",
            "quantity": 0,
            "cumulative_quantity": 0
        },
        {
            "item_type": "big_box",
            "quantity": 1,
            "cumulative_quantity": 1
        }
    ]
}

The optimization engine also determines how many items the vehicle must have on board when the shift begins. This is recorded in the start_items object of the route. By loading the vehicle with these items at the start of the route, all orders in the route will have their delivery demand satisfied.

{
    "start_items": [
        {
            "start_quantity": 11,
            "item_type": "box"
        },
        {
            "start_quantity": 9,
            "item_type": "big_box"
        }
    ]
}

Other features of the delivery aspect of the route are also included in the route object, such as max_volume_in_vehicle, max_num_items_in_vehicle.