Add Optimization with Fixed Orders Sequence
This example demonstrates how to create an optimization using the Fleet Management Rest API where specific orders must be visited in a fixed sequence by the same vehicle. The example covers the following features:
- Adding an optimization with fixed orders sequences (orders in a sequence will be visited in the specified order).
- Displaying the optimized solution on a map.
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.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
- 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.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": 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.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": 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.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": 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.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": 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.344043
],
"customData": ""
},
"location": [
48.895658,
2.344043
],
"alias": "Customer 12",
"firstName": "Customer12",
"lastName": "Customer12",
"address": {
"country": "",
"state": "",
"county": "",
"city": "",
"postalCode": "",
"streetName": "",
"streetNumber": ""
},
"phoneNumber": "+120255501811",
"customData": "",
"type": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 6,
"weight": 4.8,
"cube": 11.5,
"revenue": 2.3,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
Step 2: Configure Optimization Parameters
Configuration Parameters define the behavior of the optimization process. These settings include optimization goals, search time limits, and flexibility in handling orders. Proper configuration ensures the optimization aligns with your business needs.
- Create Configuration: Define a
ConfigurationParametersobject and set fixed sequence of orders that must be visited in a specific order.
{
"name": "Paris - test optimization",
"ignoreTimeWindow": false,
"allowDroppingOrders": false,
"groupingOrders": false,
"balancedRoutes": 0,
"optimizationCriterion": 0,
"arrangeCriterion": 0,
"optimizationQuality": 2,
"maxTimeToOptimize": 300,
"maxWaitTime": 8000,
"routeType": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": [
{
"sequenceOptions": 2,
"ordersSequence": [
[
879887,
879881
],
[
879885,
879882
]
]
}
]
}
Step 3: Create the Vehicle and Define Vehicle Constraints
Vehicles are the resources that will be used to fulfill the orders. Each vehicle can have specific constraints and capabilities.
Adding Vehicles
- Initialize Vehicles: Create two
Vehicleobjects and populate their fields (e.g., type, capacity, availability). - Send Request: Call the
Add Vehiclesendpoint to save these vehicles in the database.
- Method:
POST - Endpoint:
/vehicles - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/vehicles
If the operation is successful, the Vehicle object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
[
{
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
]
- Response Body: (error code
200)
[
{
"id": 135932,
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"id": 135933,
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
]
Define Vehicle Constraints
Vehicle constraints define the limitations and requirements applied to a vehicle during the route optimization process. Ensure that the vehicle operates within its capabilities, such as time windows, capacity, distance, and revenue.
- Create Constraints: Define a
VehicleConstraintsobject that applies to both vehicles. Add this object to a list.
[
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0,
"maxDistance": 99999999,
"maxRevenue": 85
}
]
Step 4: Create Departure and Destinations
- Departures: Define the starting points for vehicle routes. These locations impact optimization by influencing travel distance and time.
- Destinations: Define the final stops for vehicle routes. These locations ensure routes are optimized for efficiency.
Adding Departures and Destinations
- Initialize Departures: Create two
Departureobjects, one for each vehicle.
[
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
]
- Initialize Destinations: Since the route custom end, we have to create two
Destinationobjects, one for each vehicle.
[
{
"alias": "Destination 1",
"location": [
48.898165,
2.34484
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"alias": "Destination 2",
"location": [
48.872064,
2.402497
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
]
Step 5: Create the Optimization
An optimization represents a routing problem defined by orders, vehicles, constraints, and configuration parameters. This step combines all the elements to generate an optimized solution.
- Create Optimization: Define an
Optimizationobject and assign theOrderList,ConfigurationParameters,VehicleList,VehicleConstraintsList, andDepartures. - Send Request: Call the
Add Optimizationendpoint to create the optimization.
- Method:
POST - Endpoint:
/optimizations - Headers:
Authorization: YOUR_API_KEYContent-Type: application/json
- URL:
https://fleetmanagement.magiclaneapis.com/v1/optimizations - Query Parameter:
encodeShape(integer, optional)0: The route's shape will not be encoded.1(default): The route's shape will be encoded.
Adding an optimization returns a request object, which allows you to track the status of the optimization process. Once the request status is finished, the solution can be retrieved using Get Optimization's Solution request. The solution consists of one or more routes. A route is the trip that a vehicle travels to visit the orders, so the number of routes returned is maximum the number of vehicles set in the optimization(see Routes).
If the operation is successful, the Optimization object will have its id field populated. If the operation fails, an error code is returned.
Example:
- Request Body:
{
"orders": [
879888,
879887,
879886,
879885,
879884,
879883,
879882,
879881,
879880,
879879,
879878,
879877
],
"departures": [
{
"depotId": 0,
"alias": "Depot 1",
"location": [
48.870569,
2.356448
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"destinations": [
{
"alias": "Destination 1",
"location": [
48.898165,
2.34484
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"alias": "Destination 2",
"location": [
48.872064,
2.402497
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"vehicles": [
135932,
135933
],
"vehiclesConstraints": [
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 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": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": [
{
"sequenceOptions": 2,
"ordersSequence": [
[
879887,
879881
],
[
879885,
879882
]
]
}
]
},
"matrixBuildType": 1
}
- Response Body: (error code
200)
{
"id": 138108,
"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.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": 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.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": 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.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"
}
},
{
"depotId": 0,
"alias": "Depot 2",
"location": [
48.82674,
2.342116
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"destinations": [
{
"alias": "Destination 1",
"location": [
48.898165,
2.34484
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75001",
"streetName": "Rue de Rivoli",
"streetNumber": "1"
}
},
{
"alias": "Destination 2",
"location": [
48.872064,
2.402497
],
"address": {
"country": "France",
"state": "Ile-de-France",
"county": "Paris",
"city": "Paris",
"postalCode": "75002",
"streetName": "Rue de Richelieu",
"streetNumber": "2"
}
}
],
"vehicles": [
{
"id": 135932,
"type": 0,
"status": 0,
"name": "Car vehicle 1",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.870569,
2.356448
],
"consumption": 6.5,
"plate": "AA-123-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
},
{
"id": 135933,
"type": 0,
"status": 0,
"name": "Car vehicle 2",
"manufacturer": "Renault",
"model": "Master",
"fuelType": 2,
"lastPosition": [
48.82674,
2.342116
],
"consumption": 6.5,
"plate": "AA-124-AA",
"maxLoadWeight": 60,
"maxLoadCube": 50,
"height": 0,
"width": 0,
"weight": 0,
"length": 0,
"axleLoad": 0,
"fixedCost": 0,
"costPerHour": 0,
"startTime": 420,
"endTime": 1439
}
],
"vehiclesConstraints": [
{
"fuelPrice": 1.09,
"startDate": 1596758400000,
"maxNumberOfPackages": 53,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 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": 2,
"restrictions": 0,
"distanceUnit": 0,
"orderSequenceOptions": [
{
"sequenceOptions": 2,
"ordersSequence": [
[
879887,
879881
],
[
879885,
879882
]
]
}
]
},
"creationTimestamp": 1763486363150,
"matrixBuildType": 1,
"request": {
"id": 26553,
"optimizationId": 138108,
"status": 1,
"message": "Operation done successfully!",
"creationTimestamp": 1763486363150
}
}
Step 6: Display the Solution
Once the optimization is complete, retrieve the solution (routes) to visualize the optimized routes and waypoints.
- Method:
GET - Endpoint:
/optimizations/{id}/solution - Headers:
Authorization: YOUR_API_KEY
- Path Parameter:
id(integer, required) - The unique optimization ID.
- Query Parameter:
encodeShape(integer, optional)0: The route's shape will not be encoded.1(default): The route's shape will be encoded.
Example:
- Response Body: (error code
200)
{
"totalRecords": 1,
"routes": [
{
"configurationParameters": {
"orderSequenceOptions": [
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 0"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 53,
"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": 161765,
"name": "Car vehicle 1",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161765,
"endTime": 1100,
"fixedCost": 0.0,
"startTime": 420,
"lastPosition": [
2147483647.0,
2147483647.0
]
},
"destination": {
"depotId": 0,
"alias": "Destination 1",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.89816499999999877,
2.3448400000000000354
],
"matchedLocation": [
48.898125624999998706,
2.3448431250000001391
],
"arrivalTime": 1596809744000,
"traveledDistance": 31.010105133056640625
},
"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@{@eAeCgDm@sAa@m@yGkHsBkB{@{@kFyF}@eASOeAe@OEwBqDp@sIyHgLm@f@uEkHhE_RhBcQXqA`BwDDTEUs@~Am@vAYpAoA~LvGxJzC|EfFoIJDJAJOBOAQdBmCdCuE`@QHpEPnFF|CAn@^vPBXHTYrE_@pNChM@rD?nAdG|GjAhAVNdCfDpA|Az@`DvJ~MnJ~MbLlOr@v@rBrCtFbH|NxRZi@tG|IfCdDrCzDvKnNvAdBxBpA`F|BhDhBNJT^CDBJHEbApBR|@N`@TT^RLDJ?bB`AfEjBdX~MBVVPPHuArJe@zD}BzPeArIeDd^sArOMb@C`@fLhENeB[{E{@wKK@mFkAsArOMb@Q|BRHXhAvClZdAnKZ|DfAxKz@dJSl@aCtK?NFJK^Kf@?PMj@KNKf@EZD\\TVvCpBFHLt@RBfAs@\\URg@lNhJVRZb@Zn@@F?h@Hb@JRJJ`BfA_@fB@b@vCnBT`@Jb@BdAGxBFrADxF_@bAHpMrW|AKzI?pFcHYaACqKTe@AeIT_LRG]IMMCSHiDcI_C}F_BwAoCmBeDiBOEgEz@yHPh@j_@aGxFMHgDnEW\\cCtGEGG?GDCN@LFF_DtHq@zAx@jGkHhKZRkGeE_R~QOYWUYEM@UFOLKPKTEVCj@Dj@DTP^ZTQzEu@rLS\\J^_ArMKvB{@~Kw@dN_AaBqCpDMKKDGRBTFHF@HClC|GDPEPCXaQjRoFaR}A|A{@iD{Nqd@f@a@w@yCo@h@gDaK{AcFyJ|GqB{MxMeLnAmApBsCpCaEh@c@f@k@xBeDrBoCzAiBbAwA]s@gBsCcBkDgA{A}HeOy@iBe@sAq@{DYqA}AgGt@uAfIqPNm@@]eHiW}ByIm@aBaCuIS_AMoACkCEkOCs@IwKAsD?kBEkFGeAGeI?sHMaMAiGrCmCl@c@{AiWnAr@xA{Hh@ZhANAaCHb[{BdCi@f@Qj@QH{AiW}BmAGwKSgFK}@Es@IqEYg^c@BD`GD|@FrEHvEF~GLxFAt@@p@JhC",
"creationTimestamp": 1752825809322,
"neededFuel": 2.0156569480895996094,
"matrixBuildType": 1,
"price": 2.1970660686492919922,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148930,
"orders": [
{
"orderInfo": {
"revenue": 10.0,
"serviceTime": 0,
"timeWindow": [
786,
1053
],
"creationTimestamp": 1752825805381,
"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": 1193857,
"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": 1998276,
"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": 1022,
"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.7627301216125488281,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.0,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1752825805233,
"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": 1193852,
"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": 1998271,
"location": [
48.870851999999999293,
2.3561480000000001311
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.87077843750000028,
2.3565665624999998506
],
"indexInRoute": 1,
"indexInOptimization": 0,
"arrivalTime": 1596806582000,
"timeToNextOrder": 318,
"waitTime": 0,
"numberOfPackagesAtArrival": 6,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 5.200000762939453125,
"collectedWeight": 3.2000000476837158203,
"deliveredWeight": 0.0,
"cubeAtArrival": 1.5,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 11.712398529052734375,
"distanceToNextOrder": 1.8787109851837158203,
"revenueAtArrival": 10.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 6.1999998092651367188,
"serviceTime": 0,
"timeWindow": [
903,
1020
],
"creationTimestamp": 1752825805531,
"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": 1193862,
"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": 1998281,
"location": [
48.870449000000000694,
2.3422040000000001747
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.870181875000000105,
2.3423449999999998994
],
"indexInRoute": 2,
"indexInOptimization": 10,
"arrivalTime": 1596806900000,
"timeToNextOrder": 590,
"waitTime": 0,
"numberOfPackagesAtArrival": 7,
"collectedNumberOfPackages": 10,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 8.4000005722045898438,
"collectedWeight": 8.0,
"deliveredWeight": 0.0,
"cubeAtArrival": 1.6000000238418579102,
"collectedCube": 4.0999999046325683594,
"deliveredCube": 0.0,
"traveledDistance": 13.591109275817871094,
"distanceToNextOrder": 3.5287261009216308594,
"revenueAtArrival": 23.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.399999618530273438,
"serviceTime": 0,
"timeWindow": [
820,
1020
],
"creationTimestamp": 1752825805410,
"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": 1193858,
"location": [
48.860914000000001067,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c6@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c6",
"customData": "",
"id": 1998277,
"location": [
48.860914000000001067,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.861119999999999663,
2.310630624999999938
],
"indexInRoute": 3,
"indexInOptimization": 6,
"arrivalTime": 1596807490000,
"timeToNextOrder": 494,
"waitTime": 0,
"numberOfPackagesAtArrival": 17,
"collectedNumberOfPackages": 5,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 16.40000152587890625,
"collectedWeight": 7.5,
"deliveredWeight": 0.0,
"cubeAtArrival": 5.6999998092651367188,
"collectedCube": 2.5999999046325683594,
"deliveredCube": 0.0,
"traveledDistance": 17.11983489990234375,
"distanceToNextOrder": 3.1172869205474853516,
"revenueAtArrival": 29.200000762939453125,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 12.0,
"serviceTime": 0,
"timeWindow": [
770,
1020
],
"creationTimestamp": 1752825805291,
"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": 1193854,
"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": 1998273,
"location": [
48.880249999999996646,
2.2996010000000000062
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.880213437499996587,
2.2997093749999999446
],
"indexInRoute": 4,
"indexInOptimization": 2,
"arrivalTime": 1596807984000,
"timeToNextOrder": 369,
"waitTime": 0,
"numberOfPackagesAtArrival": 22,
"collectedNumberOfPackages": 3,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 23.90000152587890625,
"collectedWeight": 5.0999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 8.299999237060546875,
"collectedCube": 2.5,
"deliveredCube": 0.0,
"traveledDistance": 20.23712158203125,
"distanceToNextOrder": 1.8877489566802978516,
"revenueAtArrival": 42.59999847412109375,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.9000000953674316406,
"serviceTime": 0,
"timeWindow": [
770,
1070
],
"creationTimestamp": 1752825805471,
"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": 1193860,
"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": 1998279,
"location": [
48.887095999999999663,
2.283513000000000126
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.886898125000001869,
2.2838078125000000895
],
"indexInRoute": 5,
"indexInOptimization": 8,
"arrivalTime": 1596808353000,
"timeToNextOrder": 330,
"waitTime": 0,
"numberOfPackagesAtArrival": 25,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 6,
"weightAtArrival": 29.000001907348632812,
"collectedWeight": 0.0,
"deliveredWeight": 5.1999998092651367188,
"cubeAtArrival": 10.799999237060546875,
"collectedCube": 0.0,
"deliveredCube": 1.5,
"traveledDistance": 22.12487030029296875,
"distanceToNextOrder": 1.896412968635559082,
"revenueAtArrival": 54.59999847412109375,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 7.5,
"serviceTime": 0,
"timeWindow": [
736,
1086
],
"creationTimestamp": 1752825805352,
"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": 1193856,
"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": 1998275,
"location": [
48.897162999999999045,
2.2928649999999999309
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897063750000000937,
2.2924699999999997857
],
"indexInRoute": 6,
"indexInOptimization": 4,
"arrivalTime": 1596808683000,
"timeToNextOrder": 428,
"waitTime": 0,
"numberOfPackagesAtArrival": 19,
"collectedNumberOfPackages": 9,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 23.8000030517578125,
"collectedWeight": 16.200000762939453125,
"deliveredWeight": 0.0,
"cubeAtArrival": 9.299999237060546875,
"collectedCube": 8.3999996185302734375,
"deliveredCube": 0.0,
"traveledDistance": 24.021284103393554688,
"distanceToNextOrder": 2.9556970596313476562,
"revenueAtArrival": 57.5,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 8.1000003814697265625,
"serviceTime": 0,
"timeWindow": [
836,
1053
],
"creationTimestamp": 1752825805501,
"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": 1193861,
"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": 1998280,
"location": [
48.896894000000003189,
2.3215859999999999275
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897175937500001908,
2.3212631250000002048
],
"indexInRoute": 7,
"indexInOptimization": 9,
"arrivalTime": 1596809111000,
"timeToNextOrder": 294,
"waitTime": 0,
"numberOfPackagesAtArrival": 28,
"collectedNumberOfPackages": 13,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 40.000003814697265625,
"collectedWeight": 6.3000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 17.699998855590820312,
"collectedCube": 7.5,
"deliveredCube": 0.0,
"traveledDistance": 26.97698211669921875,
"distanceToNextOrder": 1.8961019515991210938,
"revenueAtArrival": 65.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.2999999523162841797,
"serviceTime": 0,
"timeWindow": [
870,
1020
],
"creationTimestamp": 1752825805561,
"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": 1193863,
"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": 1998282,
"location": [
48.895657999999997401,
2.3440430000000000987
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.895803437499999688,
2.3440406249999998778
],
"indexInRoute": 8,
"indexInOptimization": 11,
"arrivalTime": 1596809405000,
"timeToNextOrder": 339,
"waitTime": 0,
"numberOfPackagesAtArrival": 41,
"collectedNumberOfPackages": 6,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 46.3000030517578125,
"collectedWeight": 4.8000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 25.199998855590820312,
"collectedCube": 11.5,
"deliveredCube": 0.0,
"traveledDistance": 28.87308502197265625,
"distanceToNextOrder": 2.1370210647583007812,
"revenueAtArrival": 73.09999847412109375,
"visitTimestamp": 0
}
],
"totalTime": 5198,
"totalDistance": 31.010105133056640625,
"id": 273328
},
{
"configurationParameters": {
"orderSequenceOptions": [
{
"sequenceOptions": 2,
"ordersSequence": [
[
1193853,
1193859,
1193855
]
]
}
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 1"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 53,
"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": 161766,
"name": "Car vehicle 2",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161766,
"endTime": 1100,
"fixedCost": 0.0,
"startTime": 420,
"lastPosition": [
2147483647.0,
2147483647.0
]
},
"destination": {
"depotId": 0,
"alias": "Destination 2",
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"location": [
48.872064000000001727,
2.4024969999999998826
],
"matchedLocation": [
48.871986249999999075,
2.4021184374999999811
],
"arrivalTime": 1596796724000,
"traveledDistance": 12.74579620361328125
},
"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": 1596795071561,
"timeToNext": 12,
"distanceToNext": 0.070194996893405914307
},
"shape": "mn_iH_mhMCVuGuBQIy@s@SDOLIxFzAOlAIfHJJi@FmAtAgQBq@t@_J@g@[aQkAyi@ByLAkCC_AiHedA^w@M[@O`ByMoBmNmAiE{AyEdGwFlDkD`@WlAwCFc@HW~AqEdAeClAcCTo@mByAIMM]YeC[iASa@w@kAiA_DkFsTg@yCGo@SwBu@aMKaAcD{Uc@kCUaAs@yBe@gAmIwNsIsQ}@uB{@wCgEqOc@cAm@eAaAkAw@w@sA{@gAc@uLwCwJeBoBMwMe@}Da@gAe@uA_@uAW{EsAUc@SEU@QHILM\\Mf@Ct@Bf@F^FPNVD~@c@`KEb@Kb@D`BoAl[x@FPIGj@o@fOlIt@jC|BMPER?^BHDLFHNFPELMFYAc@EOGIGqAn@sPeNaBICQWyBS[FkD_@sOv@mFd@_PbD{@TiAb@wAr@iDzBs@j@oBzB_I|J_A~@uAdAcBv@m@ReAT{BV{AXuBn@mHbFEKIEI@MPYUuAoAeCmBgAcAuIcHkE|DcHxFA]{CcOGc@?k@iAn@",
"creationTimestamp": 1752825809426,
"neededFuel": 0.82847672700881958008,
"matrixBuildType": 1,
"price": 0.90303963422775268555,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148930,
"orders": [
{
"orderInfo": {
"revenue": 14.100000381469726562,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1752825805262,
"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": 1193853,
"location": [
48.827326999999996815,
2.3422670000000000989
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
},
"customerInfo": {
"phoneNumber": "+12312312",
"email": "c1@yahoo.com",
"lastName": "",
"firstName": "",
"alias": "c1",
"customData": "",
"id": 1998272,
"location": [
48.827326999999996815,
2.3422670000000000989
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.827346249999997951,
2.3421875000000000888
],
"indexInRoute": 0,
"indexInOptimization": 1,
"arrivalTime": 1596795084000,
"timeToNextOrder": 496,
"waitTime": 0,
"numberOfPackagesAtArrival": 19,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 27.5,
"collectedWeight": 4.5999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 10.399999618530273438,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 0.070194996893405914307,
"distanceToNextOrder": 3.3999071121215820312,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 14.699999809265136719,
"serviceTime": 0,
"timeWindow": [
753,
1086
],
"creationTimestamp": 1752825805441,
"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": 1193859,
"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": 1998278,
"location": [
48.827865000000002738,
2.3792159999999999975
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.827919999999998879,
2.3791415625000000844
],
"indexInRoute": 1,
"indexInOptimization": 7,
"arrivalTime": 1596795580000,
"timeToNextOrder": 555,
"waitTime": 0,
"numberOfPackagesAtArrival": 20,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 11,
"weightAtArrival": 32.09999847412109375,
"collectedWeight": 0.0,
"deliveredWeight": 12.100000381469726562,
"cubeAtArrival": 10.5,
"collectedCube": 0.0,
"deliveredCube": 4.5999999046325683594,
"traveledDistance": 3.4701020717620849609,
"distanceToNextOrder": 5.4595351219177246094,
"revenueAtArrival": 14.100000381469726562,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.7000000476837158203,
"serviceTime": 0,
"timeWindow": [
753,
1036
],
"creationTimestamp": 1752825805320,
"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": 1193855,
"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": 1998274,
"location": [
48.845198000000003447,
2.4028960000000001429
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.845262499999996919,
2.4027009375000001334
],
"indexInRoute": 2,
"indexInOptimization": 3,
"arrivalTime": 1596796135000,
"timeToNextOrder": 589,
"waitTime": 0,
"numberOfPackagesAtArrival": 9,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 8,
"weightAtArrival": 19.999998092651367188,
"collectedWeight": 0.0,
"deliveredWeight": 15.399999618530273438,
"cubeAtArrival": 5.9000000953674316406,
"collectedCube": 0.0,
"deliveredCube": 5.8000001907348632812,
"traveledDistance": 8.9296369552612304688,
"distanceToNextOrder": 3.8161590099334716797,
"revenueAtArrival": 28.799999237060546875,
"visitTimestamp": 0
}
],
"totalTime": 1652,
"totalDistance": 12.74579620361328125,
"id": 273329
}
]
}
Analyzing the Solution - Paris Route Optimization Test

Summary Table
| Metric | Part 0 | Part 1 |
|---|---|---|
| Total Distance | 31.01 km | 12.75 km |
| Total Time | 1 hr 26 min 44 sec | 27 min 33 sec |
| Cost | €2.20 | €0.90 |
| Departure Point | Depot 1 | Depot 2 |
| Departure Time | 12:49:05 (07/08/2020) | 10:11:11 (07/08/2020) |
| Destination | Destination 1 | Destination 2 |
| Arrival Time | 14:15:44 | 10:38:44 |
| Total Stops | 9 | 3 |
| Pickups | 7 | 1 |
| Deliveries | 2 | 2 |
Route Insights
Route 1 (Part 0) completed a mix of 9 tasks (pickups and deliveries) over a distance of 31.01 km, with a total estimated cost of €2.20. Starting from Depot 1, the vehicle begins with a delivery at Order 6 and continues with four pickups up at Order 1, Order 11, Order 7, and Order 2, next making one delivery at Order 9, and another three pickups at Order 5, Order 10 and Order 12 before concluding its compact and efficient loop at Destination 1.
Route 2 (Part 1) completed a mix of 3 tasks (pickups and deliveries) over a distance of 12.75 km, with a total estimated cost of €0.90. Starting from Depot 2, the vehicle begins with a pickup at Order 2 and continues with two deliveries up at Order 1, Order 11, before concluding its compact and efficient loop at Destination 2.
Operational Highlights
-
Load Management:
- Part 0: Cube utilization peaks at 25.2 m³ (likely near vehicle capacity)
- Part 1: 78% weight reduction (27.5 kg → 5.9 kg) in just 3 stops
-
Time Efficiency:
- Part 1 achieves 2.7 stops/hour vs Part 0's 6.2 stops/hour
- Zero wait times despite tight windows (e.g., c10's 903-1020 window)
-
Cost Performance:
- Combined cost/km: €0.07 (€3.10/43.76 km)
- Part 1 costs just €0.07/km (most efficient in dataset)
Conclusion
This example demonstrates how to create an optimization where specific orders must be visited in a fixed sequence by the same vehicle. By following the steps above, you can adapt this example to your specific use case and integrate it into your fleet management workflow.