Skip to main content
GuidesExamples

Add Optimization with Multiple Departures

Estimated reading time: 18 minutes

Overview

This example demonstrates how to create and optimize a fleet management solution using the Fleet Management RestAPI with multiple vehicles starting from different departure points. The example covers the following features:

  • Adding an optimization with multiple vehicles and different departure 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 different departure points, 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: 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 3: Create Departures

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. Since the route is round-trip, the vehicle will start and end at the same point.
[
{
"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
]
}
]

Step 4: 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": [],
"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": 0,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"matrixBuildType": 1
}
  • Response Body: (error code 200)
{
"id": 137827,
"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": [],
"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": 0,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"creationTimestamp": 1751445531341,
"matrixBuildType": 1,
"request": {
"id": 26547,
"optimizationId": 137827,
"status": 1,
"message": "Operation done successfully!",
"creationTimestamp": 1751445531341
}
}

Step 5: 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.

Example:

  • Response Body: (error code 200)
{
"routes": [
{
"configurationParameters": {
"orderSequenceOptions": [],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 0,
"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": "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
],
"arrivalTime": 1596811239000,
"traveledDistance": 42.90754699707031
},
"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": 34,
"weight": 49.20000076293945,
"cube": 21.600000381469727,
"departureTime": 1596794287583,
"timeToNext": 312,
"distanceToNext": 1.8536280393600464
},
"shape": "a`hiHwfkM`GxCBVVPPHuArJe@zD}BzPeArIeDd^sArOMb@C`@fLhENeB[{E{@wKK@mFkAiCYqCRa@HIWaD}HS[?uA_Mq@gHab@{g@YmAoHuc@eBgJqL_Pw@kA}@}@u@eAsUuZyHmKaG}HcGyIcJeMa@q@{@sAa@a@{@eAeCgDm@sAa@m@yGkHsBkB{{@kFyF@eASOeAe@OEwBqDp@sIyHgLm@f@uEkHhE_RhBcQXqA`BwDDTEUs@~Am@vAYpAoA~LvGxJzCEfFoIJDJA@TEzByBdr@k@q@SOKo@G_C@cB@q@HaA^mCZsLi@ZgAn@qAhA{Af@k@vA{@hAe@nA]fX_Gt\\iGlF_A~Di@nCaA`Bw@fCqB~@cAlKoNlBmCh{@j@oAh@aBn@kChByJf@mBVs@jAgC~B{Ch@e@rJ{ErDsBjDaBnA@bJuH`CwArCyAjAa@zCk@`CKtOF~EHzGG`G]`J_AtOwAtCBvRbAjBlDm@dAYnBy@fBcApBy@~Aa@zA?jABtGdANXjF~AfC\\FPNVD~@c@`KEb@Kb@D`BoA[x@FPIGj@o@fOlIt@jC|BMPER?^HVFHNFPEJIdEnAzSrFHzDZbDlILRXDBpBEx@IZw@bG@TBFNH|@\\FNDXB`@dLrSr@lFdB~KHp@IDGJCV@J~@BFHLDLEDEpF`MhOr\\~EuGtAnE`BiAJChBbGd{BvAnEdBaBaPhOwGbGsM~LiItHgBz[PyIpCuAv@aJbHGPgDhCSJUEWUiCvDi@j@mAbBaBjCyChEe@bAoMdTmL`S{@bDoBvJsCfMgAhFc@nB_BrFyBx{@vBuAdDK^oB`L]vA{CzHaC`EkDfFqAf{DpImAvILhECd@wApJq@dDcEpQmA`Gg@rBmEfTuF|XcAvF]zAIz@CpA?lCDdE@zHDtDbJh@KzIpFcHYaACqKTe@AeIT_LRG]IMMCSHiDcI_CF_BwAoCmBeDiBOEgEz@yHPh@j_@aGxFMHgDnEW\\cCtGEGGGDCN@LFF_DtHq@zAx@jGkHhKZRkGeE_R~QOYWUYEM@UFOLKPKTEVCj@Dj@DTP^ZTQzEu@rLS\\J_ArMKvB{@~Kw@dN_AaBqCpDMKKDGRBTFHF@HClCGDPEPCXsMzN}EdFyGcX{Nqd@f@a@w@yCo@h@gDaK{AcFyJ|GqB{M@cFYeA_BmDoBqDk@mAmDkJMw@aAmCAm@`NoNeCgIw{DKYtLcJdEmGrBcCt@uAfIqPNm@@]eHiW}ByIm@aBaCuIS_AMoACkCEkOCs@IwKAsD?kBEkFGeAGeIsHMaMAiGrCkCl@e@{AiWrAt@OtAmHh@ZhANAaCDxOlDnBd@N`GrArCh@b@uGjC{NXuB?UDGfJqFpE{BlAyGxDmFFUBs@fUNn@GTKTWx@q@`FiEtIwHn{BbPkNlAk@^]NSjBcBPbJ_IxAn@dPdI",
"creationTimestamp": 1743064207280,
"neededFuel": 2.7889904975891113,
"matrixBuildType": 1,
"price": 2.984220027923584,
"totalWaitTime": 10534,
"totalServiceTime": 0,
"optimizationId": 137827,
"orders": [
{
"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": 0,
"indexInOptimization": 1,
"arrivalTime": 1596812600000,
"timeToNextOrder": 1075,
"waitTime": 9925,
"numberOfPackagesAtArrival": 34,
"collectedNumberOfPackages": 10,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 49.20000076293945,
"collectedWeight": 8,
"deliveredWeight": 0,
"cubeAtArrival": 21.600000381469727,
"collectedCube": 4.099999904632568,
"deliveredCube": 0,
"traveledDistance": 1.8536280393600464,
"distanceToNextOrder": 6.322669982910156,
"revenueAtArrival": 0,
"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": 1,
"indexInOptimization": 6,
"arrivalTime": 1596805600000,
"timeToNextOrder": 857,
"waitTime": 0,
"numberOfPackagesAtArrival": 44,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 9,
"weightAtArrival": 57.20000076293945,
"collectedWeight": 0,
"deliveredWeight": 16.5,
"cubeAtArrival": 25.700000762939453,
"collectedCube": 0,
"deliveredCube": 9.699999809265137,
"traveledDistance": 8.176298141479492,
"distanceToNextOrder": 9.274402618408203,
"revenueAtArrival": 6.199999809265137,
"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": 1596806457000,
"timeToNextOrder": 530,
"waitTime": 0,
"numberOfPackagesAtArrival": 35,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 8,
"weightAtArrival": 40.70000076293945,
"collectedWeight": 0,
"deliveredWeight": 15.399999618530273,
"cubeAtArrival": 16,
"collectedCube": 0,
"deliveredCube": 5.800000190734863,
"traveledDistance": 17.450700759887695,
"distanceToNextOrder": 3.185900926589966,
"revenueAtArrival": 16.200000762939453,
"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": 3,
"indexInOptimization": 4,
"arrivalTime": 1596806987000,
"timeToNextOrder": 1027,
"waitTime": 0,
"numberOfPackagesAtArrival": 27,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 11,
"weightAtArrival": 25.30000114440918,
"collectedWeight": 0,
"deliveredWeight": 12.100000381469727,
"cubeAtArrival": 10.199999809265137,
"collectedCube": 0,
"deliveredCube": 4.599999904632568,
"traveledDistance": 20.6366024017334,
"distanceToNextOrder": 6.921174049377441,
"revenueAtArrival": 18.900001525878906,
"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": 4,
"indexInOptimization": 5,
"arrivalTime": 1596808014000,
"timeToNextOrder": 497,
"waitTime": 0,
"numberOfPackagesAtArrival": 16,
"collectedNumberOfPackages": 5,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 13.200000762939453,
"collectedWeight": 7.5,
"deliveredWeight": 0,
"cubeAtArrival": 5.599999904632568,
"collectedCube": 2.5999999046325684,
"deliveredCube": 0,
"traveledDistance": 27.557777404785156,
"distanceToNextOrder": 3.117466926574707,
"revenueAtArrival": 33.60000228881836,
"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": 5,
"indexInOptimization": 9,
"arrivalTime": 1596808511000,
"timeToNextOrder": 369,
"waitTime": 0,
"numberOfPackagesAtArrival": 21,
"collectedNumberOfPackages": 3,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 20.700000762939453,
"collectedWeight": 5.099999904632568,
"deliveredWeight": 0,
"cubeAtArrival": 8.199999809265137,
"collectedCube": 2.5,
"deliveredCube": 0,
"traveledDistance": 30.675243377685547,
"distanceToNextOrder": 1.8877489566802979,
"revenueAtArrival": 47,
"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": 6,
"indexInOptimization": 3,
"arrivalTime": 1596808880000,
"timeToNextOrder": 330,
"waitTime": 0,
"numberOfPackagesAtArrival": 24,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 6,
"weightAtArrival": 25.80000114440918,
"collectedWeight": 0,
"deliveredWeight": 5.199999809265137,
"cubeAtArrival": 10.699999809265137,
"collectedCube": 0,
"deliveredCube": 1.5,
"traveledDistance": 32.562992095947266,
"distanceToNextOrder": 1.9110699892044067,
"revenueAtArrival": 59,
"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": 7,
"indexInOptimization": 7,
"arrivalTime": 1596809210000,
"timeToNextOrder": 486,
"waitTime": 0,
"numberOfPackagesAtArrival": 18,
"collectedNumberOfPackages": 9,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 20.60000228881836,
"collectedWeight": 16.200000762939453,
"deliveredWeight": 0,
"cubeAtArrival": 9.199999809265137,
"collectedCube": 8.399999618530273,
"deliveredCube": 0,
"traveledDistance": 34.474063873291016,
"distanceToNextOrder": 2.9220430850982666,
"revenueAtArrival": 61.900001525878906,
"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": 8,
"indexInOptimization": 2,
"arrivalTime": 1596809696000,
"timeToNextOrder": 295,
"waitTime": 609,
"numberOfPackagesAtArrival": 27,
"collectedNumberOfPackages": 13,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 36.80000305175781,
"collectedWeight": 6.300000190734863,
"deliveredWeight": 0,
"cubeAtArrival": 17.599998474121094,
"collectedCube": 7.5,
"deliveredCube": 0,
"traveledDistance": 37.3961067199707,
"distanceToNextOrder": 1.8992279767990112,
"revenueAtArrival": 69.4000015258789,
"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": 9,
"indexInOptimization": 0,
"arrivalTime": 1596810600000,
"timeToNextOrder": 633,
"waitTime": 0,
"numberOfPackagesAtArrival": 40,
"collectedNumberOfPackages": 6,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 43.10000228881836,
"collectedWeight": 4.800000190734863,
"deliveredWeight": 0,
"cubeAtArrival": 25.099998474121094,
"collectedCube": 11.5,
"deliveredCube": 0,
"traveledDistance": 39.29533386230469,
"distanceToNextOrder": 3.5871338844299316,
"revenueAtArrival": 77.5,
"visitTimestamp": 0
},
{
"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": 10,
"indexInOptimization": 11,
"arrivalTime": 1596811233000,
"timeToNextOrder": 6,
"waitTime": 0,
"numberOfPackagesAtArrival": 46,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 47.900001525878906,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 36.599998474121094,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 42.882469177246094,
"distanceToNextOrder": 0.02507600001990795,
"revenueAtArrival": 79.80000305175781,
"visitTimestamp": 0
}
],
"totalTime": 16951,
"totalDistance": 42.90754699707031,
"id": 251838
}

"configurationParameters": {
"orderSequenceOptions": [],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 0,
"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": "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
],
"arrivalTime": 1596783691000,
"traveledDistance": 0.6638350486755371
},
"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": 0,
"weight": 0,
"cube": 0,
"departureTime": 1596783600000,
"timeToNext": 12,
"distanceToNext": 0.07019499689340591
},
"shape": "mn_iH_mhMCVuGuBQIy@s@SDOLIxFzAOlAIfHJJi@mAa@BW",
"creationTimestamp": 1743064207632,
"neededFuel": 0.04314928129315376,
"matrixBuildType": 1,
"price": 0.04616973176598549,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 137827,
"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": 79,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0,
"collectedWeight": 0,
"deliveredWeight": 0,
"cubeAtArrival": 0,
"collectedCube": 0,
"deliveredCube": 0,
"traveledDistance": 0.07019499689340591,
"distanceToNextOrder": 0.5936400294303894,
"revenueAtArrival": 0,
"visitTimestamp": 0
}
],
"totalTime": 91,
"totalDistance": 0.6638350486755371,
"id": 251839
}
]
}

Conclusion

This example demonstrates how to create a fully customized optimization with multiple vehicles starting from different departure points, 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 .