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 objective is used to encourage cluster compactness of routes. As the engine assigns stops to vehicles, the objective encourages 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. Note, clustered routes can be handled with either this hard constraint or with the cluster constraint.
To enable the cluster objective and set the penalty to, say 1000, you can run with the following option
model.objectives.cluster 1000. 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: