Solution

The Solution entity represents the Vehicle Routing Problem solution which consists of three important parts: statistic, tours, and unassigned jobs.

statistic

the statistic object represents the statistic of one or multiple tours and consists of the following properties:

  • cost: total cost in abstract units rounded to three decimal places

    "cost": 54.459

  • costs: ALPHA breakdown of the total cost into individual components. Only fields that are configured on the vehicle and have a non-zero value are present.

    {
      "costs": {
        "distance": 19886.32,
        "fixed": 100.0,
        "time": 7204.53,
        "perJob": 2500.0,
        "perWaitingTime": 120.0
      }
    }
    FieldDescription
    distanceCost from distance traveled
    fixedFixed cost for using the vehicle
    timeCost from time (duration minus waiting, or full duration if perWaitingTime is not configured)
    perJobCost from per-job cost function
    perWaitingTimeCost from waiting time
    excessExcess costs from exceeding limits
    📘

    Note

    Due to floating-point arithmetic and internal rounding, the sum of individual costs components may not exactly equal the cost field. Small differences (typically less than 0.001) are expected and do not indicate an error.

  • distance: total driven distance in meters

    "distance": 35277

  • duration: total duration in seconds

    duration": 5286

  • consumption: estimated fuel consumption, with the unit type corresponding to the fuel type, for example, for CNG, the unit is kilograms while for petrol, the unit is liters

    consumption: 6.3893

  • co2Emission: the estimated CO₂ emission for the tour, in kilograms

    co2Emission: 17.232999999999997

  • intraStopDistance: in clustering, the total distance (in meters) between activities inside all the stops plus the way back to the stop locations. If all stop locations are equal to all activity locations (for example, a stop includes a single activity only), this value is 0.

    intraStopDistance: 1024

  • times: times spent for driving, serving jobs, waiting for time window start, stopping, break, and walking between activities within stops

    {
      "times": {
        "driving": 5106,
        "serving": 180,
        "waiting": 0,
        "stopping": 0,
        "break": 0,
        "intraStop": 0
      }
    }

The duration property in a solution's statistic represents the total sum of all tour durations for that specific solution.

List of tours

Each item of the tour list provides detailed information about the used vehicle and the assigned jobs.

  • typeId: specifies vehicle type id

    "typeId": "myVehicle"

  • vehicleId: specifies concrete id of the used vehicle. It consists of typeId and a sequential number separated by underscore

    vehicleId": "myVehicle_1"

  • stops: specifies the list of stops

  • statistic: specifies tour statistic

  • shiftIndex: specifies which vehicle shift index will be used during the tour.

stop

The stop specifies the list of activities performed at a specific time, at a specific place. It consists of the following properties:

  • location: stop location represented via latitude/longitude

    "location": {"lat": 52.52568, "lng": 13.45345}

  • time: specifies expected arrival and departure time at/from stop

    {
      "time": {
        "arrival": "2020-07-04T09:19:01Z",
        "departure": "2020-07-04T09:19:01Z"
      }
    }
  • load: specifies vehicle load after departure from the stop

    "load": [1]

  • distance: specifies total distance traveled from the tour start (in meters)

  • intraStopDistance: specifies the total distance (in meters) between activities in this stop plus the way back to the stop location. If the stop location is equal to all activity locations in the stop, this value equals 0.

  • activities: specifies list of activities to be performed at the stop

📘

Note

The times in the solution results will always be returned in UTC regardless of what time offset was used in the problem formulation.

activity

