Skip to main content
GuidesExamples

Add Optimization with Multiple Destinations

Estimated reading time: 19 minutes

Overview

This example demonstrates how to create and optimize a fleet management solution using the Fleet Management RestAPI 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:

  1. An optimization is created and saved.
  2. The optimized solution is returned and displayed on the map.

Step-by-Step Guide

Step 1: Create Customers and Orders

Note

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

  1. Initialize Customers: Create twelve Customer objects and populate their fields (e.g., name, address, contact details).
  2. Send Request: Call the Add Customers endpoint to save these customers in the system.
  • Method: POST
  • Endpoint: /customers
  • Headers:
    • Authorization: YOUR_API_KEY
    • Content-Type: application/json
  • URL: https://fleetmanagement.magiclaneapis.com/v1/customers
Note

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.827327,
2.342267
],
"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.860914,
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.344043
],
"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.827327,
2.342267
],
"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.860914,
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.344043
],
"customData": ""
}
]

Initializing and Adding Orders

  1. Initialize Orders: Create twelve Order objects and associate each with a customer. Populate fields such as time windows, package details, and weights.
  2. Send Request: Call the Add Orders endpoint to save these orders in the system.
  • Method: POST
  • Endpoint: /orders
  • Headers:
    • Authorization: YOUR_API_KEY
    • Content-Type: application/json
  • URL: https://fleetmanagement.magiclaneapis.com/v1/orders
Note

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.827327,
2.342267
],
"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.860914,
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.344043
],
"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": 1751445531341,
"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": 1751445531341,
"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.827327,
2.342267
],
"customData": ""
},
"location": [
48.827327,
2.342267
],
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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.860914,
2.310625
],
"customData": ""
},
"location": [
48.860914,
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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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.344043
],
"customData": ""
},
"location": [
48.895658,
2.344043
],
"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

Note

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.

  1. Create Configuration: Define a ConfigurationParameters object 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": 18000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
}

Step 3: Create the Vehicle and Define Vehicle Constraints

Note

Vehicles are the resources that will be used to fulfill the orders. Each vehicle can have specific constraints and capabilities.

Adding Vehicles

  1. Initialize Vehicles: Create two Vehicle objects and populate their fields (e.g., type, capacity, availability).
  2. Send Request: Call the Add Vehicles endpoint to save these vehicles in the database.
  • Method: POST
  • Endpoint: /vehicles
  • Headers:
    • Authorization: YOUR_API_KEY
    • Content-Type: application/json
  • URL: https://fleetmanagement.magiclaneapis.com/v1/vehicles
Note

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

Note

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.

  1. Create Constraints: Define a VehicleConstraints object 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

Note
  • 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

  1. Initialize Departures: Create two Departure objects, 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"
},
"matchedLocation": [
0,
0
]
},
{
"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"
},
"matchedLocation": [
0,
0
]
}
]
  1. Initialize Destinations: Since the route custom end, we have to create two Destination objects, 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"
},
"matchedLocation": [
0,
0
]
},
{
"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"
},
"matchedLocation": [
0,
0
]
}
]

Step 5: Create the Optimization

Note

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.

  1. Create Optimization: Define an Optimization object and assign the OrderList, ConfigurationParameters, VehicleList, VehicleConstraintsList, and Departures.
  2. Send Request: Call the Add Optimization endpoint to create the optimization.
  • Method: POST
  • Endpoint: /optimizations
  • Headers:
    • Authorization: YOUR_API_KEY
    • Content-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.
Note

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"
},
"matchedLocation": [
0,
0
]
},
{
"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"
},
"matchedLocation": [
0,
0
]
}
],
"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"
},
"matchedLocation": [
0,
0
]
},
{
"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"
},
"matchedLocation": [
0,
0
]
}
],
"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": 18000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"matrixBuildType": 1
}

