Add Optimization with Multiple Departures
This example demonstrates how to create and optimize a fleet management solution using the Fleet Management Rest API 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:
- An optimization is created and saved.
- The optimized solution is returned and displayed on the map.
Step-by-Step Guide
Step 1: Create Customers and Orders
Each order must have a customer associated with it. You can either:
- Create a new customer and assign it to the order.
- Use an existing customer (refer to the Get Customer example).
Initializing and Adding Customers
- Initialize Customers: Create twelve
Customerobjects and populate their fields (e.g., name, address, contact details). - Send Request: Call the
Add Customersendpoint to save these customers in the system.
- Method:
POST - Endpoint:
/customers - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/customers
If the operation is successful, the Customer object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer1@example.com",
"phoneNumber": "+12025550180",
"location": [
48.870852,
2.356148
],
"customData": ""
},
{
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
{
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer3@example.com",
"phoneNumber": "+12025550182",
"location": [
48.88025,
2.299601
],
"customData": ""
},
{
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer4@example.com",
"phoneNumber": "+12025550183",
"location": [
48.845198,
2.402896
],
"customData": ""
},
{
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer5@example.com",
"phoneNumber": "+12025550184",
"location": [
48.897163,
2.292865
],
"customData": ""
},
{
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer6@example.com",
"phoneNumber": "+12025550185",
"location": [
48.90092,
2.400039
],
"customData": ""
},
{
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
{
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer8@example.com",
"phoneNumber": "+12025550187",
"location": [
48.827865,
2.379216
],
"customData": ""
},
{
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer9@example.com",
"phoneNumber": "+12025550188",
"location": [
48.887096,
2.283513
],
"customData": ""
},
{
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer10@example.com",
"phoneNumber": "+12025550189",
"location": [
48.896894,
2.321586
],
"customData": ""
},
{
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer11@example.com",
"phoneNumber": "+120255501810",
"location": [
48.870449,
2.342204
],
"customData": ""
},
{
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
}
]
- Response Body: (error code
200)
[
{
"id": 1791105,
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer1@example.com",
"phoneNumber": "+12025550180",
"location": [
48.870852,
2.356148
],
"customData": ""
},
{
"id": 1791104,
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
{
"id": 1791103,
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer3@example.com",
"phoneNumber": "+12025550182",
"location": [
48.88025,
2.299601
],
"customData": ""
},
{
"id": 1791102,
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer4@example.com",
"phoneNumber": "+12025550183",
"location": [
48.845198,
2.402896
],
"customData": ""
},
{
"id": 1791101,
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer5@example.com",
"phoneNumber": "+12025550184",
"location": [
48.897163,
2.292865
],
"customData": ""
},
{
"id": 1791100,
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer6@example.com",
"phoneNumber": "+12025550185",
"location": [
48.90092,
2.400039
],
"customData": ""
},
{
"id": 1791099,
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
{
"id": 1791098,
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer8@example.com",
"phoneNumber": "+12025550187",
"location": [
48.827865,
2.379216
],
"customData": ""
},
{
"id": 1791097,
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer9@example.com",
"phoneNumber": "+12025550188",
"location": [
48.887096,
2.283513
],
"customData": ""
},
{
"id": 1791096,
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer10@example.com",
"phoneNumber": "+12025550189",
"location": [
48.896894,
2.321586
],
"customData": ""
},
{
"id": 1791095,
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer11@example.com",
"phoneNumber": "+120255501810",
"location": [
48.870449,
2.342204
],
"customData": ""
},
{
"id": 1791094,
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
}
]
Initializing and Adding Orders
- Initialize Orders: Create twelve
Orderobjects and associate each with a customer. Populate fields such as time windows, package details, and weights. - Send Request: Call the
Add Ordersendpoint to save these orders in the system.
- Method:
POST - Endpoint:
/orders - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/orders
If the operation is successful, the Order object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"customerId": 1791105,
"location": [
48.870852,
2.356148
],
"alias": "Customer 1",
"firstName": "Customer1",
"lastName": "Customer1",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550180",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 1,
"weight": 3.2,
"cube": 0.1,
"revenue": 13,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791104,
"location": [
48.892138,
2.330583
],
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550181",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 1,
"weight": 4.6,
"cube": 0.1,
"revenue": 14.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791103,
"location": [
48.88025,
2.299601
],
"alias": "Customer 3",
"firstName": "Customer3",
"lastName": "Customer3",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550182",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 12,
"timeWindow": [
770,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791102,
"location": [
48.845198,
2.402896
],
"alias": "Customer 4",
"firstName": "Customer4",
"lastName": "Customer4",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550183",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 5.8,
"revenue": 2.7,
"timeWindow": [
753,
1036
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791101,
"location": [
48.897163,
2.292865
],
"alias": "Customer 5",
"firstName": "Customer5",
"lastName": "Customer5",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550184",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.2,
"cube": 8.4,
"revenue": 7.5,
"timeWindow": [
736,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791100,
"location": [
48.90092,
2.400039
],
"alias": "Customer 6",
"firstName": "Customer6",
"lastName": "Customer6",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550185",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 9,
"weight": 16.5,
"cube": 9.7,
"revenue": 10,
"timeWindow": [
786,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791099,
"location": [
48.890914,
2.310625
],
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550186",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 2.6,
"revenue": 13.4,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791098,
"location": [
48.827865,
2.379216
],
"alias": "Customer 8",
"firstName": "Customer8",
"lastName": "Customer8",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550187",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 11,
"weight": 12.1,
"cube": 4.6,
"revenue": 14.7,
"timeWindow": [
753,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791097,
"location": [
48.887096,
2.283513
],
"alias": "Customer 9",
"firstName": "Customer9",
"lastName": "Customer9",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550188",
"customData": "",
"type": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 5.2,
"cube": 1.5,
"revenue": 2.9,
"timeWindow": [
770,
1070
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791096,
"location": [
48.896894,
2.321586
],
"alias": "Customer 10",
"firstName": "Customer10",
"lastName": "Customer10",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550189",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 13,
"weight": 6.3,
"cube": 7.5,
"revenue": 8.1,
"timeWindow": [
836,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791095,
"location": [
48.870449,
2.342204
],
"alias": "Customer 11",
"firstName": "Customer11",
"lastName": "Customer11",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501810",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 10,
"weight": 8,
"cube": 4.1,
"revenue": 6.2,
"timeWindow": [
903,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"customerId": 1791094,
"location": [
48.895658,
2.344042
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
- Response Body: (error code
200)
[
{
"id": 879888,
"creationTimestamp": 1763486363150,
"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": 1,
"weight": 3.2,
"cube": 0.1,
"revenue": 13,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879887,
"creationTimestamp": 1763486363150,
"customerInfo": {
"id": 1791104,
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
"location": [
48.892138,
2.330583
],
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550181",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 1,
"weight": 4.6,
"cube": 0.1,
"revenue": 14.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879886,
"creationTimestamp": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"customerInfo": {
"id": 1791099,
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
"location": [
48.890914,
2.310625
],
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550186",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 2.6,
"revenue": 13.4,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879881,
"creationTimestamp": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"customerInfo": {
"id": 1791094,
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
},
"location": [
48.895658,
2.344042
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
Step 2: Create the Vehicle and Define Vehicle Constraints
Vehicles are the resources that will be used to fulfill the orders. Each vehicle can have specific constraints and capabilities.
Adding Vehicles
- Initialize Vehicles: Create two
Vehicleobjects and populate their fields (e.g., type, capacity, availability). - Send Request: Call the
Add Vehiclesendpoint to save these vehicles in the database.
- Method:
POST - Endpoint:
/vehicles - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/vehicles
If the operation is successful, the Vehicle object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
]
- Response Body: (error code
200)
[
{
"id": 135932,
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"id": 135933,
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
]
Define Vehicle Constraints
Vehicle constraints define the limitations and requirements applied to a vehicle during the route optimization process. Ensure that the vehicle operates within its capabilities, such as time windows, capacity, distance, and revenue.
- Create Constraints: Define a
VehicleConstraintsobject that applies to both vehicles. Add this object to a list.
[
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
]
Step 3: Create Departures
- Departures: Define the starting points for vehicle routes. These locations impact optimization by influencing travel distance and time.
- Destinations: Define the final stops for vehicle routes. These locations ensure routes are optimized for efficiency.
Adding Departures and Destinations
- Initialize Departures: Create two
Departureobjects, one for each vehicle. 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"
}
},
{
"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"
}
}
]
Step 4: Create the Optimization
An optimization represents a routing problem defined by orders, vehicles, constraints, and configuration parameters. This step combines all the elements to generate an optimized solution.
- Create Optimization: Define an
Optimizationobject and assign theOrderList,ConfigurationParameters,VehicleList,VehicleConstraintsList, andDepartures. - Send Request: Call the
Add Optimizationendpoint to create the optimization.
- Method:
POST - Endpoint:
/optimizations - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/optimizations - Query Parameter:
encodeShape(integer, optional)0: The route's shape will not be encoded.1(default): The route's shape will be encoded.
Adding an optimization returns a request object, which allows you to track the status of the optimization process. Once the request status is finished, the solution can be retrieved using Get Optimization's Solution request. The solution consists of one or more routes. A route is the trip that a vehicle travels to visit the orders, so the number of routes returned is maximum the number of vehicles set in the optimization(see Routes).
If the operation is successful, the Optimization object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
{
"orders": [
879888,
879887,
879886,
879885,
879884,
879883,
879882,
879881,
879880,
879879,
879878,
879877
],
"departures": [
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"destinations": [],
"vehicles": [
135932,
135933
],
"vehiclesConstraints": [
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
],
"configurationParameters": {
"name": "Paris - test optimization",
"ignoreTimeWindow": false,
"allowDroppingOrders": false,
"groupingOrders": false,
"balancedRoutes": 0,
"optimizationCriterion": 0,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 300,
"maxWaitTime": 8000,
"routeType": 0,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"matrixBuildType": 1
}
- Response Body: (error code
200)
{
"id": 137827,
"orders": [
{
"id": 879888,
"creationTimestamp": 1763486363150,
"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": 1,
"weight": 3.2,
"cube": 0.1,
"revenue": 13,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879887,
"creationTimestamp": 1763486363150,
"customerInfo": {
"id": 1791104,
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer2@example.com",
"phoneNumber": "+12025550181",
"location": [
48.892138,
2.330583
],
"customData": ""
},
"location": [
48.892138,
2.330583
],
"alias": "Customer 2",
"firstName": "Customer2",
"lastName": "Customer2",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550181",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 1,
"weight": 4.6,
"cube": 0.1,
"revenue": 14.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879886,
"creationTimestamp": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"customerInfo": {
"id": 1791099,
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer7@example.com",
"phoneNumber": "+12025550186",
"location": [
48.890914,
2.310625
],
"customData": ""
},
"location": [
48.890914,
2.310625
],
"alias": "Customer 7",
"firstName": "Customer7",
"lastName": "Customer7",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+12025550186",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 2.6,
"revenue": 13.4,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879881,
"creationTimestamp": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"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": 1763486363150,
"customerInfo": {
"id": 1791094,
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"email": "customer12@example.com",
"phoneNumber": "+120255501811",
"location": [
48.895658,
2.344042
],
"customData": ""
},
"location": [
48.895658,
2.344042
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
],
"departures": [
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"destinations": [],
"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": 9,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
],
"configurationParameters": {
"name": "Paris - test optimization",
"ignoreTimeWindow": false,
"allowDroppingOrders": false,
"groupingOrders": false,
"balancedRoutes": 0,
"optimizationCriterion": 0,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 300,
"maxWaitTime": 8000,
"routeType": 0,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": []
},
"creationTimestamp": 1763486363150,
"matrixBuildType": 1,
"request": {
"id": 26547,
"optimizationId": 137827,
"status": 1,
"message": "Operation done successfully!",
"creationTimestamp": 1763486363150
}
}
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)
{
"totalRecords": 1,
"routes": [
{
"configurationParameters": {
"orderSequenceOptions": [
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 0,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 0"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0.0,
"maxDistance": 100000000.0,
"maxRevenue": 100000000.0,
"fuelPrice": 1.0900000333786010742
},
"rideStatus": 1,
"vehicle": {
"length": 0.0,
"weight": 0.0,
"width": 0.0,
"licensePlate": "AA-123-AA",
"consumption": 6.5,
"fuelType": 0,
"make": "Renault",
"id": 161787,
"name": "Car vehicle 1",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161787,
"endTime": 1100,
"fixedCost": 0.0,
"startTime": 420,
"lastPosition": [
2147483647.0,
2147483647.0
]
},
"destination": {
"depotId": 0,
"alias": "Depot 1",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.870569000000003257,
2.3564479999999998761
],
"matchedLocation": [
48.870568437499997572,
2.356441562500000142
],
"arrivalTime": 1596808963000,
"traveledDistance": 28.620336532592773438
},
"departure": {
"depotId": 0,
"alias": "Depot 1",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.870569000000003257,
2.3564479999999998761
],
"matchedLocation": [
48.870568437499997572,
2.356441562500000142
],
"numberOfpackages": 15,
"weight": 21.700000762939453125,
"cube": 11.199999809265136719,
"departureTime": 1596804545693,
"timeToNext": 1014,
"distanceToNext": 5.9496679306030273438
},
"shape": "a`hiHwfkM`GxCBVVPPHs@~Ek_@_QqAu@o@WwD{BOOx@uIDYFSHEAIGAU_@OKiDiBaF}ByBqAwAeBwKoNsC{DoKqNw@kA}@}@qQ}UwD}EyHmKaG}HcGyIcJeMa@q@{@sAa@a@",
"creationTimestamp": 1752827971650,
"neededFuel": 1.8603217601776123047,
"matrixBuildType": 1,
"price": 2.0277507305145263672,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148940,
"orders": [
{
"orderInfo": {
"revenue": 10.0,
"serviceTime": 0,
"timeWindow": [
786,
1053
],
"creationTimestamp": 1752827968147,
"cube": 9.6999998092651367188,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.5,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c5",
"state": 1,
"type": 1,
"priority": 0,
"id": 1193989,
"location": [
48.900919999999999277,
2.4000390000000000335
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c5@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c5",
"customData": "",
"id": 1998408,
"location": [
48.900919999999999277,
2.4000390000000000335
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.900595937500000332,
2.4000474999999998893
],
"indexInRoute": 0,
"indexInOptimization": 5,
"arrivalTime": 1596805560000,
"timeToNextOrder": 646,
"waitTime": 0,
"numberOfPackagesAtArrival": 15,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 9,
"weightAtArrival": 21.700000762939453125,
"collectedWeight": 0.0,
"deliveredWeight": 16.5,
"cubeAtArrival": 11.199999809265136719,
"collectedCube": 0.0,
"deliveredCube": 9.6999998092651367188,
"traveledDistance": 5.9496679306030273438,
"distanceToNextOrder": 5.5179982185363769531,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.2999999523162841797,
"serviceTime": 0,
"timeWindow": [
870,
1020
],
"creationTimestamp": 1752827968329,
"cube": 11.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 4.8000001907348632812,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c11",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193995,
"location": [
48.895657999999997401,
2.3440430000000000987
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c11@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c11",
"customData": "",
"id": 1998414,
"location": [
48.895657999999997401,
2.3440430000000000987
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.895803437499999688,
2.3440406249999998778
],
"indexInRoute": 1,
"indexInOptimization": 11,
"arrivalTime": 1596806206000,
"timeToNextOrder": 259,
"waitTime": 0,
"numberOfPackagesAtArrival": 6,
"collectedNumberOfPackages": 6,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 5.200000762939453125,
"collectedWeight": 4.8000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 1.5,
"collectedCube": 11.5,
"deliveredCube": 0.0,
"traveledDistance": 11.4676666259765625,
"distanceToNextOrder": 1.44077301025390625,
"revenueAtArrival": 10.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 14.100000381469726562,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1752827968029,
"cube": 0.10000000149011611938,
"numberOfPackages": 1,
"depotId": 0,
"customData": "",
"weight": 4.5999999046325683594,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c1",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193985,
"location": [
48.892138000000002762,
2.3305829999999998492
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c1@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c1",
"customData": "",
"id": 1998404,
"location": [
48.892138000000002762,
2.3305829999999998492
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.892148437499997726,
2.3306215625000001879
],
"indexInRoute": 2,
"indexInOptimization": 1,
"arrivalTime": 1596806465000,
"timeToNextOrder": 298,
"waitTime": 0,
"numberOfPackagesAtArrival": 12,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 10.000000953674316406,
"collectedWeight": 4.5999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 13.0,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 12.90843963623046875,
"distanceToNextOrder": 1.7079169750213623047,
"revenueAtArrival": 12.300000190734863281,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 8.1000003814697265625,
"serviceTime": 0,
"timeWindow": [
836,
1053
],
"creationTimestamp": 1752827968267,
"cube": 7.5,
"numberOfPackages": 13,
"depotId": 0,
"customData": "",
"weight": 6.3000001907348632812,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c9",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193993,
"location": [
48.896894000000003189,
2.3215859999999999275
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c9@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c9",
"customData": "",
"id": 1998412,
"location": [
48.896894000000003189,
2.3215859999999999275
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897175937500001908,
2.3212631250000002048
],
"indexInRoute": 3,
"indexInOptimization": 9,
"arrivalTime": 1596806763000,
"timeToNextOrder": 234,
"waitTime": 0,
"numberOfPackagesAtArrival": 13,
"collectedNumberOfPackages": 13,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 14.600000381469726562,
"collectedWeight": 6.3000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 13.100000381469726562,
"collectedCube": 7.5,
"deliveredCube": 0.0,
"traveledDistance": 14.616356849670410156,
"distanceToNextOrder": 1.5619690418243408203,
"revenueAtArrival": 26.40000152587890625,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.399999618530273438,
"serviceTime": 0,
"timeWindow": [
820,
1020
],
"creationTimestamp": 1752827968177,
"cube": 2.5999999046325683594,
"numberOfPackages": 5,
"depotId": 0,
"customData": "",
"weight": 7.5,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c6",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193990,
"location": [
48.890914000000002204,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c6@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c6",
"customData": "",
"id": 1998409,
"location": [
48.890914000000002204,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.891068437500003085,
2.3109646874999998367
],
"indexInRoute": 4,
"indexInOptimization": 6,
"arrivalTime": 1596806997000,
"timeToNextOrder": 379,
"waitTime": 0,
"numberOfPackagesAtArrival": 26,
"collectedNumberOfPackages": 5,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 20.90000152587890625,
"collectedWeight": 7.5,
"deliveredWeight": 0.0,
"cubeAtArrival": 20.600000381469726562,
"collectedCube": 2.5999999046325683594,
"deliveredCube": 0.0,
"traveledDistance": 16.178325653076171875,
"distanceToNextOrder": 2.4352300167083740234,
"revenueAtArrival": 34.5,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 7.5,
"serviceTime": 0,
"timeWindow": [
736,
1086
],
"creationTimestamp": 1752827968117,
"cube": 8.3999996185302734375,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.200000762939453125,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c4",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193988,
"location": [
48.897162999999999045,
2.2928649999999999309
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c4@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c4",
"customData": "",
"id": 1998407,
"location": [
48.897162999999999045,
2.2928649999999999309
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897063750000000937,
2.2924699999999997857
],
"indexInRoute": 5,
"indexInOptimization": 4,
"arrivalTime": 1596807376000,
"timeToNextOrder": 372,
"waitTime": 0,
"numberOfPackagesAtArrival": 31,
"collectedNumberOfPackages": 9,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 28.40000152587890625,
"collectedWeight": 16.200000762939453125,
"deliveredWeight": 0.0,
"cubeAtArrival": 23.200000762939453125,
"collectedCube": 8.3999996185302734375,
"deliveredCube": 0.0,
"traveledDistance": 18.613555908203125,
"distanceToNextOrder": 2.7714979648590087891,
"revenueAtArrival": 47.90000152587890625,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.9000000953674316406,
"serviceTime": 0,
"timeWindow": [
770,
1070
],
"creationTimestamp": 1752827968237,
"cube": 1.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 5.1999998092651367188,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c8",
"state": 1,
"type": 1,
"priority": 0,
"id": 1193992,
"location": [
48.887095999999999663,
2.283513000000000126
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c8@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c8",
"customData": "",
"id": 1998411,
"location": [
48.887095999999999663,
2.283513000000000126
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.886898125000001869,
2.2838078125000000895
],
"indexInRoute": 6,
"indexInOptimization": 8,
"arrivalTime": 1596807748000,
"timeToNextOrder": 354,
"waitTime": 0,
"numberOfPackagesAtArrival": 40,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 6,
"weightAtArrival": 44.600002288818359375,
"collectedWeight": 0.0,
"deliveredWeight": 5.1999998092651367188,
"cubeAtArrival": 31.600000381469726562,
"collectedCube": 0.0,
"deliveredCube": 1.5,
"traveledDistance": 21.385053634643554688,
"distanceToNextOrder": 1.826871037483215332,
"revenueAtArrival": 55.40000152587890625,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 12.0,
"serviceTime": 0,
"timeWindow": [
770,
1020
],
"creationTimestamp": 1752827968059,
"cube": 2.5,
"numberOfPackages": 3,
"depotId": 0,
"customData": "",
"weight": 5.0999999046325683594,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c2",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193986,
"location": [
48.880249999999996646,
2.2996010000000000062
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c2@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c2",
"customData": "",
"id": 1998405,
"location": [
48.880249999999996646,
2.2996010000000000062
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.880213437499996587,
2.2997093749999999446
],
"indexInRoute": 7,
"indexInOptimization": 2,
"arrivalTime": 1596808102000,
"timeToNextOrder": 855,
"waitTime": 0,
"numberOfPackagesAtArrival": 34,
"collectedNumberOfPackages": 3,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 39.40000152587890625,
"collectedWeight": 5.0999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 30.100000381469726562,
"collectedCube": 2.5,
"deliveredCube": 0.0,
"traveledDistance": 23.211925506591796875,
"distanceToNextOrder": 5.3833341598510742188,
"revenueAtArrival": 58.3000030517578125,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.0,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1752827967999,
"cube": 0.10000000149011611938,
"numberOfPackages": 1,
"depotId": 0,
"customData": "",
"weight": 3.2000000476837158203,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c0",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193984,
"location": [
48.870851999999999293,
2.3561480000000001311
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c0@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c0",
"customData": "",
"id": 1998403,
"location": [
48.870851999999999293,
2.3561480000000001311
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.87077843750000028,
2.3565665624999998506
],
"indexInRoute": 8,
"indexInOptimization": 0,
"arrivalTime": 1596808957000,
"timeToNextOrder": 6,
"waitTime": 0,
"numberOfPackagesAtArrival": 37,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 44.5,
"collectedWeight": 3.2000000476837158203,
"deliveredWeight": 0.0,
"cubeAtArrival": 32.59999847412109375,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 28.5952606201171875,
"distanceToNextOrder": 0.025076000019907951355,
"revenueAtArrival": 70.3000030517578125,
"visitTimestamp": 0
}
],
"totalTime": 4417,
"totalDistance": 28.620336532592773438,
"id": 273344
},
{
"configurationParameters": {
"orderSequenceOptions": [
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 0,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 1"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0.0,
"maxDistance": 100000000.0,
"maxRevenue": 100000000.0,
"fuelPrice": 1.0900000333786010742
},
"rideStatus": 1,
"vehicle": {
"length": 0.0,
"weight": 0.0,
"width": 0.0,
"licensePlate": "AA-124-AA",
"consumption": 6.5,
"fuelType": 0,
"make": "Renault",
"id": 161788,
"name": "Car vehicle 2",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161788,
"endTime": 1100,
"fixedCost": 0.0,
"startTime": 420,
"lastPosition": [
2147483647.0,
2147483647.0
]
},
"destination": {
"depotId": 0,
"alias": "Depot 2",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.826740000000000919,
2.3421159999999998647
],
"matchedLocation": [
48.826793750000000216,
2.3420853125000000716
],
"arrivalTime": 1596814585000,
"traveledDistance": 18.42877197265625
},
"departure": {
"depotId": 0,
"alias": "Depot 2",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.826740000000000919,
2.3421159999999998647
],
"matchedLocation": [
48.826793750000000216,
2.3420853125000000716
],
"numberOfpackages": 19,
"weight": 27.5,
"cube": 10.399999618530273438,
"departureTime": 1596811642438,
"timeToNext": 938,
"distanceToNext": 5.8017611503601074219
},
"shape": "mn_iH_mhMCVuGuBQImBeBoAo@kF_CqCu@ax@{IIRy@lCqBnHON[PsJ~DsEbBe@VwHvC{BbAUNUT_DuAcO{HmPmGsBs@}H{Hi@c@_CuAOGIUmDkBY{@MSuFkC}Jvc@gAbF]jAub@qQQGoBUaHvBcE~AR`Bd@",
"creationTimestamp": 1752827971745,
"neededFuel": 1.1978701353073120117,
"matrixBuildType": 1,
"price": 1.3056784868240356445,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148940,
"orders": [
{
"orderInfo": {
"revenue": 6.1999998092651367188,
"serviceTime": 0,
"timeWindow": [
903,
1020
],
"creationTimestamp": 1752827968298,
"cube": 4.0999999046325683594,
"numberOfPackages": 10,
"depotId": 0,
"customData": "",
"weight": 8.0,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c10",
"state": 1,
"type": 0,
"priority": 0,
"id": 1193994,
"location": [
48.870449000000000694,
2.3422040000000001747
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c10@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c10",
"customData": "",
"id": 1998413,
"location": [
48.870449000000000694,
2.3422040000000001747
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.870181875000000105,
2.3423449999999998994
],
"indexInRoute": 0,
"indexInOptimization": 10,
"arrivalTime": 1596812580000,
"timeToNextOrder": 1024,
"waitTime": 0,
"numberOfPackagesAtArrival": 19,
"collectedNumberOfPackages": 10,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 27.5,
"collectedWeight": 8.0,
"deliveredWeight": 0.0,
"cubeAtArrival": 10.399999618530273438,
"collectedCube": 4.0999999046325683594,
"deliveredCube": 0.0,
"traveledDistance": 5.8017611503601074219,
"distanceToNextOrder": 6.4338431358337402344,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.7000000476837158203,
"serviceTime": 0,
"timeWindow": [
753,
1036
],
"creationTimestamp": 1752827968088,
"cube": 5.8000001907348632812,
"numberOfPackages": 8,
"depotId": 0,
"customData": "",
"weight": 15.399999618530273438,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c3",
"state": 1,
"type": 1,
"priority": 0,
"id": 1193987,
"location": [
48.845198000000003447,
2.4028960000000001429
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c3@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c3",
"customData": "",
"id": 1998406,
"location": [
48.845198000000003447,
2.4028960000000001429
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.845262499999996919,
2.4027009375000001334
],
"indexInRoute": 1,
"indexInOptimization": 3,
"arrivalTime": 1596813604000,
"timeToNextOrder": 530,
"waitTime": 0,
"numberOfPackagesAtArrival": 29,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 8,
"weightAtArrival": 35.5,
"collectedWeight": 0.0,
"deliveredWeight": 15.399999618530273438,
"cubeAtArrival": 14.5,
"collectedCube": 0.0,
"deliveredCube": 5.8000001907348632812,
"traveledDistance": 12.235604286193847656,
"distanceToNextOrder": 3.1860260963439941406,
"revenueAtArrival": 6.1999998092651367188,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 14.699999809265136719,
"serviceTime": 0,
"timeWindow": [
753,
1086
],
"creationTimestamp": 1752827968209,
"cube": 4.5999999046325683594,
"numberOfPackages": 11,
"depotId": 0,
"customData": "",
"weight": 12.100000381469726562,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c7",
"state": 1,
"type": 1,
"priority": 0,
"id": 1193991,
"location": [
48.827865000000002738,
2.3792159999999999975
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c7@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c7",
"customData": "",
"id": 1998410,
"location": [
48.827865000000002738,
2.3792159999999999975
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.827919999999998879,
2.3791415625000000844
],
"indexInRoute": 2,
"indexInOptimization": 7,
"arrivalTime": 1596814134000,
"timeToNextOrder": 451,
"waitTime": 0,
"numberOfPackagesAtArrival": 21,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 11,
"weightAtArrival": 20.100000381469726562,
"collectedWeight": 0.0,
"deliveredWeight": 12.100000381469726562,
"cubeAtArrival": 8.6999998092651367188,
"collectedCube": 0.0,
"deliveredCube": 4.5999999046325683594,
"traveledDistance": 15.421630859375,
"distanceToNextOrder": 3.00714111328125,
"revenueAtArrival": 8.8999996185302734375,
"visitTimestamp": 0
}
],
"totalTime": 2943,
"totalDistance": 18.42877197265625,
"id": 273345
}
]
}
Analyzing the Solution - Paris Route Optimization Test

Summary Table
| Metric | Part 0 | Part 1 |
|---|---|---|
| Total Distance | 28.62 km | 18.43 km |
| Total Time | 1 hr 13 min 37 sec | 49 min 2 sec |
| Cost | €2.03 | €1.31 |
| Departure Point | Depot 1 | Depot 2 |
| Departure Time | 12:49:05 (07/08/2020) | 14:47:22 (07/08/2020) |
| Destination | Depot 1 | Depot 2 |
| Arrival Time | 14:02:43 | 15:36:25 |
| Total Stops | 9 | 3 |
| Pickups | 7 | 1 |
| Deliveries | 2 | 2 |
Route Insights
-
Route 1 (Part 0) completes 9 stops, combining 7 pickups and 2 deliveries, over 28.62 km.
- The route starts at Depot 1, heading to Order 6 for an early delivery, followed by a series of pickups at Order 12, Order 2, Order 10, Order 7 and Order 5, then a delivery at Order 9 and two more pickups at Order 3, Order 1, before returning to Depot 1.
- The cargo load progressively increases through pickups while being strategically offloaded at delivery points.
-
Route 2 (Part 1) is a compact loop of 3 stops.
- Starting from Depot 2, it picks up at Order 11 and proceeds with deliveries to Orders 4 and 8, before returning to base.
- Despite its brevity, this route handles a significant load, efficiently reducing both weight and volume.
Operational Highlights
-
Total Distance Covered: Combined, both routes span 47.05 km, efficiently distributing loads across a compact urban layout.
-
Load Management:
- Part 0 demonstrates tight capacity usage, peaking at over 44 kg and 32.6 cubic units of cargo.
- Part 1 emphasizes quick delivery turnover, unloading up to 15.4 kg and 5.8 cubic units in one stop.
-
Time Efficiency: Both parts are completed in under 1.5 hours each, contributing to tight route cycles within daily operational windows.
-
Cost Performance: At just €3.34 combined, this solution offers a cost-effective delivery model for low-mileage, high-density order clusters.
-
Time Window Adherence: All tasks respect defined service windows, maintaining punctuality across all customer engagements.
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.