The POST Time Window Routing operation allows user to optimize the stops sequence.
POST https://pcmiler.alk.com/apis/rest/v1.0/Service.svc/route/optimize?region={region}&dataset={dataset}
The operation takes a JSON format data in the POST body.
Element | Definition | Required |
---|---|---|
The POST Body Object contains Settings and Route System Object.
|
Y | |
region |
The data region in which the stops in the sequence are located. Valid values are NA, EU, OC and SA.
|
N |
dataset |
The regional dataset. Possible value: Current (default), PCM_EU, PCM_OC, PCM_SA, PCM_AF, PCM_AS, PCM_ME, PCM_GT, PCM_WW and PCM_NA.
|
N |
Element | Description | Data Type | Value/Example |
---|---|---|---|
Method |
Specifies if the process is to optimize the sequence or optimize an already optimized sequence based on the estimated time of arrival.
Optional and defaults to optimization of the sequence. |
Enum | 1 - Optimize 2 - ETA |
TimeFormat |
The format of the time in time windows specified per stop.
Optional and defaults to the 24-hour format. |
Enum | 1 - Hour24 2 - Minutes 3 - Hour12 |
MaxClusterCount |
The maximum number of clusters of stops allowed to be generated.
Optional and defaults to 40 clusters. |
Integer | |
MinClusterCount |
The minimum number of clusters of stops allowed to be generated.
Optional and defaults to 30 clusters. |
Integer | |
MaxAirTravelTimeForCluster |
The maximum air travel time in seconds that any two stops can be apart from each other and still be allowed to be clustered together.
It also determines the maximum air travel time in seconds that is allowed for traveling between all stops in a cluster. Optional and defaults to 180 seconds. |
Integer | |
MinAirTravelTimeForCluster |
The minimum air travel time in seconds that is allowed for traveling between all stops in a cluster.
Optional and defaults to 6 seconds. |
Integer | |
MaxAirTravelDistanceForCluster |
The maximum air travel distance that is allowed for traveling between all stops in a cluster.
Optional and defaults to 100 miles. |
Double | |
MaxAirTravelDistanceFromDepot |
The maximum air travel distance that is allowed for traveling between any stop and the start and end depots.
Optional and defaults to 200 miles. |
Double | |
MaxGridsForMatrixCalculation |
The maximum number of grid expansions allowed when building a time/distance matrix for sequences and clusters.
Optional and defaults to 60. |
Integer | |
GeocodingDistanceThreshold |
How far off a stop is allowed to be from the original or Geocoded latitude and longitude once snapped to a grid link.
Optional and defaults to 0.497097 miles (800 meters). |
Double | |
GeocodingDistanceThreshold |
How far off a stop is allowed to be from the original or Geocoded latitude and longitude once snapped to a grid link.
Optional and defaults to 0.497097 miles (800 meters). Use kilometers by setting time window sequence's Route.Options.DistanceUnits. |
Double | |
GeocodingConfidenceThreshold |
A confidence level as to how certain a Geocode search for stops are.
Optional and defaults to 2 (good confidence). |
Integer | 1 - Exact 2 - Good 3 - Uncertain 4 - Fail |
MaxWaitTime |
The maximum time in seconds a driver is allowed to wait at a stop.
Optional and defaults to 1800 seconds. |
Integer | |
MaxBreakWaitTime |
The maximum time in seconds a driver is allowed to wait at a break stop.
Optional and defaults to 7200 seconds. |
Integer | |
MaxServiceTimeToClusterStops |
The maximum total wait time in seconds allowed for stops in a cluster.
Optional and defaults to 2400 seconds. |
Integer | |
MaxServiceTimeToClusterLevel0Stops |
The maximum amount of combined service time. The stops at service level 0 (pre-10AM stops) inside a cluster are allowed to have.
Optional and defaults to 600 seconds. |
Integer | |
MaxServiceTimeToClusterLevel1Stops |
The maximum amount of combined service time. The stops at service level 1 (pre-noon stops) inside a cluster are allowed to have.
Optional and defaults to 600 seconds. |
Integer | |
MaxTravelTimeToBreakCluster |
The maximum total travel time in seconds a cluster can reach before being forced to break smaller clusters.
Optional and defaults to 300 seconds. |
Integer | |
AvgTravelTimeToBreakCluster |
The travel time in seconds that is used for breaking a cluster into smaller clusters if the travel time between any two stops in that cluster exceeds it.
Optional and defaults to 180 seconds. |
Integer | |
AvgTravelTimeRatioToBreakCluster |
The ratio of stops over the average time to break a cluster to the stops under the average time.
Optional and defaults to 3. |
Integer | |
MaxTimeBeforeLateInBlockTime |
The max time in seconds into a stop's blocked time window the driver arrives at the stop before it is considered late.
Optional and defaults to 900 seconds. |
Integer | |
UTurnCost |
The cost of making a U-turn regardless of vehicle type.
This value doesn't actually match any particular cost or unit of measurement used elsewhere. In theory, 1,000 is roughly 1 mile. Optional and defaults to a value assigned by vehicle type. |
Integer | |
PrioritizePremiumStops |
Pick a sequence with fewer stops with pre-noon and pre-six PM time windows that are late instead of favoring shorter ETAs or total distance.
Optional and defaults to true. |
Boolean | |
GeocodingUseLocationPlusAddress |
Geocode stops using latitude, longitude, and an address (if an address is provided) instead of finding the nearest grid link.
Optional and defaults to false. |
Boolean | |
AllowGeocodeMultiMatch |
Whether or not it's okay that a Geocode search returns more than one match for a stop.
Optional and defaults to true. |
Boolean | |
RemoveStopIfTimeWindowBeforeStartTime |
Whether or not a stop should be removed if its time window occurs before the start depot's start time.
Optional and defaults to true. |
Boolean | |
ClusterWithUniqueIDOnly |
When "true", after the algorithm tries to cluster based on the unique cluster ID, the algorithm stops trying to cluster anymore.
Optional and defaults to false. |
Boolean |
Element | Description | Data Type | Value/Example |
---|---|---|---|
Name |
Name of the trip | String | |
Options |
Route Options Object. | ||
Stops |
A list of stops that include time window restrictions in which they must be reached.
It consists of Location Object and TimeWindow Object. The minimum required number of stops is 3. The maximum required number of stops is 200. |
Element | Description | Data Type | Value/Example |
---|---|---|---|
VehicleType |
The type of the vehicle driving the route.
Optional and defaults to default vehicle type 0. |
Enum |
0 - Truck 1 - LightTruck 2 - Auto |
RoutingType |
The type of routing algorithm to use.
Optional and defaults to 0. |
Enum |
0 - Practical 1 - Shortest 2 - Fastest |
HighwayOnly |
Indicates whether to use highways.
Optional and defaults to false. |
Boolean | |
FuelRoute |
Whether or not a fuel optimized route is desired.
Optional and defaults to false. This parameter is ignored by time window optimization. If "true" is passed, it is set to "false" and a warning is returned in the response header. |
Boolean | |
UseAvoidsAndFavors |
Whether or not to use avoids and favors.
Optional and defaults to false. This parameter is a remnant of legacy code and is only useable by legacy customers. On top of that, time window optimization ignores this parameter. If "true" is passed, it is set to "false" and a warning is returned in the response header. |
Boolean | |
ClassOverrides |
Represents a route class override to a special network.
Optional and defaults to 0. |
Boolean |
0 - None 1 - FiftyThreeFoot 2 - NationalNetwork 3 - FiftyThreeFoot, NationalNetwork |
DistanceUnits |
Represents miles or kilometers.
Optional and defaults to 0. |
Boolean |
0 - Miles 1 - Kilometers |
TollDiscourage |
Whether or not tolls should be discouraged on the route.
Optional and defaults to false. |
Boolean | |
BordersOpen |
Wether or not borders are open for travel.
Optional and defaults to false. |
Boolean | |
OverrideRestrict |
Whether or not to override truck restrictions.
Optional and defaults to false. If this property is set to "true", then it is set to false and a warning is returned in the response header. This affects link costs in PCMiler and allows differences between it and CoPilot. |
Boolean | |
HazMatType |
Defines transported hazardous material type.
Optionalsand defaults to 0. |
Enum |
0 - None 1 - General 2 - Caustic 3 - Explosives 4 - Flammable 5 - Inhalants 6 - Radioactive |
RouteOptimization |
The method by which to optimize the route stops.
Optional and defaults to 0. If any value other than "None" is provided, then it is set to 0 and a warning is returned in the response header. Time window optimization requires the start and end depot to be fixed so this value is at ends with the process. |
Boolean |
0 - None 1 - Thruall 2 - DestinationFixed |
TruckCfg |
TruckConfig object. Configures truck size and statistics.
Optional. |
||
Units |
Specifies whether English or metric units describe vehicle dimensions.
Optional and defaults to 0. |
Enum |
0 - English 1 - Metric |
Height |
Represents the height of the truck in feet and inches, or meters depending upon the units.
Maximum value is 13'6" or 4.1148 meters. Optional and defaults to "13'6\"" in all regions except Europe, which is "12'6\"". |
String | |
Length |
Represents the length of the truck in feet or meters, depending upon the units.
Maximum value is 53' or 16.1544 meters. Optional and defaults to "48'" in all regions except Europe, which is "54'1\"". |
String | |
Width |
Represents the width of the truck in inches or meters, depending upon units.
This value can be 96" and below, 102" and above or 98". Optional and defaults to "96\"" for all regions. |
String | |
Weight |
Represents the weight of the truck in pounds or kilos, depending upon units.
Acceptable values can be up to 132,000 pounds or 59,874 kilos. Optional and defaults to "80000". |
String | |
Axles |
The number of axles on the truck.
Acceptable values are 2 through 14. Optional and defaults to 5. |
Integer | |
LCV |
Indicates whether the truck is a multi-trailer or longer combination vehicle.
This is used for calculation of toll costs, and only for North American region. Optional and defaults to false. |
Boolean | |
HubRouting |
Whether or not to enable hub routing.
Optional and defaults to false. |
Boolean | |
AFSetIDs |
This represents a collection of set IDs to use with avoid/favors.
Like "UseAvoidsAndFavors" this is only useable by legacy customers and is ignored by time window optimization. If a list is provided, it is emptied, is ignored and a warning is returned in the response header. |
List of integers | |
ElevLimit |
Represents elevation limit when generating a route.
Elevation units can be either meters or feet determined by "DistanceUnits". Miles=feet, Kilometers=meters Limit will be ignored if: 1.Routing is deemed impractical with the limit. 2.A stop is located at an elevation higher than the limit. Optional and defaults to 0. |
Unsigned Integer | |
FerryDiscourage |
Whether or not to avoid ferries while routing.
Optional and defaults to 0. |
Boolean | |
HoSOptions |
This is an object used to define a driver's service times and rule sets.
Optional and defaults to null. This object is at ends with the entire time window optimization process and should not be defined. However, an warning will only be thrown if "Enabled" is set to "true" and then the object will be set to null. |
HoSScheduleType object | |
Enabled |
Whether or not to use the defined "HoSScheduleType" object.
Optional and defaults to false. If this is "true", an warning will be returned and the parent "HoSScheduleType" object will be set to null. |
Boolean | |
SideOfStreetAdherence |
How strict to be in order to avoid the destination being on the opposite side of the street.
Optional and defaults to 0. |
Enum |
0 - Off 1 - Minimal 2 - Moderate 3 - Average 4 - Strict 5 - Adhere 6 - StronglyAdhere |
GovernorSpeedLimit |
Maximum average road speed to use in route calculations that overrides all other road speeds when they are above this value.
Valid value is between 1 and 100 mph. Optional and default is 0. |
Integer |
For a valid Location, one of the following must be defined. See details in Sample JSON Request.
StreetAddress
, City
, State
, County
, Country
, SPLC
and zip
.Lat
and Lon
.It is also valid to have both defined. As long as one of the above conditions are met, it doesn't matter what else in "Location" is undefined or partially defined. If neither of the requirements are met, an error is returned for each invalid stop.
Element | Description | Data Type | Value/Example |
---|---|---|---|
TimeWindow |
The window of time in which a stop must be reached.
It contains a string StartTime and string EndTime .
|
||
SecondTimeWindow |
It represents a second time window in which the stop can be reached.
It contains a string StartTime and string EndTime .
A single stop cannot have this and BlockTimeWindow defined at the same time.
|
||
BlockTimeWindow |
The window of time in which a stop cannot be reached within a time window.
It contains a string StartTime and string EndTime .
A single stop cannot have this and SecondTimeWindow defined at the same time.
|
||
StartTime |
The stop can only be reached on or after this time.
|
||
EndTime |
The stop can only be reached on or before this time. | ||
WaitTime |
The period of time in which the driver will be at this stop in seconds. | Integer | |
IsBreak |
Whether or not this stop is actually where the driver takes a break. In this case, the time window represents how long the break is.
Optional and defaults to false. A single stop cannot be a static stop and a break stop at the same time.
|
Boolean | |
IsStatic |
Whether or not this stop is not to change its position in the sequence when an optimized sequence is calculated. Static stops can only appear at the beginning and the end of a sequence.
Optional and defaults to false. A single stop cannot be a static stop and a break stop at the same time.
|
Boolean | |
UniqueClusterID |
This coerces the algorithm to cluster stops together based on these IDs. It never uses only the unique cluster ID by itself and clusters can still break apart during sequencing. However, stops with the same unique cluster ID are more likely to be sequenced together in the end result.
Optional and defaults to an empty string. Set ClusterWithUniqueIDOnly to "true" in order to prioritize clustering by the unique cluster ID more than normal. |
String |
{ "Settings":{ "Method":1, "TimeFormat":1, "MaxClusterCount":40, "MinClusterCount":30, "MaxAirTravelTimeForCluster":180, "MinAirTravelTimeForCluster":6, "MaxAirTravelDistanceForCluster":100.0, "MaxAirTravelDistanceFromDepot":200.0, "MaxGridsForMatrixCalculation":60, "GeocodingDistanceThreshold":0.497097, "GeocodingConfidenceThreshold":2, "MaxWaitTime":1800, "MaxBreakWaitTime":7200, "MaxServiceTimeToClusterStops":2400, "MaxServiceTimeToClusterLevel0Stops":600, "MaxServiceTimeToClusterLevel1Stops":600, "MaxTravelTimeToBreakCluster":300, "AvgTravelTimeToBreakCluster":180, "AvgTravelTimeRatioToBreakCluster":3, "MaxTimeBeforeLateInBlockTime":900, "UTurnCost":-2, "PrioritizePremiumStops":true, "GeocodingUseLocationPlusAddress":false, "AllowGeocodeMultiMatch":true, "RemoveStopIfTimeWindowBeforeStartTime":true, "UniqueClusterStrictness":0 // trunk only }, "Route":{ "Name":"", "Options":{ "VehicleType":0, "RoutingType":0, "HighwayOnly":false, "FuelRoute":false, "UseAvoidsAndFavors":false, "ClassOverrides":0, "DistanceUnits":0, "TollDiscourage":false, "BordersOpen":true, "OverrideRestrict":false, "HazMatType":0, "RouteOptimization":0, "TruckCfg":{ "Units":0, "Height":"13'6\"", "Length":"48'", "Width":"96\"", "Weight":"80000", "Axles":5, "LCV":false }, "HubRouting":false, "AFSetIDs":[ ], "ElevLimit":0, "FerryDiscourage":false, "HoSOptions":{ "Enabled":false, "RemainingDriveTimeUntilBreak":0.0, "RemainingDriveTime":0.0, "RemainingOnDutyTime":0.0, "HoSRuleType":0, "RemainingCycleDutyTime":0.0 }, "SideOfStreetAdherence":0, "GovernorSpeedLimit":0, "CustomRoadSpeeds":[ { "RoadCategory":1, "Speed":0 } ] }, "Stops":[ { "Location":{ "Address":{ "StreetAddress":"", "City":"", "State":"", "Zip":"", "County":"", "Country":"", "SPLC":"", "CountryPostalFilter":0, "AbbreviationFormat":0 }, "Coords":{ "Lat":"0.000000", "Lon":"0.000000" }, "Region":4, "Label":"", "PlaceName":"" }, "TimeWindow":{ "StartTime":"00:00", "EndTime":"11:59" }, "SecondTimeWindow":{ "StartTime":"00:00", "EndTime":"11:59" }, "BlockTimeWindow":{ "StartTime":"00:00", "EndTime":"11:59" }, "WaitTime":0, "IsBreak":false, "IsStatic":false, "UniqueClusterID":"" // trunk only } ] } }
{ "TotalETA":"00:00", "TotalDistance":"0.00", "Stops":[ { "Location":{ "Address":null, "Coords":{ "Lat":"0.000000", "Lon":"0.000000" }, "Region":4, "Label":"", "PlaceName":"" }, "OriginalPosition":0, "ETA":"00:00", "Distance":"0.00", "TimeWindowMet":false, "SlackTime":0 } ], "RemovedStops":[ { "Location":{ "Address":{ "StreetAddress":"", "City":"", "State":"", "Zip":"", "County":"", "Country":"", "SPLC":"", "CountryPostalFilter":0, "AbbreviationFormat":0, "CountryAbbreviation": "US" }, "Coords":{ "Lat":"0.000000", "Lon":"0.000000" }, "Region":4, "Label":"", "PlaceName":"" }, "OriginalPosition":0, "Error":"" } ] }
Validation
Any errors or warnings that occur here happen when validating the incoming request JSON. Errors will cause a failure but warnings will allow the request to continue and be returned in the response header. Time window routing shares the same validations as other requests for requests, route options and stop locations. The following are unique to time window routing:
Warnings
Settings
property not provided. Using default values.
Settings
property provided.
Method
property not found in Settings
. The value will be set to 1.
Settings
is provided but Method
is not.
TimeFormat
property not found in 'Settings'. The value will be set to 1.
Settings
is provided but TimeFormat
is not.
RouteOptions
property not found in Route
. Using default values.
Options
is not provided in Route
.
FuelOptions
. This property will be ignored.
FuelRoute
is provided and set to true in RouteOptions
.
RoutingType
will be changed to 0.
RoutingType
is provided and set to 2 in RouteOptions
.
RouteOptimization
property. It requires its start and end depots to be fixed.
RouteOptimization
is provided and set to any value other than 0 in RouteOptions
.
HoSOptions
property. Work time and schedule is implied by the optimized sequence's results.
Use break stops to mark breaks for the driver in the sequence.
HoSOptions
is provided and "Enabled" is set to true in RouteOptions
.
OverrideRestrict
property. It impacts OverrideRestrictthe sequence.
OverrideRestrict
is provided and set to true in RouteOptions
.
EndTime
value. Just provide the same value as StartTime
.
Stops
list is provided an EndTime
with a different value than its StartTime
.
StartTime
. Any value over 0 will be ignored.
Stops
list is given a StartTime
with a value other than midnight.
EndTime
. Any value over 0 will be ignored.
Stops
list is given a EndTime
with a value other than midnight.
IsBreak
false is unnecessary.
Stops
list has IsBreak
set to false.
IsStatic
true is unnecessary.
Stops
list has "IsStatic" set to true.
WaitTime
above 0 will be ignored.
Stops
list has WaitTime
provided with a value greater than 0.
SPLC
provided but cannot be used by time window routing. This property will be ignored.
Location
property has SPLC
provided with a valid StreetAddress
,
City
, State
/Country
and Zip
.
SPLC
provided but time window routing requires StreetAddress
,
City
, State
/Country
It cannot use this property.
Location
property has SPLC
provided with a valid StreetAddress
,
City
, State
/Country
and Zip
.
Location
property must have either valid address (complete with StreetAddress
,
City
, State
/Country
) or valid latitude and longitude coordinates in order to be geocoded successfully.
Location
property does not have valid Coords
or StreetAddress
,
City
, State
/Country
and Zip
.
Errors
TimeWindowSequence
provided.
Route
provided.
Stops
provided.
Stops
list than minimum number of stops allowed.
Stops
list than maximum number of stops allowed.
StartTime
StartTime
in last stop in Stops
list.
EndTime
.
EndTime
in last stop in Stops
list.
TimeWindow
must be supplied.
TimeWindow
property.
StartTime
and EndTime
must be supplied
TimeWindow
without supplying StartTime
and EndTime
.
StartTime
does not match the sequence's time format [time format].
StartTime
that is not in the correct format for Settings
property's TimeFormat
.
EndTime
does not match the sequence's time format [time format].
EndTime
that is not in the correct format for Settings
property's TimeFormat
.
Stops
list has IsBreak
set to true.
BlockTimeWindow
defined and IsBreak
set to true.
SecondTimeWindow
defined and IsBreak
set to true.
Stops
list has IsStatic
set to false.
Stops
list has BlockTimeWindow
provided.
StartTime
and EndTime
must be supplied.
BlockTimeWindow
without supplying StartTime
and EndTime
.
StartTime
does not match the sequence's time format [time format].
StartTime
that is not in the correct format for Settings
property's TimeFormat
.
EndTime
does not match the sequence's time format [time format].
EndTime
that is not in the correct format for Settings
property's TimeFormat
.
Stops
list has SecondTimeWindow
provided.
StartTime
and EndTime
must be supplied
SecondTimeWindow
without supplying StartTime
and EndTime
StartTime
does not match the sequence's time format [time format].
StartTime
that is not in the correct format for Settings
property's TimeFormat
.
EndTime
does not match the sequence's time format [time format].
EndTime
that is not in the correct format for Settings
property's TimeFormat
.
SecondTimeWindow
or BlockTimeWindow
but not both.
BlockTimeWindow
and SecondTimeWindow
provided.
IsBreak
and IsStatic
set to true.
WaitTime
must be supplied.
WaitTime
property.
WaitTime
.
WaitTime
less than 0 or a value greater than the highest possible integer value (currently 2,147,483,647).
Location
property for a time window stop.
Location
property.
Optmization
These errors also cause the response to fail, like validation, only they occur during the actual optimization logic.
OverrideRestrict
Stops
list or both were not able to be geocoded, even with a valid Location
property.
Stops
list or both are farther away from all other stops than the distance defined by MaxAirTravelDistanceFromDepot
.
Stops
Location
property.
TimeWindow
StartTime
greater than EndTime
.
TimeWindow
EndTime
less than the first stop in Stops
list's TimeWindow
StartTime
if RemoveStopIfTimeWindowBeforeStartTime
is set to true.
WaitTime
less than 0 or a value greater than the value defined by MaxWaitTime
.
WaitTime
less than 0 or a value greater than the value defined by MaxBreakWaitTime
and has IsBreak
set to true.
IsStatic
set to true but is not placed at the beginning or end of the sequence.
IsBreak
set to true but was not able to be inserted into the final optimized sequence.
Stops
list was reached before the the break stop's StartTime
.
RemovedStops
list without actually having an error.