Add Optimization with Orders Sequence Pairs
This example demonstrates how to create and optimize a fleet management solution using the Fleet Management Rest API with order sequence pairs. The example covers the following features:
- Adding an optimization with sequence pairs (pick-up and delivery order pairs).
- Defining orders with various fields (e.g., packages, weights, cubes).
- Setting up vehicles with specific constraints.
- 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": 0.1,
"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": 0.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": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 0.5,
"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": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 5.8,
"revenue": 0.8,
"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": 0.4,
"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": 1.7,
"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": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 2.6,
"revenue": 1.2,
"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": 0.6,
"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": 1.5,
"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": 0.5,
"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": 0.1,
"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": 1.5,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
- Response Body: (error code
200)
[
{
"id": 879877,
"creationTimestamp": 1763486363152,
"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": 0.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879878,
"creationTimestamp": 1763486363152,
"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": 0.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879879,
"creationTimestamp": 1763486363152,
"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": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 0.5,
"timeWindow": [
770,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879880,
"creationTimestamp": 1763486363152,
"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": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 5.8,
"revenue": 0.8,
"timeWindow": [
753,
1036
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879881,
"creationTimestamp": 1763486363152,
"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": 0.4,
"timeWindow": [
736,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879882,
"creationTimestamp": 1763486363152,
"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": 1.7,
"timeWindow": [
786,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879883,
"creationTimestamp": 1763486363152,
"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": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 2.6,
"revenue": 1.2,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879884,
"creationTimestamp": 1763486363152,
"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": 0.6,
"timeWindow": [
753,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879885,
"creationTimestamp": 1763486363152,
"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": 1.5,
"timeWindow": [
770,
1070
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879886,
"creationTimestamp": 1763486363152,
"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": 0.5,
"timeWindow": [
836,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879887,
"creationTimestamp": 1763486363152,
"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": 0.1,
"timeWindow": [
903,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879888,
"creationTimestamp": 1763486363152,
"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": 1.5,
"timeWindow": [
870,
1020
],
"serviceTime": 0,
"depotId": 0
}
]
Step 3: Configure Optimization Parameters
Configuration Parameters define key settings that influence the behavior of the route optimization process. These settings determine aspects such as optimization goals, search time limits, and flexibility in handling orders.
- Create Configuration: Define a
ConfigurationParametersobject and set the desired parameters. In this example, we define sequence pairs where the first order is a pick-up and the second is a delivery.
Orders from the same OrderPair will be visited by the same vehicle. The first order will be visited before the second one . The number of pieces, weight, and cube picked up from the first order will be delivered at the second order, so the second order should have the number of pieces, weight, and cube >= than the ones from the first 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": 3,
"ordersSequence": [
[
879879,
879880
],
[
879881,
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": [
879877,
879878,
879879,
879880,
879881,
879882,
879883,
879884,
879885,
879886,
879887,
879888
],
"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": 3,
"ordersSequence": [
[
879879,
879880
],
[
879881,
879882
]
]
}
]
},
"matrixBuildType": 1
}
- Response Body: (error code
200)
{
"id": 138243,
"orders": [
{
"id": 879877,
"creationTimestamp": 1763486363152,
"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": 0.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879878,
"creationTimestamp": 1763486363152,
"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": 0.1,
"timeWindow": [
420,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879879,
"creationTimestamp": 1763486363152,
"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": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 3,
"weight": 5.1,
"cube": 2.5,
"revenue": 0.5,
"timeWindow": [
770,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879880,
"creationTimestamp": 1763486363152,
"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": 0,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 5,
"weight": 7.5,
"cube": 5.8,
"revenue": 0.8,
"timeWindow": [
753,
1036
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879881,
"creationTimestamp": 1763486363152,
"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": 0.4,
"timeWindow": [
736,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879882,
"creationTimestamp": 1763486363152,
"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": 1.7,
"timeWindow": [
786,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879883,
"creationTimestamp": 1763486363152,
"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": 1,
"status": 0,
"state": 1,
"priority": 0,
"numberOfPackages": 8,
"weight": 15.4,
"cube": 2.6,
"revenue": 1.2,
"timeWindow": [
820,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879884,
"creationTimestamp": 1763486363152,
"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": 0.6,
"timeWindow": [
753,
1086
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879885,
"creationTimestamp": 1763486363152,
"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": 1.5,
"timeWindow": [
770,
1070
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879886,
"creationTimestamp": 1763486363152,
"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": 0.5,
"timeWindow": [
836,
1053
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879887,
"creationTimestamp": 1763486363152,
"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": 0.1,
"timeWindow": [
903,
1020
],
"serviceTime": 0,
"depotId": 0
},
{
"id": 879888,
"creationTimestamp": 1763486363152,
"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": 1.5,
"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": 3,
"ordersSequence": [
[
879879,
879880
],
[
879881,
879882
]
]
}
]
},
"creationTimestamp": 1763486363152,
"matrixBuildType": 1,
"request": {
"id": 26553,
"optimizationId": 138243,
"status": 1,
"message": "Operation done successfully!",
"creationTimestamp": 1763486363152
}
}
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": 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": 161813,
"name": "Car vehicle 1",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161813,
"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": 1596805627000,
"traveledDistance": 9.48253631591796875
},
"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": 0,
"weight": 0.0,
"cube": 0.0,
"departureTime": 1596804016128,
"timeToNext": 245,
"distanceToNext": 1.4171849489212036133
},
"shape": "a`hiHwfkM`GxCBVVPPHs@~Ec[sNgCkA_Ai@pEyDxAn@dX~MBVVPPHuArJe@zD}BzPeArIeDd^sArOMb@C`@fLhENeB[{E{@wKK@mFkAiCYqCRa@HIWaD}HS[?uA_Mq@_Mct@mEzDoCzBuBlBaMrKy@p@UVUJo@FgVU_ABkACsSCUDWJqJxHyMdKaFbEmA|@JtAJ?zF~ChANAaCHb[{BdCi@f@Qj@QH{AiW}BmAGwKSgFK}@Es@IqEYg^c@BD`GD|@FrEHvEF~GLxFAt@LzD",
"creationTimestamp": 1753174229510,
"neededFuel": 0.61636483669281005859,
"matrixBuildType": 1,
"price": 0.67183768749237060547,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148946,
"orders": [
{
"orderInfo": {
"revenue": 13.0,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1753174212101,
"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": 1194152,
"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": 1998571,
"location": [
48.870851999999999293,
2.3561480000000001311
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.87077843750000028,
2.3565665624999998506
],
"indexInRoute": 0,
"indexInOptimization": 0,
"arrivalTime": 1596804261000,
"timeToNextOrder": 318,
"waitTime": 0,
"numberOfPackagesAtArrival": 0,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 0.0,
"collectedWeight": 3.2000000476837158203,
"deliveredWeight": 0.0,
"cubeAtArrival": 0.0,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 1.4171849489212036133,
"distanceToNextOrder": 1.8787109851837158203,
"revenueAtArrival": 0.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 6.1999998092651367188,
"serviceTime": 0,
"timeWindow": [
903,
1020
],
"creationTimestamp": 1753174212572,
"cube": 0.10000000149011611938,
"numberOfPackages": 10,
"depotId": 0,
"customData": "",
"weight": 8.0,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c10",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194162,
"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": 1998581,
"location": [
48.870449000000000694,
2.3422040000000001747
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.870181875000000105,
2.3423449999999998994
],
"indexInRoute": 1,
"indexInOptimization": 10,
"arrivalTime": 1596804579000,
"timeToNextOrder": 709,
"waitTime": 0,
"numberOfPackagesAtArrival": 1,
"collectedNumberOfPackages": 10,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 3.2000000476837158203,
"collectedWeight": 8.0,
"deliveredWeight": 0.0,
"cubeAtArrival": 0.10000000149011611938,
"collectedCube": 0.10000000149011611938,
"deliveredCube": 0.0,
"traveledDistance": 3.2958960533142089844,
"distanceToNextOrder": 4.0496191978454589844,
"revenueAtArrival": 13.0,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.2999999523162841797,
"serviceTime": 0,
"timeWindow": [
870,
1020
],
"creationTimestamp": 1753174212603,
"cube": 1.5,
"numberOfPackages": 6,
"depotId": 0,
"customData": "",
"weight": 4.8000001907348632812,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c11",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194163,
"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": 1998582,
"location": [
48.895657999999997401,
2.3440430000000000987
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.895803437499999688,
2.3440406249999998778
],
"indexInRoute": 2,
"indexInOptimization": 11,
"arrivalTime": 1596805288000,
"timeToNextOrder": 339,
"waitTime": 0,
"numberOfPackagesAtArrival": 11,
"collectedNumberOfPackages": 6,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 11.199999809265136719,
"collectedWeight": 4.8000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 0.20000000298023223877,
"collectedCube": 1.5,
"deliveredCube": 0.0,
"traveledDistance": 7.3455152511596679688,
"distanceToNextOrder": 2.1370210647583007812,
"revenueAtArrival": 19.200000762939453125,
"visitTimestamp": 0
}
],
"totalTime": 1611,
"totalDistance": 9.48253631591796875,
"id": 273355
},
{
"configurationParameters": {
"orderSequenceOptions": [
{
"sequenceOptions": 3,
"ordersSequence": [
[
1194153,
1194159
],
[
1194155,
1194158
]
]
}
],
"distanceUnit": 0,
"maxTimeToOptimize": 300,
"optimizationQuality": 2,
"routeType": 2,
"arrangeCriterion": 0,
"restrictions": 0,
"maxWaitTime": 8000,
"balancedRoutes": 0,
"groupingOrders": false,
"optimizationCriterion": 0,
"allowDroppingOrders": false,
"ignoreTimeWindow": false,
"name": "Paris - test optimization - Part 1"
},
"vehicleConstraints": {
"startDate": 1596758400000,
"maxNumberOfPackages": 99999999,
"minNumberOfOrders": 0,
"maxNumberOfOrders": 9,
"minDistance": 0.0,
"maxDistance": 100000000.0,
"maxRevenue": 100000000.0,
"fuelPrice": 1.0900000333786010742
},
"rideStatus": 1,
"vehicle": {
"length": 0.0,
"weight": 0.0,
"width": 0.0,
"licensePlate": "AA-124-AA",
"consumption": 6.5,
"fuelType": 0,
"make": "Renault",
"id": 161814,
"name": "Car vehicle 2",
"model": "Master",
"costPerHour": 0.0,
"type": 0,
"status": 0,
"maxLoadWeight": 60.0,
"height": 0.0,
"maxLoadCube": 50.0,
"idDriver": 161814,
"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": 1596800246000,
"traveledDistance": 38.866825103759765625
},
"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": 31,
"weight": 42.200000762939453125,
"cube": 4.5999999046325683594,
"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{@w",
"creationTimestamp": 1753174229801,
"neededFuel": 2.5263435840606689453,
"matrixBuildType": 1,
"price": 2.7537145614624023438,
"totalWaitTime": 0,
"totalServiceTime": 0,
"optimizationId": 148946,
"orders": [
{
"orderInfo": {
"revenue": 14.100000381469726562,
"serviceTime": 0,
"timeWindow": [
420,
1086
],
"creationTimestamp": 1753174212224,
"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": 1194153,
"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": 1998572,
"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": 31,
"collectedNumberOfPackages": 1,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 42.200000762939453125,
"collectedWeight": 4.5999999046325683594,
"deliveredWeight": 0.0,
"cubeAtArrival": 4.5999999046325683594,
"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": 1753174212481,
"cube": 0.60000002384185791016,
"numberOfPackages": 11,
"depotId": 0,
"customData": "",
"weight": 12.100000381469726562,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c7",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194159,
"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": 1998578,
"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": 32,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 11,
"weightAtArrival": 46.799999237060546875,
"collectedWeight": 0.0,
"deliveredWeight": 12.100000381469726562,
"cubeAtArrival": 4.6999998092651367188,
"collectedCube": 0.0,
"deliveredCube": 0.60000002384185791016,
"traveledDistance": 3.4701020717620849609,
"distanceToNextOrder": 5.4595351219177246094,
"revenueAtArrival": 14.100000381469726562,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.7000000476837158203,
"serviceTime": 0,
"timeWindow": [
753,
1036
],
"creationTimestamp": 1753174212295,
"cube": 0.80000001192092895508,
"numberOfPackages": 5,
"depotId": 0,
"customData": "",
"weight": 7.5,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c3",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194155,
"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": 1998574,
"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": 1199,
"waitTime": 0,
"numberOfPackagesAtArrival": 21,
"collectedNumberOfPackages": 5,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 34.6999969482421875,
"collectedWeight": 7.5,
"deliveredWeight": 0.0,
"cubeAtArrival": 4.0999999046325683594,
"collectedCube": 0.80000001192092895508,
"deliveredCube": 0.0,
"traveledDistance": 8.9296369552612304688,
"distanceToNextOrder": 8.0230865478515625,
"revenueAtArrival": 28.799999237060546875,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 13.399999618530273438,
"serviceTime": 0,
"timeWindow": [
820,
1020
],
"creationTimestamp": 1753174212445,
"cube": 1.2000000476837158203,
"numberOfPackages": 8,
"depotId": 0,
"customData": "",
"weight": 15.399999618530273438,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c6",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194158,
"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": 1998577,
"location": [
48.860914000000001067,
2.3106249999999999289
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.861119999999999663,
2.310630624999999938
],
"indexInRoute": 3,
"indexInOptimization": 6,
"arrivalTime": 1596797334000,
"timeToNextOrder": 494,
"waitTime": 0,
"numberOfPackagesAtArrival": 26,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 8,
"weightAtArrival": 42.1999969482421875,
"collectedWeight": 0.0,
"deliveredWeight": 15.399999618530273438,
"cubeAtArrival": 4.9000000953674316406,
"collectedCube": 0.0,
"deliveredCube": 1.2000000476837158203,
"traveledDistance": 16.952724456787109375,
"distanceToNextOrder": 3.1172869205474853516,
"revenueAtArrival": 31.5,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 12.0,
"serviceTime": 0,
"timeWindow": [
770,
1020
],
"creationTimestamp": 1753174212261,
"cube": 0.5,
"numberOfPackages": 3,
"depotId": 0,
"customData": "",
"weight": 5.0999999046325683594,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c2",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194154,
"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": 1998573,
"location": [
48.880249999999996646,
2.2996010000000000062
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.880213437499996587,
2.2997093749999999446
],
"indexInRoute": 4,
"indexInOptimization": 2,
"arrivalTime": 1596797828000,
"timeToNextOrder": 369,
"waitTime": 0,
"numberOfPackagesAtArrival": 18,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 3,
"weightAtArrival": 26.799997329711914062,
"collectedWeight": 0.0,
"deliveredWeight": 5.0999999046325683594,
"cubeAtArrival": 3.7000000476837158203,
"collectedCube": 0.0,
"deliveredCube": 0.5,
"traveledDistance": 20.070011138916015625,
"distanceToNextOrder": 1.8877489566802978516,
"revenueAtArrival": 44.90000152587890625,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 2.9000000953674316406,
"serviceTime": 0,
"timeWindow": [
770,
1070
],
"creationTimestamp": 1753174212512,
"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": 1194160,
"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": 1998579,
"location": [
48.887095999999999663,
2.283513000000000126
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.886898125000001869,
2.2838078125000000895
],
"indexInRoute": 5,
"indexInOptimization": 8,
"arrivalTime": 1596798197000,
"timeToNextOrder": 330,
"waitTime": 0,
"numberOfPackagesAtArrival": 15,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 6,
"weightAtArrival": 21.6999969482421875,
"collectedWeight": 0.0,
"deliveredWeight": 5.1999998092651367188,
"cubeAtArrival": 3.2000000476837158203,
"collectedCube": 0.0,
"deliveredCube": 1.5,
"traveledDistance": 21.957759857177734375,
"distanceToNextOrder": 1.896412968635559082,
"revenueAtArrival": 56.90000152587890625,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 7.5,
"serviceTime": 0,
"timeWindow": [
736,
1086
],
"creationTimestamp": 1753174212338,
"cube": 0.40000000596046447754,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.200000762939453125,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c4",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194156,
"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": 1998575,
"location": [
48.897162999999999045,
2.2928649999999999309
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897063750000000937,
2.2924699999999997857
],
"indexInRoute": 6,
"indexInOptimization": 4,
"arrivalTime": 1596798527000,
"timeToNextOrder": 428,
"waitTime": 0,
"numberOfPackagesAtArrival": 9,
"collectedNumberOfPackages": 9,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 16.499996185302734375,
"collectedWeight": 16.200000762939453125,
"deliveredWeight": 0.0,
"cubeAtArrival": 1.7000000476837158203,
"collectedCube": 0.40000000596046447754,
"deliveredCube": 0.0,
"traveledDistance": 23.854173660278320312,
"distanceToNextOrder": 2.9556970596313476562,
"revenueAtArrival": 59.8000030517578125,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 8.1000003814697265625,
"serviceTime": 0,
"timeWindow": [
836,
1053
],
"creationTimestamp": 1753174212542,
"cube": 0.5,
"numberOfPackages": 13,
"depotId": 0,
"customData": "",
"weight": 6.3000001907348632812,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c9",
"state": 1,
"type": 0,
"priority": 0,
"id": 1194161,
"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": 1998580,
"location": [
48.896894000000003189,
2.3215859999999999275
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.897175937500001908,
2.3212631250000002048
],
"indexInRoute": 7,
"indexInOptimization": 9,
"arrivalTime": 1596798955000,
"timeToNextOrder": 679,
"waitTime": 0,
"numberOfPackagesAtArrival": 18,
"collectedNumberOfPackages": 13,
"deliveredNumberOfPackages": 0,
"weightAtArrival": 32.6999969482421875,
"collectedWeight": 6.3000001907348632812,
"deliveredWeight": 0.0,
"cubeAtArrival": 2.1000001430511474609,
"collectedCube": 0.5,
"deliveredCube": 0.0,
"traveledDistance": 26.809871673583984375,
"distanceToNextOrder": 6.4609599113464355469,
"revenueAtArrival": 67.3000030517578125,
"visitTimestamp": 0
},
{
"orderInfo": {
"revenue": 10.0,
"serviceTime": 0,
"timeWindow": [
786,
1053
],
"creationTimestamp": 1753174212401,
"cube": 1.7000000476837158203,
"numberOfPackages": 9,
"depotId": 0,
"customData": "",
"weight": 16.5,
"phoneNumber": "+12312312",
"lastName": "",
"status": 1,
"firstName": "",
"alias": "c5",
"state": 1,
"type": 1,
"priority": 0,
"id": 1194157,
"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": 1998576,
"location": [
48.900919999999999277,
2.4000390000000000335
],
"address": {
"streetNumber": "",
"postalCode": "",
"streetName": "",
"county": "",
"state": "",
"extra": "",
"city": "",
"country": ""
}
}
},
"matchedLocation": [
48.900595937500000332,
2.4000474999999998893
],
"indexInRoute": 8,
"indexInOptimization": 5,
"arrivalTime": 1596799634000,
"timeToNextOrder": 612,
"waitTime": 0,
"numberOfPackagesAtArrival": 31,
"collectedNumberOfPackages": 0,
"deliveredNumberOfPackages": 9,
"weightAtArrival": 38.999996185302734375,
"collectedWeight": 0.0,
"deliveredWeight": 16.5,
"cubeAtArrival": 2.6000001430511474609,
"collectedCube": 0.0,
"deliveredCube": 1.7000000476837158203,
"traveledDistance": 33.270832061767578125,
"distanceToNextOrder": 5.5959939956665039062,
"revenueAtArrival": 75.40000152587890625,
"visitTimestamp": 0
}
],
"totalTime": 5174,
"totalDistance": 38.866825103759765625,
"id": 273356
}
]
}
Analyzing the Solution

Paris Route Optimization Test
Summary Table
| Metric | Part 0 | Part 1 |
|---|---|---|
| Total Distance | 9.48 km | 38.87 km |
| Total Time | 26 min 50 sec | 1 hr 26 min 14 sec |
| Cost | €0.67 | €2.75 |
| Departure Point | Depot 1 | Depot 2 |
| Departure Time | 12:40:16 (07/08/2020) | 10:11:11 (07/08/2020) |
| Destination | Destination 1 | Destination 2 |
| Arrival Time | 13:07:07 | 11:37:26 |
| Total Stops | 3 | 9 |
| Pickups | 3 | 4 |
| Deliveries | 0 | 5 |
Route Insights
-
Route 1 (Part 0) consists of 3 back-to-back pickups in close proximity, resulting in a compact loop of just 9.48 km. The journey starts at Depot 1, collects small quantities at Order 1, Order 11, and Order 12, and ends smoothly at Destination 1. With no deliveries and minimal load handling, this route is lean and optimized for short-range efficiency.
-
Route 2 (Part 1) is more involved, executing 9 stops including both pickups and deliveries across central and outer Paris. Beginning from Depot 2, the route features initial pickups at Order 2 and Order 8, and strategically schedules deliveries at Order 4, Order 7, Order 3, Order 9. Following these, two pickups are made at Order 5 and Order 10, then the last delivery at Order 6. It concludes at Destination 2 after visiting all orders, ensuring efficient load transfers throughout.
Operational Highlights
- Combined Distance: The two routes span a total of 48.35 km, with optimized clustering to reduce travel where possible.
- Time Management: Routes demonstrate high efficiency in timing with precise service intervals and minimal idle/wait times.
- Load Distribution: The second route manages heavy load activity (multiple deliveries and pickups), while the first route focuses on light, high-frequency collection.
- Cost Effectiveness: At under €3.50 combined, the routes reflect excellent cost-efficiency, given their geographical coverage and service demand.
Conclusion
This example demonstrates how to create a fully customized optimization with sequence pairs, define orders and vehicles, 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.