Constraint API Descriptions

The API offers a variety of constraints to control various aspects of the solutions returned by the routing engine. These constraints can be loosely divided into three categories

  • Solution Level : These constraints control global properties such as the total travel time across all routes and the number of active routes in the solution.
  • Order LevelThese are constraint that relate to the properties of how a single order or set of orders is treated in the solution, including the honoring of time windows, appointments, and priority.
  • Route LevelThese constraints address features of the individual route including the # of stops, the amount of working time vs the length of the shift, the sequencing of the stops on the route, and so on.

For each constraint category, we provide a list of all the currently supported constraints. We provide a description of each constraint and in many cases include a detailed example that shows how the inclusion of the constraint in a routing problem helps to shape the solution in a particular way. In these examples, the “constraints” object is first in the JSON, but this is just for clarity’s sake and the top-level objects can be in any order in a request. Many constraints have additional members that influence the behavior of the constraint in addition to the following members which are required by all constraints.

constraint_typestringNString that provides the specific type of the constraint. Must be an exact string match for one of the constraint types given here.
constraint_namestringNString that gives a user-defined name for the constraint.
penalty_per_violationintegerNNumber of penalty units assessed for each violation
violation_incrementintegerYIf provided, then an additional penalty_per_violation units of penalty is assessed whenever we exceed the constraint’s threshold by violation_increment units. Note that the units of the violation_increment depend on the constraint type – sometimes the units will be seconds, other times the units will be the number of stops on the route. See the individual constraint descriptions for more details on how this works for each constraint type.