In general, activity specifies a planned task to be performed at a specific location and time. It consists of the following properties:

  • jobId: id of the job or marker (e.g. break, departure or arrival)

    jobId": "myJob"

  • type: specifies the activity type. It can be one of the following values: departure, arrival, break, pickup, delivery

    "type": "delivery"

  • jobTag (optional): a user defined value specified on the corresponding job place

    "jobTag": "place 1"

  • location (optional): the activity location represented via latitude/longitude or custom ID. Omitted when it is the same as the one defined at the parent stop

    "location": {"lat": 52.52568, "lng": 13.45345}
    or
    "location": {"id": "uniqueLocationId""}

  • time (optional) : specifies expected arrival, start, and end times for the activity. The arrival time indicates when the vehicle/person arrives at the activity location, while start and end indicate when the activity itself begins and finishes. Omitted if there is only one activity in the stop

    {
      "time": {
        "arrival": "2020-07-04T10:00:00Z",
        "start": "2020-07-04T10:00:00Z",
        "end": "2020-07-04T10:03:00Z"
      }
    }
    📘

    Note

    The times in the solution results are always returned in the UTC format regardless of what time offset was used in the problem formulation.

  • notices (optional): a list of notices attached to the activity. The optimization algorithm can produce notices for various reasons, for example, when it assigns a stop despite a route violation due to the ignoreRouteViolations configuration in the vehicle profile.

    Each notice contains:

    • code: the notice type. unreachableLocation indicates the stop carries a routing risk because a violation was ignored.

    • title: a human-readable description of the notice, including which violation category or scope was ignored.

    • action: a suggested remediation step.

      The following snippet shows a notices array example:

      {
        "notices": [
          {
            "code": "unreachableLocation",
            "title": "Due to ignored route violations (all), this location can be unreachable",
            "action": "Remove ignoreRouteViolations to be sure that location is reachable"
          }
        ]
      }

unassigned jobs

The optional unassigned job list is populated with jobs which cannot be assigned due to specific constraints. Each item consists of a job id and possible unassignment reasons:

{
  "unassigned": [
      {
        "jobId": "myJob",
        "reasons": [
          {
            "code": "MAX_DISTANCE_CONSTRAINT",
            "description": "cannot be assigned due to max distance constraint of vehicle"
          }
        ]
      }
  ]
}

Example

{
  "statistic": {
    "cost": 54.459916,
    "distance": 35277,
    "duration": 5286,
    "times": {
      "driving": 5106,
      "serving": 180,
      "waiting": 0,
      "stopping": 0,
      "break": 0,
      "intraStop": 0
    },
    "costs": {
      "distance": 35.277,
      "fixed": 10.0,
      "time": 9.182916
    },
    "intraStopDistance": 0
  },
  "tours": [
    {
      "vehicleId": "myVehicle_1",
      "typeId": "myVehicle",
      "stops": [
        {
          "location": {"lat": 52.52568, "lng": 13.45345},
          "time": {
            "arrival": "2020-07-04T09:19:01Z",
            "departure": "2020-07-04T09:19:01Z"
          },
          "load": [1],
          "activities": [
            {
              "jobId": "departure",
              "type": "departure",
              "time": {
                "arrival": "2020-07-04T09:19:01Z",
                "start": "2020-07-04T09:19:01Z",
                "end": "2020-07-04T09:19:01Z"
              }
            }
          ],
          "distance": 0,
          "intraStopDistance": 0
        },
        {
          "location": {"lat": 52.46642, "lng": 13.28124},
          "time": {
            "arrival": "2020-07-04T10:00:00Z",
            "departure": "2020-07-04T10:03:00Z"
          },
          "load": [0],
          "activities": [
            {
              "jobId": "myJob",
              "type": "delivery",
              "time": {
                "arrival": "2020-07-04T10:00:00Z",
                "start": "2020-07-04T10:00:00Z",
                "end": "2020-07-04T10:03:00Z"
              }
            }
          ],
          "distance": 16035,
          "intraStopDistance": 0
        },
        {
          "location": {"lat": 52.52568, "lng": 13.45345},
          "time": {
            "arrival": "2020-07-04T10:47:07Z",
            "departure": "2020-07-04T10:47:07Z"
          },
          "load": [0],
          "activities": [
            {
              "jobId": "arrival",
              "type": "arrival",
              "time": {
                "arrival": "2020-07-04T10:47:07Z",
                "start": "2020-07-04T10:47:07Z",
                "end": "2020-07-04T10:47:07Z"
              }
            }
          ],
          "distance": 31943,
          "intraStopDistance": 0
        }
      ],
      "statistic": {
        "cost": 54.459916,
        "distance": 35277,
        "duration": 5286,
        "times": {
          "driving": 5106,
          "serving": 180,
          "waiting": 0,
          "stopping": 0,
          "break": 0,
          "intraStop": 0
        },
        "costs": {
          "distance": 35.277,
          "fixed": 10.0,
          "time": 9.182916
        },
        "intraStopDistance": 0
      },
      "shiftIndex": 0
    }
  ]
}

Did this page help you?