Routing with Attributes
Attributes are constraints that are either required to be present on a route or its driver or vehicle or depot, or must not be present (that is, they are "disallowed") on a route or its driver or vehicle, in order to insert a job into that route. Attributes are assigned by specifying the following fields:
- Route attributes: route.route_attributes, specified as either required or disallowed on jobs with job.required_route_attributes and job.disallowed_route_attributes.
- Driver attributes: driver.attributes, specified as required on vehicles with vehicle.required_driver_attributes, or as either required or disallowed on jobs with job.required_driver_attributes and job.disallowed_driver_attributes.
- Vehicle attributes: vehicle.attributes, specified as required on jobs with job.required_vehicle_attributes.
- Depot attributes: marker.attributes, on a marker with marker.is_depot set, specified as required either before or after a job with job.required_pre_job_depot_attributes and job.required_post_job_depot_attributes.
Attributes are typically special skills or properties associated with a route entity such as a driver, vehicle, or depot.
Note
To run the examples in this tutorial, you will need:
- A RouteCloud API login. Use your Verizon Connect Enterprise username and password to authenticate with the RouteCloud API. To obtain a username and password, contact Verizon Connect sales.
- cURL to run the requests. You can download a cURL binary from here.
Request
{
"routes": [
{ "id": "route0", "location": "39.718005, -104.969531" },
{ "id": "route1", "location": "39.718005, -104.969531", "route_attributes": [ "hazmat" ] }
],
"jobs": [
{ "id": "job0", "time_on_site": "00:10", "location": "39.635928, -105.049219" },
{ "id": "job1", "time_on_site": "00:10", "location": "39.638635, -105.128906", "required_route_attributes": [ "hazmat" ] },
{ "id": "job2", "time_on_site": "00:10", "location": "39.597111, -105.041015", "disallowed_route_attributes": [ "hazmat" ] },
{ "id": "job3", "time_on_site": "00:10", "location": "39.727919, -105.103126", "required_route_attributes": [ "heavy_truck" ] },
{ "id": "job4", "time_on_site": "00:10", "location": "39.727919, -105.103126", "required_route_attributes": [ "hazmat", "heavy_truck" ] }
]
}
routing_with_attributes_build.json
build request - download it here. Click here to open it in the UI.
routing_with_attributes_build.json
specifies two routes, and five jobs.
route0
provides no attributes, so can only service stops that do not require any route attributes.
route1
provides the hazmat
attribute, so can service stops that require the hazmat
attribute.
job0
does not require any attributes, so can be placed on either route0
or route1
.
job1
requires the hazmat
attribute, so can only be placed on route1
.
job2
disallows the hazmat
attribute, so cannot be placed on route1
, leaving route0
as the only possible route for job2
.
job3
requires the heavy_truck
attribute. As neither route0
nor route1
provides the heavy_truck
attribute, job3
will not be routed.
job4
requires both hazmat
and heavy_truck
attributes. route1
provides hazmat
, but does not satisfy the heavy_truck
requirement. As neither route0
nor route1
satisfies all of job4's
attributes, it will not be routed.
Response
{
"routes": [
{
"id": "route0", ...
"stops": [ { "type": "depot", ... }, { "id": "job2", ... }, { "type": "depot", ... } ]
}, {
"id": "route1", ...
"stops": [ { "type": "depot", ... }, { "id": "job1", }, { "id": "job0", }, { "type": "depot", } ]
}
],
"unrouted_jobs": [ { "id": "job3" }, { "id": "job4" } ]
}
A snipped version of the build response - download a copy here. Click here to open it in the UI.
Violations
If a job is placed on a route with an attribute mismatch, one of the following violations is generated:
- missing_route_attributes if the route is missing one of the job's required_route_attributes.
- disallowed_route_attributes if the route contains one of the job's disallowed_route_attributes.
- missing_driver_attributes if the route's driver is missing one of the job's required_driver_attributes.
- disallowed_driver_attributes if the route's driver contains one of the job's disallowed_driver_attributes.
- missing_vehicle_attributes if the route's vehicle is missing one of the job's required_vehicle_attributes.
- missing_depot_earlier_attributes if the route is missing depot that has job's required_pre_job_depot_attributes.
- missing_depot_later_attributes if the route is missing depot that has job's required_post_job_depot_attributes.
{
"type": "job",
"id": "job0",
"arrival_datetime": "2016-01-18T00:26:58",
"time_on_site": "00:00:00",
"distance_to_meters": 19440.0,
"time_to": "00:26:58",
"violations": [
{
"type": "missing_route_attributes",
"data": {
"attributes": ["hazmat"]
}
}
]
}
Note
build requests should never produce an attribute mismatch violation, but sequence, recommend, and evaluate requests may.
See Also
- The route.route_attributes field.
- The job.required_route_attributes field.
- The job.disallowed_route_attributes field.
- The driver.attributes field.
- The vehicle.required_driver_attributes field.
- The job.required_driver_attributes field.
- The job.disallowed_driver_attributes field.
- The vehicle.attributes field.
- The job.required_vehicle_attributes field.
- The marker.attributes field.
- The job.required_pre_job_depot_attributes field.
- The job.required_post_job_depot_attributes field.