Add Optimization with Multiple Destinations
This example demonstrates how to create and optimize a fleet management solution using the Fleet Management Rest API with multiple vehicles ending their routes at different destinations. The example covers the following features:
- Adding an optimization with multiple vehicles and different destination locations.
- Defining orders with various fields (e.g., time windows, packages, weights).
- Setting up multiple vehicles with specific constraints.
- Displaying the optimized solution on a map.
In this optimization, multiple vehicles start their routes from a single departure point but end at different destinations, allowing for more flexible and efficient route planning.
How to Use the Sample
When you run the example application:
- An optimization is created and saved.
- The optimized solution is returned and displayed on the map.
Step-by-Step Guide
Step 1: Create Customers and Orders
Each order must have a customer associated with it. You can either:
- Create a new customer and assign it to the order.
- Use an existing customer (refer to the Get Customer example).
Initializing and Adding Customers
- Initialize Customers: Create twelve
Customerobjects and populate their fields (e.g., name, address, contact details). - Send Request: Call the
Add Customersendpoint to save these customers in the system.
- Method:
POST - Endpoint:
/customers - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/customers
If the operation is successful, the Customer object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer1@example.com",
"phoneNumber": "+12025550180",
"location": [
48.870852,
2.356148
],
"customData": ""
},
{
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
{
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer3@example.com",
"phoneNumber": "+12025550182",
"location": [
48.88025,
2.299601
],
"customData": ""
},
{
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer4@example.com",
"phoneNumber": "+12025550183",
"location": [
48.845198,
2.402896
],
"customData": ""
},
{
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer5@example.com",
"phoneNumber": "+12025550184",
"location": [
48.897163,
2.292865
],
"customData": ""
},
{
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer6@example.com",
"phoneNumber": "+12025550185",
"location": [
48.90092,
2.400039
],
"customData": ""
},
{
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
{
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer8@example.com",
"phoneNumber": "+12025550187",
"location": [
48.827865,
2.379216
],
"customData": ""
},
{
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer9@example.com",
"phoneNumber": "+12025550188",
"location": [
48.887096,
2.283513
],
"customData": ""
},
{
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer10@example.com",
"phoneNumber": "+12025550189",
"location": [
48.896894,
2.321586
],
"customData": ""
},
{
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer11@example.com",
"phoneNumber": "+120255501810",
"location": [
48.870449,
2.342204
],
"customData": ""
},
{
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
}
]
- Response Body: (error code
200)
[
{
"id": 1791105,
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer1@example.com",
"phoneNumber": "+12025550180",
"location": [
48.870852,
2.356148
],
"customData": ""
},
{
"id": 1791104,
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
{
"id": 1791103,
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer3@example.com",
"phoneNumber": "+12025550182",
"location": [
48.88025,
2.299601
],
"customData": ""
},
{
"id": 1791102,
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer4@example.com",
"phoneNumber": "+12025550183",
"location": [
48.845198,
2.402896
],
"customData": ""
},
{
"id": 1791101,
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer5@example.com",
"phoneNumber": "+12025550184",
"location": [
48.897163,
2.292865
],
"customData": ""
},
{
"id": 1791100,
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer6@example.com",
"phoneNumber": "+12025550185",
"location": [
48.90092,
2.400039
],
"customData": ""
},
{
"id": 1791099,
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
{
"id": 1791098,
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer8@example.com",
"phoneNumber": "+12025550187",
"location": [
48.827865,
2.379216
],
"customData": ""
},
{
"id": 1791097,
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer9@example.com",
"phoneNumber": "+12025550188",
"location": [
48.887096,
2.283513
],
"customData": ""
},
{
"id": 1791096,
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer10@example.com",
"phoneNumber": "+12025550189",
"location": [
48.896894,
2.321586
],
"customData": ""
},
{
"id": 1791095,
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer11@example.com",
"phoneNumber": "+120255501810",
"location": [
48.870449,
2.342204
],
"customData": ""
},
{
"id": 1791094,
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
}
]
Initializing and Adding Orders
- Initialize Orders: Create twelve
Orderobjects and associate each with a customer. Populate fields such as time windows, package details, and weights. - Send Request: Call the
Add Ordersendpoint to save these orders in the system.
- Method:
POST - Endpoint:
/orders - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/orders
If the operation is successful, the Order object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"customerId": 1791105,
"location": [
48.870852,
2.356148
],
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550180",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 0,
"weight": 0,
"cube": 0,
"revenue": 0,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791104,
"location": [
48.892138,
2.330583
],
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550181",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 0,
"weight": 0,
"cube": 0,
"revenue": 0,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791103,
"location": [
48.88025,
2.299601
],
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550182",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 12,
"timeWindow": [
770,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791102,
"location": [
48.845198,
2.402896
],
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550183",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 5.8,
"revenue": 2.7,
"timeWindow": [
753,
1036
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791101,
"location": [
48.897163,
2.292865
],
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550184",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.2,
"cube": 8.4,
"revenue": 7.5,
"timeWindow": [
736,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791100,
"location": [
48.90092,
2.400039
],
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550185",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.5,
"cube": 9.7,
"revenue": 10,
"timeWindow": [
786,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791099,
"location": [
48.890914,
2.310625
],
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550186",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 2.6,
"revenue": 13.4,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791098,
"location": [
48.827865,
2.379216
],
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550187",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 11,
"weight": 12.1,
"cube": 4.6,
"revenue": 14.7,
"timeWindow": [
753,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791097,
"location": [
48.887096,
2.283513
],
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550188",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 5.2,
"cube": 1.5,
"revenue": 2.9,
"timeWindow": [
770,
1070
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791096,
"location": [
48.896894,
2.321586
],
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550189",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 13,
"weight": 6.3,
"cube": 7.5,
"revenue": 8.1,
"timeWindow": [
836,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791095,
"location": [
48.870449,
2.342204
],
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501810",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 10,
"weight": 8,
"cube": 4.1,
"revenue": 6.2,
"timeWindow": [
903,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791094,
"location": [
48.895658,
2.344042
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
- Response Body: (error code
200)
[
{
"id": 879888,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791105,
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer1@example.com",
"phoneNumber": "+12025550180",
"location": [
48.870852,
2.356148
],
"customData": ""
},
"location": [
48.870852,
2.356148
],
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550180",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 0,
"weight": 0,
"cube": 0,
"revenue": 0,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879887,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791104,
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
"location": [
48.892138,
2.330583
],
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550181",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 0,
"weight": 0,
"cube": 0,
"revenue": 0,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879886,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791103,
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer3@example.com",
"phoneNumber": "+12025550182",
"location": [
48.88025,
2.299601
],
"customData": ""
},
"location": [
48.88025,
2.299601
],
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550182",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 12,
"timeWindow": [
770,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879885,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791102,
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer4@example.com",
"phoneNumber": "+12025550183",
"location": [
48.845198,
2.402896
],
"customData": ""
},
"location": [
48.845198,
2.402896
],
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550183",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 5.8,
"revenue": 2.7,
"timeWindow": [
753,
1036
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879884,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791101,
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer5@example.com",
"phoneNumber": "+12025550184",
"location": [
48.897163,
2.292865
],
"customData": ""
},
"location": [
48.897163,
2.292865
],
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550184",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.2,
"cube": 8.4,
"revenue": 7.5,
"timeWindow": [
736,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879883,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791100,
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer6@example.com",
"phoneNumber": "+12025550185",
"location": [
48.90092,
2.400039
],
"customData": ""
},
"location": [
48.90092,
2.400039
],
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550185",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.5,
"cube": 9.7,
"revenue": 10,
"timeWindow": [
786,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879882,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791099,
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
"location": [
48.890914,
2.310625
],
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550186",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 2.6,
"revenue": 13.4,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879881,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791098,
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer8@example.com",
"phoneNumber": "+12025550187",
"location": [
48.827865,
2.379216
],
"customData": ""
},
"location": [
48.827865,
2.379216
],
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550187",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 11,
"weight": 12.1,
"cube": 4.6,
"revenue": 14.7,
"timeWindow": [
753,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879880,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791097,
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer9@example.com",
"phoneNumber": "+12025550188",
"location": [
48.887096,
2.283513
],
"customData": ""
},
"location": [
48.887096,
2.283513
],
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550188",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 5.2,
"cube": 1.5,
"revenue": 2.9,
"timeWindow": [
770,
1070
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879879,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791096,
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer10@example.com",
"phoneNumber": "+12025550189",
"location": [
48.896894,
2.321586
],
"customData": ""
},
"location": [
48.896894,
2.321586
],
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550189",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 13,
"weight": 6.3,
"cube": 7.5,
"revenue": 8.1,
"timeWindow": [
836,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879878,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791095,
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer11@example.com",
"phoneNumber": "+120255501810",
"location": [
48.870449,
2.342204
],
"customData": ""
},
"location": [
48.870449,
2.342204
],
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501810",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 10,
"weight": 8,
"cube": 4.1,
"revenue": 6.2,
"timeWindow": [
903,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879877,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791094,
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
},
"location": [
48.895658,
2.344042
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
Step 2: Configure Optimization Parameters
Configuration Parameters define the behavior of the optimization process. These settings include optimization goals, search time limits, and flexibility in handling orders. Proper configuration ensures the optimization aligns with your business needs.
- Create Configuration: Define a
ConfigurationParametersobject and set the desired parameters.
{
"name": "Paris - test optimization",
"ignoreTimeWindow": false,
"allowDroppingOrders": false,
"groupingOrders": false,
"balancedRoutes": 0,
"optimizationCriterion": 0,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 300,
"maxWaitTime": 8000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
}
Step 3: Create the Vehicle and Define Vehicle Constraints
Vehicles are the resources that will be used to fulfill the orders. Each vehicle can have specific constraints and capabilities.
Adding Vehicles
- Initialize Vehicles: Create two
Vehicleobjects and populate their fields (e.g., type, capacity, availability). - Send Request: Call the
Add Vehiclesendpoint to save these vehicles in the database.
- Method:
POST - Endpoint:
/vehicles - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/vehicles
If the operation is successful, the Vehicle object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
]
- Response Body: (error code
200)
[
{
"id": 135932,
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"id": 135933,
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
]
Define Vehicle Constraints
Vehicle constraints define the limitations and requirements applied to a vehicle during the route optimization process. Ensure that the vehicle operates within its capabilities, such as time windows, capacity, distance, and revenue.
- Create Constraints: Define a
VehicleConstraintsobject that applies to both vehicles. Add this object to a list.
[
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
]
Step 4: Create Departure and Destinations
- Departures: Define the starting points for vehicle routes. These locations impact optimization by influencing travel distance and time.
- Destinations: Define the final stops for vehicle routes. These locations ensure routes are optimized for efficiency.
Adding Departures and Destinations
- Initialize Departures: Create two
Departureobjects, one for each vehicle.
[
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
]
- Initialize Destinations: Since the route custom end, we have to create two
Destinationobjects, one for each vehicle.
[
{
"alias": "Destination 1",
"location": [
48.898165,
2.34484
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"alias": "Destination 2",
"location": [
48.872064,
2.402497
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
]
Step 5: Create the Optimization
An optimization represents a routing problem defined by orders, vehicles, constraints, and configuration parameters. This step combines all the elements to generate an optimized solution.
- Create Optimization: Define an
Optimizationobject and assign theOrderList,ConfigurationParameters,VehicleList,VehicleConstraintsList, andDepartures. - Send Request: Call the
Add Optimizationendpoint to create the optimization.
- Method:
POST - Endpoint:
/optimizations - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/optimizations - Query Parameter:
encodeShape(integer, optional)0: The route's shape will not be encoded.1(default): The route's shape will be encoded.
Adding an optimization returns a request object, which allows you to track the status of the optimization process. Once the request status is finished, the solution can be retrieved using Get Optimization's Solution request. The solution consists of one or more routes. A route is the trip that a vehicle travels to visit the orders, so the number of routes returned is maximum the number of vehicles set in the optimization(see Routes).
If the operation is successful, the Optimization object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
{
"orders": [
879888,
879887,
879886,
879885,
879884,
879883,
879882,
879881,
879880,
879879,
879878,
879877
],
"departures": [
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"destinations": [
{
"alias": "Destination 1",
"location": [
48.898165,
2.34484
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"alias": "Destination 2",
"location": [
48.872064,
2.402497
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"vehicles": [
135932,
135933
],
"vehiclesConstraints": [
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
],
"configurationParameters": {
"name": "Paris - test optimization",
"ignoreTimeWindow": false,
"allowDroppingOrders": false,
"groupingOrders": false,
"balancedRoutes": 0,
"optimizationCriterion": 0,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 300,
"maxWaitTime": 8000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"matrixBuildType": 1
}
Example:
- Response Body: (error code
200)
{
"id": 137831,
"orders": [
{
"id": 879888,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791105,
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer1@example.com",
"phoneNumber": "+12025550180",
"location": [
48.870852,
2.356148
],
"customData": ""
},
"location": [
48.870852,
2.356148
],
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550180",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 0,
"weight": 0,
"cube": 0,
"revenue": 0,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879887,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791104,
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
"location": [
48.892138,
2.330583
],
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550181",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 0,
"weight": 0,
"cube": 0,
"revenue": 0,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879886,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791103,
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer3@example.com",
"phoneNumber": "+12025550182",
"location": [
48.88025,
2.299601
],
"customData": ""
},
"location": [
48.88025,
2.299601
],
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550182",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 12,
"timeWindow": [
770,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879885,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791102,
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer4@example.com",
"phoneNumber": "+12025550183",
"location": [
48.845198,
2.402896
],
"customData": ""
},
"location": [
48.845198,
2.402896
],
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550183",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 5.8,
"revenue": 2.7,
"timeWindow": [
753,
1036
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879884,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791101,
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer5@example.com",
"phoneNumber": "+12025550184",
"location": [
48.897163,
2.292865
],
"customData": ""
},
"location": [
48.897163,
2.292865
],
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550184",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.2,
"cube": 8.4,
"revenue": 7.5,
"timeWindow": [
736,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879883,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791100,
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer6@example.com",
"phoneNumber": "+12025550185",
"location": [
48.90092,
2.400039
],
"customData": ""
},
"location": [
48.90092,
2.400039
],
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550185",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.5,
"cube": 9.7,
"revenue": 10,
"timeWindow": [
786,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879882,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791099,
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
"location": [
48.890914,
2.310625
],
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550186",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 2.6,
"revenue": 13.4,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879881,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791098,
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer8@example.com",
"phoneNumber": "+12025550187",
"location": [
48.827865,
2.379216
],
"customData": ""
},
"location": [
48.827865,
2.379216
],
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550187",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 11,
"weight": 12.1,
"cube": 4.6,
"revenue": 14.7,
"timeWindow": [
753,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879880,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791097,
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer9@example.com",
"phoneNumber": "+12025550188",
"location": [
48.887096,
2.283513
],
"customData": ""
},
"location": [
48.887096,
2.283513
],
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550188",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 5.2,
"cube": 1.5,
"revenue": 2.9,
"timeWindow": [
770,
1070
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879879,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791096,
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer10@example.com",
"phoneNumber": "+12025550189",
"location": [
48.896894,
2.321586
],
"customData": ""
},
"location": [
48.896894,
2.321586
],
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550189",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 13,
"weight": 6.3,
"cube": 7.5,
"revenue": 8.1,
"timeWindow": [
836,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879878,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791095,
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer11@example.com",
"phoneNumber": "+120255501810",
"location": [
48.870449,
2.342204
],
"customData": ""
},
"location": [
48.870449,
2.342204
],
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501810",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 10,
"weight": 8,
"cube": 4.1,
"revenue": 6.2,
"timeWindow": [
903,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879877,
"creationTimestamp": 1763486363151,
"customerInfo": {
"id": 1791094,
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
},
"location": [
48.895658,
2.344042
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
],
"departures": [
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"destinations": [
{
"alias": "Destination 1",
"location": [
48.898165,
2.34484
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"alias": "Destination 2",
"location": [
48.872064,
2.402497
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"vehicles": [
{
"id": 135932,
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"id": 135933,
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
],
"vehiclesConstraints": [
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
],
"configurationParameters": {
"name": "Paris - test optimization",
"ignoreTimeWindow": false,
"allowDroppingOrders": false,
"groupingOrders": false,
"balancedRoutes": 0,
"optimizationCriterion": 0,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 300,
"maxWaitTime": 8000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"creationTimestamp": 1763486363151,
"matrixBuildType": 1,
"request": {
"id": 26551,
"optimizationId": 137831,
"status": 1,
"message": "Operation done successfully!",
"creationTimestamp": 1763486363151
}
}
Step 6: Display the Solution
Once the optimization is complete, retrieve the solution (routes) to visualize the optimized routes and waypoints.
- Method:
GET - Endpoint:
/optimizations/{id}/solution - Headers:
Authorization: YOUR_API_KEY
- Path Parameter:
id(integer, required) - The unique optimization ID.
- Query Parameter:
encodeShape(integer, optional)0: The route's shape will not be encoded.1(default): The route's shape will be encoded.
- Response -
Code 200: Successful operation!
{
"totalRecords": 1,
"routes": [
{
"configurationParameters": {
"orderSequenceOptions": [
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 0"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0.0,
"maxDistance": 100000000.0,
"maxRevenue": 100000000.0,
"fuelPrice": 1.0900000333786010742
},
"rideStatus": 1,
"vehicle": {
"length": 0.0,
"weight": 0.0,
"width": 0.0,
"licensePlate": "AA-123-AA",
"consumption": 6.5,
"fuelType": 0,
"make": "Renault",
"id": 161791,
"name": "Car vehicle 1",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161791,
"endTime": 1100,
"fixedCost": 0.0,
"startTime": 420,
"lastPosition": [
2147483647.0,
2147483647.0
]
},
"destination": {
"depotId": 0,
"alias": "Destination 1",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.89816499999999877,
2.3448400000000000354
],
"matchedLocation": [
48.898125624999998706,
2.3448431250000001391
],
"arrivalTime": 1596807324000,
"traveledDistance": 20.180767059326171875
},
"departure": {
"depotId": 0,
"alias": "Depot 1",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.870569000000003257,
2.3564479999999998761
],
"matchedLocation": [
48.870568437499997572,
2.356441562500000142
],
"numberOfpackages": 6,
"weight": 5.1999998092651367188,
"cube": 1.5,
"departureTime": 1596804016128,
"timeToNext": 245,
"distanceToNext": 1.4171849489212036133
},
"shape": "a`hiHwfkM`GxCBVVPPHs@~Ec[sNgCkA_Ai@pEyDxAn@dX~MBVVPPHuArJe@zD}BzPeArIeDd^sArOMb@C`@fLhENwA?MYiE}@iLK@mFkAsArOMb@MvAkDlf@OzAiAlPG~AeAjOuDlh@Cb@Dv@w@j@mAbBsa@ji@dAdPKtAFt@PnATTdHni@kHhKZRkGe",
"creationTimestamp": 1752839825792,
"neededFuel": 1.3117499351501464844,
"matrixBuildType": 1,
"price": 1.4298074245452880859,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148941,
"orders": [
{
"orderInfo": {
"revenue": 13.0,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1752839820754,
"cube": 0.10000000149011611938,
"numberOfPackages": 1,
"depotId": 0,
"customData": "",
"weight": 3.2000000476837158203,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c0",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194008,
"location": [
48.870851999999999293,
2.3561480000000001311
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c0@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c0",
"customData": "",
"id": 1998427,
"location": [
48.870851999999999293,
2.3561480000000001311
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.87077843750000028,
2.3565665624999998506
],
"indexInRoute": 0,
"indexInOptimization": 0,
"arrivalTime": 1596804261000,
"timeToNextOrder": 318,
"waitTime": 0,
"numberOfPackagesAtArrival": 6,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 5.1999998092651367188,
"collectedWeight": 3.2000000476837158203,
"deliveredWeight": 0.0,
"cubeAtArrival": 1.5,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 1.4171849489212036133,
"distanceToNextOrder": 1.8787109851837158203,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 6.1999998092651367188,
"serviceTime": 0,
"timeWindow": [
903,
1020
],
"creationTimestamp": 1752839821094,
"cube": 4.0999999046325683594,
"numberOfPackages": 10,
"depotId": 0,
"customData": "",
"weight": 8.0,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c10",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194018,
"location": [
48.870449000000000694,
2.3422040000000001747
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c10@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c10",
"customData": "",
"id": 1998437,
"location": [
48.870449000000000694,
2.3422040000000001747
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.870181875000000105,
2.3423449999999998994
],
"indexInRoute": 1,
"indexInOptimization": 10,
"arrivalTime": 1596804579000,
"timeToNextOrder": 595,
"waitTime": 0,
"numberOfPackagesAtArrival": 7,
"collectedNumberOfPackages": 10,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 8.3999996185302734375,
"collectedWeight": 8.0,
"deliveredWeight": 0.0,
"cubeAtArrival": 1.6000000238418579102,
"collectedCube": 4.0999999046325683594,
"deliveredCube": 0.0,
"traveledDistance": 3.2958960533142089844,
"distanceToNextOrder": 3.8362429141998291016,
"revenueAtArrival": 13.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 12.0,
"serviceTime": 0,
"timeWindow": [
770,
1020
],
"creationTimestamp": 1752839820828,
"cube": 2.5,
"numberOfPackages": 3,
"depotId": 0,
"customData": "",
"weight": 5.0999999046325683594,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c2",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194010,
"location": [
48.880249999999996646,
2.2996010000000000062
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c2@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c2",
"customData": "",
"id": 1998429,
"location": [
48.880249999999996646,
2.2996010000000000062
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.880213437499996587,
2.2997093749999999446
],
"indexInRoute": 2,
"indexInOptimization": 2,
"arrivalTime": 1596805174000,
"timeToNextOrder": 369,
"waitTime": 0,
"numberOfPackagesAtArrival": 17,
"collectedNumberOfPackages": 3,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 16.399999618530273438,
"collectedWeight": 5.0999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 5.6999998092651367188,
"collectedCube": 2.5,
"deliveredCube": 0.0,
"traveledDistance": 7.1321392059326171875,
"distanceToNextOrder": 1.8877489566802978516,
"revenueAtArrival": 19.200000762939453125,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.9000000953674316406,
"serviceTime": 0,
"timeWindow": [
770,
1070
],
"creationTimestamp": 1752839821028,
"cube": 1.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 5.1999998092651367188,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c8",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194016,
"location": [
48.887095999999999663,
2.283513000000000126
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c8@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c8",
"customData": "",
"id": 1998435,
"location": [
48.887095999999999663,
2.283513000000000126
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.886898125000001869,
2.2838078125000000895
],
"indexInRoute": 3,
"indexInOptimization": 8,
"arrivalTime": 1596805543000,
"timeToNextOrder": 330,
"waitTime": 0,
"numberOfPackagesAtArrival": 20,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 6,
"weightAtArrival": 21.5,
"collectedWeight": 0.0,
"deliveredWeight": 5.1999998092651367188,
"cubeAtArrival": 8.1999998092651367188,
"collectedCube": 0.0,
"deliveredCube": 1.5,
"traveledDistance": 9.0198879241943359375,
"distanceToNextOrder": 1.896412968635559082,
"revenueAtArrival": 31.200000762939453125,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 7.5,
"serviceTime": 0,
"timeWindow": [
736,
1086
],
"creationTimestamp": 1752839820889,
"cube": 8.3999996185302734375,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.200000762939453125,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c4",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194012,
"location": [
48.897162999999999045,
2.2928649999999999309
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c4@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c4",
"customData": "",
"id": 1998431,
"location": [
48.897162999999999045,
2.2928649999999999309
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897063750000000937,
2.2924699999999997857
],
"indexInRoute": 4,
"indexInOptimization": 4,
"arrivalTime": 1596805873000,
"timeToNextOrder": 406,
"waitTime": 0,
"numberOfPackagesAtArrival": 14,
"collectedNumberOfPackages": 9,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 16.299999237060546875,
"collectedWeight": 16.200000762939453125,
"deliveredWeight": 0.0,
"cubeAtArrival": 6.6999998092651367188,
"collectedCube": 8.3999996185302734375,
"deliveredCube": 0.0,
"traveledDistance": 10.916300773620605469,
"distanceToNextOrder": 2.8310110569000244141,
"revenueAtArrival": 34.100002288818359375,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.399999618530273438,
"serviceTime": 0,
"timeWindow": [
820,
1020
],
"creationTimestamp": 1752839820957,
"cube": 2.5999999046325683594,
"numberOfPackages": 5,
"depotId": 0,
"customData": "",
"weight": 7.5,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c6",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194014,
"location": [
48.890914000000002204,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c6@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c6",
"customData": "",
"id": 1998433,
"location": [
48.890914000000002204,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.891068437500003085,
2.3109646874999998367
],
"indexInRoute": 5,
"indexInOptimization": 6,
"arrivalTime": 1596806279000,
"timeToNextOrder": 185,
"waitTime": 0,
"numberOfPackagesAtArrival": 23,
"collectedNumberOfPackages": 5,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 32.5,
"collectedWeight": 7.5,
"deliveredWeight": 0.0,
"cubeAtArrival": 15.099999427795410156,
"collectedCube": 2.5999999046325683594,
"deliveredCube": 0.0,
"traveledDistance": 13.747311592102050781,
"distanceToNextOrder": 1.2335729598999023438,
"revenueAtArrival": 41.600002288818359375,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 8.1000003814697265625,
"serviceTime": 0,
"timeWindow": [
836,
1053
],
"creationTimestamp": 1752839821057,
"cube": 7.5,
"numberOfPackages": 13,
"depotId": 0,
"customData": "",
"weight": 6.3000001907348632812,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c9",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194017,
"location": [
48.896894000000003189,
2.3215859999999999275
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c9@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c9",
"customData": "",
"id": 1998436,
"location": [
48.896894000000003189,
2.3215859999999999275
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897175937500001908,
2.3212631250000002048
],
"indexInRoute": 6,
"indexInOptimization": 9,
"arrivalTime": 1596806464000,
"timeToNextOrder": 240,
"waitTime": 0,
"numberOfPackagesAtArrival": 28,
"collectedNumberOfPackages": 13,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 40.0,
"collectedWeight": 6.3000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 17.699998855590820312,
"collectedCube": 7.5,
"deliveredCube": 0.0,
"traveledDistance": 14.980884552001953125,
"distanceToNextOrder": 1.5006899833679199219,
"revenueAtArrival": 55.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 14.100000381469726562,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1752839820792,
"cube": 0.10000000149011611938,
"numberOfPackages": 1,
"depotId": 0,
"customData": "",
"weight": 4.5999999046325683594,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c1",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194009,
"location": [
48.892138000000002762,
2.3305829999999998492
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c1@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c1",
"customData": "",
"id": 1998428,
"location": [
48.892138000000002762,
2.3305829999999998492
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.892148437499997726,
2.3306215625000001879
],
"indexInRoute": 7,
"indexInOptimization": 1,
"arrivalTime": 1596806704000,
"timeToNextOrder": 281,
"waitTime": 0,
"numberOfPackagesAtArrival": 41,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 46.299999237060546875,
"collectedWeight": 4.5999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 25.199998855590820312,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 16.48157501220703125,
"distanceToNextOrder": 1.5621720552444458008,
"revenueAtArrival": 63.09999847412109375,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.2999999523162841797,
"serviceTime": 0,
"timeWindow": [
870,
1020
],
"creationTimestamp": 1752839821129,
"cube": 11.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 4.8000001907348632812,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c11",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194019,
"location": [
48.895657999999997401,
2.3440430000000000987
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c11@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c11",
"customData": "",
"id": 1998438,
"location": [
48.895657999999997401,
2.3440430000000000987
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.895803437499999688,
2.3440406249999998778
],
"indexInRoute": 8,
"indexInOptimization": 11,
"arrivalTime": 1596806985000,
"timeToNextOrder": 339,
"waitTime": 0,
"numberOfPackagesAtArrival": 42,
"collectedNumberOfPackages": 6,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 50.899997711181640625,
"collectedWeight": 4.8000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 25.299999237060546875,
"collectedCube": 11.5,
"deliveredCube": 0.0,
"traveledDistance": 18.0437469482421875,
"distanceToNextOrder": 2.1370210647583007812,
"revenueAtArrival": 77.1999969482421875,
"visitTimestamp": 0
}
],
"totalTime": 3308,
"totalDistance": 20.180767059326171875,
"id": 273346
},
{
"configurationParameters": {
"orderSequenceOptions": [
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 1"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0.0,
"maxDistance": 100000000.0,
"maxRevenue": 100000000.0,
"fuelPrice": 1.0900000333786010742
},
"rideStatus": 1,
"vehicle": {
"length": 0.0,
"weight": 0.0,
"width": 0.0,
"licensePlate": "AA-124-AA",
"consumption": 6.5,
"fuelType": 0,
"make": "Renault",
"id": 161792,
"name": "Car vehicle 2",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161792,
"endTime": 1100,
"fixedCost": 0.0,
"startTime": 420,
"lastPosition": [
2147483647.0,
2147483647.0
]
},
"destination": {
"depotId": 0,
"alias": "Destination 2",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.872064000000001727,
2.4024969999999998826
],
"matchedLocation": [
48.871986249999999075,
2.4021184374999999811
],
"arrivalTime": 1596805602000,
"traveledDistance": 23.745513916015625
},
"departure": {
"depotId": 0,
"alias": "Depot 2",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.826740000000000919,
2.3421159999999998647
],
"matchedLocation": [
48.826793750000000216,
2.3420853125000000716
],
"numberOfpackages": 28,
"weight": 44.0,
"cube": 20.100000381469726562,
"departureTime": 1596803071560,
"timeToNext": 508,
"distanceToNext": 3.4701020717620849609
},
"shape": "mn_iH_mhMCVuGuBQIy@s@SDOLIxFzAOlAIfHJJi@FmAtAgQBq@t@_J@g@[aQkAyi@ByLAkCC_AiHedA^w@M[@O`ByMoBmNmAiE{AyEdGwFlDkD`@WlAwCFc@HW~AqEdAeClAcCTo@mByAIMM]YeC[iASa@w@kAiA_DkFsTg@yCGo@SwBu@aMKaAcD@",
"creationTimestamp": 1752839825907,
"neededFuel": 1.5434584617614746094,
"matrixBuildType": 1,
"price": 1.6823698282241821289,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148941,
"orders": [
{
"orderInfo": {
"revenue": 14.699999809265136719,
"serviceTime": 0,
"timeWindow": [
753,
1086
],
"creationTimestamp": 1752839820993,
"cube": 4.5999999046325683594,
"numberOfPackages": 11,
"depotId": 0,
"customData": "",
"weight": 12.100000381469726562,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c7",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194015,
"location": [
48.827865000000002738,
2.3792159999999999975
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c7@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c7",
"customData": "",
"id": 1998434,
"location": [
48.827865000000002738,
2.3792159999999999975
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.827919999999998879,
2.3791415625000000844
],
"indexInRoute": 0,
"indexInOptimization": 7,
"arrivalTime": 1596803580000,
"timeToNextOrder": 555,
"waitTime": 0,
"numberOfPackagesAtArrival": 28,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 11,
"weightAtArrival": 44.0,
"collectedWeight": 0.0,
"deliveredWeight": 12.100000381469726562,
"cubeAtArrival": 20.100000381469726562,
"collectedCube": 0.0,
"deliveredCube": 4.5999999046325683594,
"traveledDistance": 3.4701020717620849609,
"distanceToNextOrder": 5.4595351219177246094,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.7000000476837158203,
"serviceTime": 0,
"timeWindow": [
753,
1036
],
"creationTimestamp": 1752839820857,
"cube": 5.8000001907348632812,
"numberOfPackages": 8,
"depotId": 0,
"customData": "",
"weight": 15.399999618530273438,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c3",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194011,
"location": [
48.845198000000003447,
2.4028960000000001429
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c3@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c3",
"customData": "",
"id": 1998430,
"location": [
48.845198000000003447,
2.4028960000000001429
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.845262499999996919,
2.4027009375000001334
],
"indexInRoute": 1,
"indexInOptimization": 3,
"arrivalTime": 1596804135000,
"timeToNextOrder": 855,
"waitTime": 0,
"numberOfPackagesAtArrival": 17,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 8,
"weightAtArrival": 31.899999618530273438,
"collectedWeight": 0.0,
"deliveredWeight": 15.399999618530273438,
"cubeAtArrival": 15.5,
"collectedCube": 0.0,
"deliveredCube": 5.8000001907348632812,
"traveledDistance": 8.9296369552612304688,
"distanceToNextOrder": 9.2198839187622070312,
"revenueAtArrival": 14.699999809265136719,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 10.0,
"serviceTime": 0,
"timeWindow": [
786,
1053
],
"creationTimestamp": 1752839820920,
"cube": 9.6999998092651367188,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.5,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c5",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194013,
"location": [
48.900919999999999277,
2.4000390000000000335
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c5@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c5",
"customData": "",
"id": 1998432,
"location": [
48.900919999999999277,
2.4000390000000000335
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.900595937500000332,
2.4000474999999998893
],
"indexInRoute": 2,
"indexInOptimization": 5,
"arrivalTime": 1596804990000,
"timeToNextOrder": 612,
"waitTime": 0,
"numberOfPackagesAtArrival": 9,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 9,
"weightAtArrival": 16.5,
"collectedWeight": 0.0,
"deliveredWeight": 16.5,
"cubeAtArrival": 9.6999998092651367188,
"collectedCube": 0.0,
"deliveredCube": 9.6999998092651367188,
"traveledDistance": 18.1495208740234375,
"distanceToNextOrder": 5.5959939956665039062,
"revenueAtArrival": 17.399999618530273438,
"visitTimestamp": 0
}
],
"totalTime": 2530,
"totalDistance": 23.745513916015625,
"id": 273347
}
]
}
Analyzing the Solution - Paris Route Optimization Test

Summary Table
| Metric | Part 0 | Part 1 |
|---|---|---|
| Total Distance | 20.18 km | 23.75 km |
| Total Time | 55 min 8 sec | 42 min 11 sec |
| Cost | €1.43 | €1.68 |
| Departure Point | Depot 1 | Depot 2 |
| Departure Time | 12:40:16 (07/08/2020) | 12:24:31 (07/08/2020) |
| Destination | Destination 1 | Destination 2 |
| Arrival Time | 13:35:24 | 13:06:42 |
| Total Stops | 9 | 3 |
| Pickups | 8 | 0 |
| Deliveries | 1 | 3 |
Route Insights
-
Route `1 (Part 0) executed 9 stops in a tight circuit totaling 20.18 km with a low cost of €1.43. Starting from Depot 1, the vehicle performs a sequence of strategic pickups—starting at Order 1, Order 11 and Order3, makes a delivery at Order 9, then continue with pickups at Order 5, Order 7, Order 10, Order 2, and Order 12. The route concludes efficiently at Destination 1, having optimized volume and weight distribution.
-
Route 2 (Part 1) focused solely on deliveries, handling 3 drop-offs over 23.75 km, costing €1.68. It departs from Depot 2, heading straight to Order 8, followed by Orders 4 and 6, then ends cleanly at Destination 2. The lack of pickups on this segment suggests it serves as a clearing run for previously loaded cargo.
Operational Highlights
- Total Distance Covered: Combined, both routes span 43.93 km, effectively balancing pickups and deliveries across compact urban areas.
- Time Efficiency: Despite more stops, Route 1 (Part 0) took only 13 minutes longer than Route 2, highlighting tight route optimization.
- Load Strategy: Route 0 builds up vehicle load progressively with minimal delivery, possibly for a future drop. Route 1 unloads extensively, starting heavier and ending light.
- Zero Wait Times: All stops comply strictly with time windows, ensuring optimized dispatch and service timing.
- Cost Management: The relatively low cost of both routes indicates minimal vehicle idle time and optimal stop sequencing, despite high cube/weight handling.
Conclusion
This example demonstrates how to create a fully customized optimization with multiple vehicles ending at different destinations, define orders, and visualize the results on a map. By following the steps above, you can adapt this example to your specific use case and integrate it into your fleet management workflow.