API Reference

Technical reference for every public class and function in grid. For a guided introduction to the modelling style, see the Quickstart and the User Guide.

Modelling Elements

The four core entities used to describe a problem instance on the routing graph. Native features are configured via their constructor parameters and attributes (e.g. node demands, vehicle capacities, time windows); see each class for the full list, and Native Features for a guided overview.

RoutingModel([triangular_inequality])

High-level model of a Vehicle Routing Problem.

Node(id[, demand, tw_start, tw_end, ...])

Vertex of the routing graph, representing a customer, depot, or stop.

Edge(node_from, node_to[, distance, travel_time])

Directed arc of the routing graph between two Node instances.

VehicleType(id[, count, capacity, ...])

Definition of a homogeneous group of vehicles sharing the same parameters.

Variables

User-defined variables declared on a VehicleType (via VehicleType.add_integer_var(), VehicleType.add_float_var(), VehicleType.add_nodes_set_var()) or globally on a RoutingModel. Combined with Python operators and the functions below, they enable the custom features described in Custom Features.

Var(id, var_type, initial_value[, preference])

Decision variable of the model.

SetVar(id, initial_value)

Set-valued decision variable, with elements from the node-id universe.

Functions

Free functions used to build expressions in cases where Python operators do not suffice: element-wise maximum and minimum over a list, square root, logarithm, and indexing into an array constant.

max(array)

Return an expression evaluating to the element-wise maximum of inputs.

min(array)

Return an expression evaluating to the element-wise minimum of inputs.

sqrt(x)

Return an expression evaluating to the square root of x.

log(x, y)

Return an expression evaluating to a logarithm.

select(array, key)

Return an expression indexing an array expression at a key.