Features

Cluster constraint

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

This feature is configurable via options for both custom and marketplace routing applications. You can find a list of all available features here.

This how-to guide assumes you already completed the get started with vehicle routing tutorial.

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.

To enable the cluster constraint, you can run with the following option model.constraints.enable.cluster. See options for specifying options for both remote and local runs. Note, clustered routes can be handled with either this hard constraint or with the cluster objective.

For custom apps, you can enable the option in code as follows:

    options.Model.Constraints.Enable.Cluster = true

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

Page last updated