Example:

  • Response Body: (error code 200)
{
"id": 137831,
"orders": [
{
"id": 879888,
"creationTimestamp": 1751445531341,
"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": 1751445531341,
"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.827327,
2.342267
],
"customData": ""
},
"location": [
48.827327,
2.342267
],
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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.860914,
2.310625
],
"customData": ""
},
"location": [
48.860914,
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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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": 1751445531341,
"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.344043
],
"customData": ""
},
"location": [
48.895658,
2.344043
],
"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"
},
"matchedLocation": [
0,
0
]
},
{
"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"
},
"matchedLocation": [
0,
0
]
}
],
"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"
},
"matchedLocation": [
0,
0
]
},
{
"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"
},
"matchedLocation": [
0,
0
]
}
],
"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": 18000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"creationTimestamp": 1751445531342,
"matrixBuildType": 1,
"request": {
"id": 26551,
"optimizationId": 137831,
"status": 1,
"message": "Operation done successfully!",
"creationTimestamp": 1751445531342
}
}

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!
{
"routes": [
{
"configurationParameters": {
"orderSequenceOptions": [],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 18000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 0"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 100000000,
"maxRevenue": 85,
"fuelPrice": 1.0700000524520874
},
"rideStatus": 1,
"vehicle": {
"length": 0,
"weight": 0,
"width": 0,
"licensePlate": "0",
"consumption": 6.5,
"fuelType": 2,
"make": "0",
"id": 135932,
"name": "Car vehicle 1",
"model": "Master",
"costPerHour": 0,
"type": 0,
"status": 0,
"maxLoadWeight": 60,
"height": 0,
"maxLoadCube": 50,
"idDriver": 135932,
"endTime": 1439,
"fixedCost": 0,
"startTime": 420,
"lastPosition": [
48.870569,
2.356448
]
},
"destination": {
"depotId": 0,
"alias": "Destination 1",
"address": {
"streetNumber": "1",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"county": "Paris",
"state": "Ile-de-France",
"extra": "0",
"city": "Paris",
"country": "France"
},
"location": [
48.898165,
2.34484
],
"matchedLocation": [
48.898125625,
2.3448428125
],
"arrivalTime": 1596816535000,
"traveledDistance": 30.77336883544922
},
"departure": {
"depotId": 0,
"alias": "Depot 1",
"address": {
"streetNumber": "1",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"county": "Paris",
"state": "Ile-de-France",
"extra": "0",
"city": "Paris",
"country": "France"
},
"location": [
48.870569,
2.356448
],
"matchedLocation": [
48.8705684375,
2.3564415625
],
"numberOfpackages": 15,
"weight": 21.700000762939453,
"cube": 11.199999809265137,
"departureTime": 1596783600000,
"timeToNext": 245,
"distanceToNext": 1.4171849489212036
},
"shape": "a`hiHwfkM`GxCBVVPPHs@~Ec[sNgCkA_Ai@pEyDxAn@dX~MBVVPPHuArJe@zD}BzPeArIeDd^sArOMb@C`@fLhENeB[{@wKK@mFkAsArOMb@Q|BRHXhApCjYjApLZ|DfAxKz@dJSl@aCtK?NFJK^KfPMj@KNQbA@PBJHLbDzBFHLt@RBfAs@\\URg@lNhJVRr@bAPj@H`@Nh@Zf@`An@_@dB@b@vCnBT`@Jb@BdAGxBFrADxF_@bAHpMrW|AKzpFcHYaACqKTe@AeIT_LRG]IMMCSHiDcI_C}F_BwAoCmBeDiBOEgEz@yHPh@j_@aGxFMHgDnEW\\cCtGEGGDCN@LFF_DtHq@zAx@jGkHhKZRkGeE_R~QOYWUYEM@UFOLKPKTEVCj@Dj@DTP^ZTQzEu@rLS\\J^_ArMK{@~Kw@dN_AaBqCpDMKKDGRBTFHF@HClC|GDPEPCXsMzN}EdFyGcX{Nqd@f@a@w@yCo@h@gDaK{AcFyJ|GqB{@cFYeA_BmDoBqDk@mAmDkJMw@aAmCAm@`NoNeCgIcBuEtLcJdEmGrBcCt@uAfIqPNm@@]eHiW}ByIm@aBaCuIS_AMoACkCEkOCs@K{R_C[MeCk@_@s@oAWwDcAIeOGcBUqDWag@a@_k@Sa`@HmFl@eR@eBJed@HuH@_DCqCHy^JuEdAkVFmD?mBEqKHsBJmGLyLL}BZsBBi@?a@Gs@{CI_BJa@Fk@Cm@CWOe@W]WMOEwBqDp@sIyHgLm@f@uEkHhE_RhBcQXqA`BwDDTEUs@~Am@vAYpAoA~LvGxJzC|E{@~@WP{CvCQXqCjCm@{@~@QVoAnAm@^XTvM|Nd@pAJp@JjASf@Id@Ah@Df@Lb@HNVZZLX?l@d@LNp@tBJh@D\\?^Ed@Mf@w@vBU`~AIl@Gj@AjAVxFP`GJ`BBrKEpEOxEq@xOOjDAxAKx[IxFAxGBdEIpc@GfDg@nPGvnGP~ZOn@CzAFhJMbB@pAtA@JALOlGAbFQTIN@DCNWbAw@LxAFELBnFxChANAaCHb[{BdCi@f@Qj@QH{AiW}BmAGuKSiF@Es@IqEYg^c@BD`GD|@FrEHvEF~GLxFAt@LzD",
"creationTimestamp": 1743084580601,
"neededFuel": 2.0002689361572266,
"matrixBuildType": 1,
"price": 2.1402878761291504,
"totalWaitTime": 28437,
"totalServiceTime": 0,
"optimizationId": 137831,
"orders": [
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"timeWindow": [
1596783600000,
1596823600000
],
"creationTimestamp": 1742972756467,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550180",
"lastName": "Customer1",
"status": 1,
"firstName": "Customer1",
"alias": "Customer 1",
"state": 1,
"type": 0,
"priority": 0,
"id": 879877,
"location": [
48.870852,
2.356148
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+120255501811",
"email": "customer12@example.com",
"lastName": "Customer12",
"firstName": "Customer12",
"alias": "Customer 12",
"customData": "",
"id": 1791105,
"location": [
48.895658,
2.344043
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.8707784375,
2.3565665625
],
"actualLocation": [
0,
0
],
"indexInRoute": 0,
"indexInOptimization": 11,
"arrivalTime": 1596783845000,
"timeToNextOrder": 318,
"waitTime": 28437,
"numberOfPackagesAtArrival": 15,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 21.700000762939453,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 11.199999809265137,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 1.4171849489212036,
"distanceToNextOrder": 1.8787050247192383,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 6.199999809265137,
"serviceTime": 0,
"timeWindow": [
1596812600000,
1596819600000
],
"creationTimestamp": 1742972756467,
"cube": 4.099999904632568,
"numberOfPackages": 10,
"depotId": 0,
"customData": "",
"weight": 8,
"phoneNumber": "+120255501810",
"lastName": "Customer11",
"status": 1,
"firstName": "Customer11",
"alias": "Customer 11",
"state": 1,
"type": 0,
"priority": 0,
"id": 879887,
"location": [
48.870449,
2.342204
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550181",
"email": "customer2@example.com",
"lastName": "Customer2",
"firstName": "Customer2",
"alias": "Customer 2",
"customData": "",
"id": 1791095,
"location": [
48.827327,
2.342267
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.870181875,
2.342345
],
"actualLocation": [
0,
0
],
"indexInRoute": 1,
"indexInOptimization": 1,
"arrivalTime": 1596812600000,
"timeToNextOrder": 589,
"waitTime": 0,
"numberOfPackagesAtArrival": 15,
"collectedNumberOfPackages": 10,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 21.700000762939453,
"collectedWeight": 8,
"deliveredWeight": 0,
"cubeAtArrival": 11.199999809265137,
"collectedCube": 4.099999904632568,
"deliveredCube": 0,
"traveledDistance": 3.2958898544311523,
"distanceToNextOrder": 3.523279905319214,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.399999618530273,
"serviceTime": 0,
"timeWindow": [
1596807600000,
1596819600000
],
"creationTimestamp": 1742972756467,
"cube": 2.5999999046325684,
"numberOfPackages": 5,
"depotId": 0,
"customData": "",
"weight": 7.5,
"phoneNumber": "+12025550186",
"lastName": "Customer7",
"status": 1,
"firstName": "Customer7",
"alias": "Customer 7",
"state": 1,
"type": 0,
"priority": 0,
"id": 879883,
"location": [
48.860914,
2.310625
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550185",
"email": "customer6@example.com",
"lastName": "Customer6",
"firstName": "Customer6",
"alias": "Customer 6",
"customData": "",
"id": 1791099,
"location": [
48.90092,
2.400039
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.86112,
2.310630625
],
"actualLocation": [
0,
0
],
"indexInRoute": 2,
"indexInOptimization": 5,
"arrivalTime": 1596813189000,
"timeToNextOrder": 497,
"waitTime": 0,
"numberOfPackagesAtArrival": 25,
"collectedNumberOfPackages": 5,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 29.700000762939453,
"collectedWeight": 7.5,
"deliveredWeight": 0,
"cubeAtArrival": 15.299999237060547,
"collectedCube": 2.5999999046325684,
"deliveredCube": 0,
"traveledDistance": 6.819169998168945,
"distanceToNextOrder": 3.117466926574707,
"revenueAtArrival": 6.199999809265137,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 12,
"serviceTime": 0,
"timeWindow": [
1596804600000,
1596819600000
],
"creationTimestamp": 1742972756467,
"cube": 2.5,
"numberOfPackages": 3,
"depotId": 0,
"customData": "",
"weight": 5.099999904632568,
"phoneNumber": "+12025550182",
"lastName": "Customer3",
"status": 1,
"firstName": "Customer3",
"alias": "Customer 3",
"state": 1,
"type": 0,
"priority": 0,
"id": 879879,
"location": [
48.88025,
2.299601
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550189",
"email": "customer10@example.com",
"lastName": "Customer10",
"firstName": "Customer10",
"alias": "Customer 10",
"customData": "",
"id": 1791103,
"location": [
48.896894,
2.321586
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.8802134375,
2.299709375
],
"actualLocation": [
0,
0
],
"indexInRoute": 3,
"indexInOptimization": 9,
"arrivalTime": 1596813686000,
"timeToNextOrder": 369,
"waitTime": 0,
"numberOfPackagesAtArrival": 30,
"collectedNumberOfPackages": 3,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 37.20000076293945,
"collectedWeight": 5.099999904632568,
"deliveredWeight": 0,
"cubeAtArrival": 17.899999618530273,
"collectedCube": 2.5,
"deliveredCube": 0,
"traveledDistance": 9.936636924743652,
"distanceToNextOrder": 1.8877489566802979,
"revenueAtArrival": 19.599998474121094,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.9000000953674316,
"serviceTime": 0,
"timeWindow": [
1596804600000,
1596822600000
],
"creationTimestamp": 1742972756467,
"cube": 1.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 5.199999809265137,
"phoneNumber": "+12025550188",
"lastName": "Customer9",
"status": 1,
"firstName": "Customer9",
"alias": "Customer 9",
"state": 1,
"type": 1,
"priority": 0,
"id": 879885,
"location": [
48.887096,
2.283513
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550183",
"email": "customer4@example.com",
"lastName": "Customer4",
"firstName": "Customer4",
"alias": "Customer 4",
"customData": "",
"id": 1791097,
"location": [
48.845198,
2.402896
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.886898125,
2.2838078125
],
"actualLocation": [
0,
0
],
"indexInRoute": 4,
"indexInOptimization": 3,
"arrivalTime": 1596814055000,
"timeToNextOrder": 330,
"waitTime": 0,
"numberOfPackagesAtArrival": 33,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 6,
"weightAtArrival": 42.29999923706055,
"collectedWeight": 0,
"deliveredWeight": 5.199999809265137,
"cubeAtArrival": 20.399999618530273,
"collectedCube": 0,
"deliveredCube": 1.5,
"traveledDistance": 11.824385643005371,
"distanceToNextOrder": 1.9110699892044067,
"revenueAtArrival": 31.599998474121094,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 7.5,
"serviceTime": 0,
"timeWindow": [
1596802600000,
1596823600000
],
"creationTimestamp": 1742972756467,
"cube": 8.399999618530273,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.200000762939453,
"phoneNumber": "+12025550184",
"lastName": "Customer5",
"status": 1,
"firstName": "Customer5",
"alias": "Customer 5",
"state": 1,
"type": 0,
"priority": 0,
"id": 879881,
"location": [
48.897163,
2.292865
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550187",
"email": "customer8@example.com",
"lastName": "Customer8",
"firstName": "Customer8",
"alias": "Customer 8",
"customData": "",
"id": 1791101,
"location": [
48.827865,
2.379216
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.89706375,
2.29247
],
"actualLocation": [
0,
0
],
"indexInRoute": 5,
"indexInOptimization": 7,
"arrivalTime": 1596814385000,
"timeToNextOrder": 486,
"waitTime": 0,
"numberOfPackagesAtArrival": 27,
"collectedNumberOfPackages": 9,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 37.099998474121094,
"collectedWeight": 16.200000762939453,
"deliveredWeight": 0,
"cubeAtArrival": 18.899999618530273,
"collectedCube": 8.399999618530273,
"deliveredCube": 0,
"traveledDistance": 13.735455513000488,
"distanceToNextOrder": 2.9220430850982666,
"revenueAtArrival": 34.5,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 8.100000381469727,
"serviceTime": 0,
"timeWindow": [
1596808600000,
1596821600000
],
"creationTimestamp": 1742972756467,
"cube": 7.5,
"numberOfPackages": 13,
"depotId": 0,
"customData": "",
"weight": 6.300000190734863,
"phoneNumber": "+12025550189",
"lastName": "Customer10",
"status": 1,
"firstName": "Customer10",
"alias": "Customer 10",
"state": 1,
"type": 0,
"priority": 0,
"id": 879886,
"location": [
48.896894,
2.321586
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550182",
"email": "customer3@example.com",
"lastName": "Customer3",
"firstName": "Customer3",
"alias": "Customer 3",
"customData": "",
"id": 1791096,
"location": [
48.88025,
2.299601
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.8971759375,
2.321263125
],
"actualLocation": [
0,
0
],
"indexInRoute": 6,
"indexInOptimization": 2,
"arrivalTime": 1596814871000,
"timeToNextOrder": 679,
"waitTime": 0,
"numberOfPackagesAtArrival": 36,
"collectedNumberOfPackages": 13,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 53.29999923706055,
"collectedWeight": 6.300000190734863,
"deliveredWeight": 0,
"cubeAtArrival": 27.299999237060547,
"collectedCube": 7.5,
"deliveredCube": 0,
"traveledDistance": 16.657499313354492,
"distanceToNextOrder": 6.4609599113464355,
"revenueAtArrival": 42,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 10,
"serviceTime": 0,
"timeWindow": [
1596805600000,
1596821600000
],
"creationTimestamp": 1742972756467,
"cube": 9.699999809265137,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.5,
"phoneNumber": "+12025550185",
"lastName": "Customer6",
"status": 1,
"firstName": "Customer6",
"alias": "Customer 6",
"state": 1,
"type": 1,
"priority": 0,
"id": 879882,
"location": [
48.90092,
2.400039
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550186",
"email": "customer7@example.com",
"lastName": "Customer7",
"firstName": "Customer7",
"alias": "Customer 7",
"customData": "",
"id": 1791100,
"location": [
48.860914,
2.310625
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.9005959375,
2.4000475
],
"actualLocation": [
0,
0
],
"indexInRoute": 7,
"indexInOptimization": 6,
"arrivalTime": 1596815550000,
"timeToNextOrder": 646,
"waitTime": 0,
"numberOfPackagesAtArrival": 49,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 9,
"weightAtArrival": 59.599998474121094,
"collectedWeight": 0,
"deliveredWeight": 16.5,
"cubeAtArrival": 34.79999923706055,
"collectedCube": 0,
"deliveredCube": 9.699999809265137,
"traveledDistance": 23.118459701538086,
"distanceToNextOrder": 5.517826080322266,
"revenueAtArrival": 50.099998474121094,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.299999952316284,
"serviceTime": 0,
"timeWindow": [
1596810600000,
1596819600000
],
"creationTimestamp": 1742972756467,
"cube": 11.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 4.800000190734863,
"phoneNumber": "+120255501811",
"lastName": "Customer12",
"status": 1,
"firstName": "Customer12",
"alias": "Customer 12",
"state": 1,
"type": 0,
"priority": 0,
"id": 879888,
"location": [
48.895658,
2.344043
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550180",
"email": "customer1@example.com",
"lastName": "Customer1",
"firstName": "Customer1",
"alias": "Customer 1",
"customData": "",
"id": 1791094,
"location": [
48.870852,
2.356148
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.8958034375,
2.344040625
],
"actualLocation": [
0,
0
],
"indexInRoute": 8,
"indexInOptimization": 0,
"arrivalTime": 1596816196000,
"timeToNextOrder": 339,
"waitTime": 0,
"numberOfPackagesAtArrival": 40,
"collectedNumberOfPackages": 6,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 43.099998474121094,
"collectedWeight": 4.800000190734863,
"deliveredWeight": 0,
"cubeAtArrival": 25.099998474121094,
"collectedCube": 11.5,
"deliveredCube": 0,
"traveledDistance": 28.63628578186035,
"distanceToNextOrder": 2.137082099914551,
"revenueAtArrival": 60.099998474121094,
"visitTimestamp": 0
}
],
"totalTime": 32935,
"totalDistance": 30.77336883544922,
"id": 251840
},
{
"configurationParameters": {
"orderSequenceOptions": [],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 18000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 1"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 99999999,
"minDistance": 0,
"maxDistance": 100000000,
"maxRevenue": 85,
"fuelPrice": 1.0700000524520874
},
"rideStatus": 1,
"vehicle": {
"length": 0,
"weight": 0,
"width": 0,
"licensePlate": "0",
"consumption": 6.5,
"fuelType": 2,
"make": "0",
"id": 135933,
"name": "Car vehicle 2",
"model": "Master",
"costPerHour": 0,
"type": 0,
"status": 0,
"maxLoadWeight": 60,
"height": 0,
"maxLoadCube": 50,
"idDriver": 135933,
"endTime": 1439,
"fixedCost": 0,
"startTime": 420,
"lastPosition": [
48.82674,
2.342116
]
},
"destination": {
"depotId": 0,
"alias": "Destination 2",
"address": {
"streetNumber": "2",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"county": "Paris",
"state": "Ile-de-France",
"extra": "0",
"city": "Paris",
"country": "France"
},
"location": [
48.872064,
2.402497
],
"matchedLocation": [
48.87198625,
2.4021184375
],
"arrivalTime": 1596804724000,
"traveledDistance": 10.90737533569336
},
"departure": {
"depotId": 0,
"alias": "Depot 2",
"address": {
"streetNumber": "2",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"county": "Paris",
"state": "Ile-de-France",
"extra": "0",
"city": "Paris",
"country": "France"
},
"location": [
48.82674,
2.342116
],
"matchedLocation": [
48.82679375,
2.3420853125
],
"numberOfpackages": 19,
"weight": 27.5,
"cube": 10.399999618530273,
"departureTime": 1596783600000,
"timeToNext": 12,
"distanceToNext": 0.07019499689340591
},
"shape": "mn_iH_mhMCVuGuBQIy@s@SDOLIxFzAOlAIfHJJi@FmAtAgQBq@t@_J@g@[aQkAyi@ByLAkCC_AiHedA^w@M[@O`ByMoBmNmA{AyEdGwFlDkD`@WlAwCFc@HWaBsGs@gC}BiGOUUYaGqOm@gB}@}C[wBc@wAaAoCW{@q@}CoBeN_@}Bo@wCc@_BaBaFcAhBQD_FwH{Zq@_@ip@qLmEdOjC|BMPER?^HVFHNFPEJIH]Ac@EOGIGqAn@sPeNaBICQWyBS[FkD_@sOv@mFd@_PbD{@TiAb@wAr@iDzBs@j@oBzB_J_A~@uAdAcBv@m@ReAT{BV{AXuBn@mHbFEKIEI@MPmNoLeDkCkE|DcHxFA]{CcOGc@?k@iAn@",
"creationTimestamp": 1743084580728,
"neededFuel": 0.7089794278144836,
"matrixBuildType": 1,
"price": 0.7586080431938171,
"totalWaitTime": 19492,
"totalServiceTime": 0,
"optimizationId": 137831,
"orders": [
{
"orderInfo": {
"revenue": 0,
"serviceTime": 0,
"timeWindow": [
1596783600000,
1596823600000
],
"creationTimestamp": 1742972756467,
"cube": 0,
"numberOfPackages": 0,
"depotId": 0,
"customData": "",
"weight": 0,
"phoneNumber": "+12025550181",
"lastName": "Customer2",
"status": 1,
"firstName": "Customer2",
"alias": "Customer 2",
"state": 1,
"type": 0,
"priority": 0,
"id": 879878,
"location": [
48.827327,
2.342267
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+120255501810",
"email": "customer11@example.com",
"lastName": "Customer11",
"firstName": "Customer11",
"alias": "Customer 11",
"customData": "",
"id": 1791104,
"location": [
48.870449,
2.342204
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.82734625,
2.3421875
],
"actualLocation": [
0,
0
],
"indexInRoute": 0,
"indexInOptimization": 10,
"arrivalTime": 1596783612000,
"timeToNextOrder": 496,
"waitTime": 19492,
"numberOfPackagesAtArrival": 19,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 27.5,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 10.399999618530273,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 0.07019499689340591,
"distanceToNextOrder": 3.399907112121582,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 14.699999809265137,
"serviceTime": 0,
"timeWindow": [
1596803600000,
1596823600000
],
"creationTimestamp": 1742972756467,
"cube": 4.599999904632568,
"numberOfPackages": 11,
"depotId": 0,
"customData": "",
"weight": 12.100000381469727,
"phoneNumber": "+12025550187",
"lastName": "Customer8",
"status": 1,
"firstName": "Customer8",
"alias": "Customer 8",
"state": 1,
"type": 1,
"priority": 0,
"id": 879884,
"location": [
48.827865,
2.379216
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550184",
"email": "customer5@example.com",
"lastName": "Customer5",
"firstName": "Customer5",
"alias": "Customer 5",
"customData": "",
"id": 1791098,
"location": [
48.897163,
2.292865
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.82792,
2.3791415625
],
"actualLocation": [
0,
0
],
"indexInRoute": 1,
"indexInOptimization": 4,
"arrivalTime": 1596803600000,
"timeToNextOrder": 535,
"waitTime": 0,
"numberOfPackagesAtArrival": 19,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 11,
"weightAtArrival": 27.5,
"collectedWeight": 0,
"deliveredWeight": 12.100000381469727,
"cubeAtArrival": 10.399999618530273,
"collectedCube": 0,
"deliveredCube": 4.599999904632568,
"traveledDistance": 3.470102071762085,
"distanceToNextOrder": 3.6211578845977783,
"revenueAtArrival": 0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.700000047683716,
"serviceTime": 0,
"timeWindow": [
1596803600000,
1596820600000
],
"creationTimestamp": 1742972756467,
"cube": 5.800000190734863,
"numberOfPackages": 8,
"depotId": 0,
"customData": "",
"weight": 15.399999618530273,
"phoneNumber": "+12025550183",
"lastName": "Customer4",
"status": 1,
"firstName": "Customer4",
"alias": "Customer 4",
"state": 1,
"type": 1,
"priority": 0,
"id": 879880,
"location": [
48.845198,
2.402896
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12025550188",
"email": "customer9@example.com",
"lastName": "Customer9",
"firstName": "Customer9",
"alias": "Customer 9",
"customData": "",
"id": 1791102,
"location": [
48.887096,
2.283513
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "0",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.8452625,
2.4027009375
],
"actualLocation": [
0,
0
],
"indexInRoute": 2,
"indexInOptimization": 8,
"arrivalTime": 1596804135000,
"timeToNextOrder": 589,
"waitTime": 0,
"numberOfPackagesAtArrival": 8,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 8,
"weightAtArrival": 15.399999618530273,
"collectedWeight": 0,
"deliveredWeight": 15.399999618530273,
"cubeAtArrival": 5.799999713897705,
"collectedCube": 0,
"deliveredCube": 5.800000190734863,
"traveledDistance": 7.091259956359863,
"distanceToNextOrder": 3.816114902496338,
"revenueAtArrival": 14.699999809265137,
"visitTimestamp": 0
}
],
"totalTime": 21124,
"totalDistance": 10.90737533569336,
"id": 251841
}
]
}

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.

For more details, refer to the RestAPI documentation .