Cluster Constraint

A how-to guide for using the cluster constraint with vehicle routing.

  • This feature is configurable via code for custom routing apps.
  • You can find a list of all available features here.

The cluster constraint is used to enforce cluster compactness of routes. As the engine assigns stops to vehicles, the objective limits assignment to vehicles whose centroid is closer to a stop cluster than other vehicles. This can be useful if drivers have preferences to stay within a certain neighborhood/region after leaving the depot and are willing to drive longer distances if it means they can stick to a cluster of stops.

Here is an example using the cluster constraint in a custom application. You can specify the option in code before creating the model in your solver. Note, clustered routes can be handled with either this hard constraint or with the cluster objective.

    options.Model.Constraints.Enable.Cluster = true

    model, err := factory.NewModel(input, options.Model)
    if err != nil {
        return runSchema.Output{}, err

Page last updated