Click here to download the complete files for all steps in this tutorial.
In the previous step we demonstrated how territories can be manually designed. As territory design is an intricate process, in most cases you will want to do some form of manual design, however ODL Studio also includes a powerful automatic territory optimisation algorithm which can speed up the process of territory design.
Select the Area table again, right click and from the Component wizard, select Cluster using capacitated p-median clusterer. In the dialog that appears, select the first option, not the different capacities per cluster option. Configure the script editor as per the following screenshot:
In ODL Studio version 1.1.0 and onwards the layout of the distance calculation options has changed, but the default values remain the same as the screenshot, so you don’t need to change anything. From version 1.1.0, you also have the option to calculate much more accurate distances using a digital road network - contact us for details on setting this up.
The first three entries in the data adapter – latitude, longitude, and id – are automatically filled in by the wizard. The functions latitude()
and longitude()
calculate the latitude and longitude of the polygon building block’s centre, as the polygon’s geometry is stored in the column the_geom. The clusterer component also requires an identifier for each building block, which we are providing using the rowId
() function.
The clusterer algorithm is capacitated – it assumes that each building block has a quantity and the amount of quantity per-cluster (a.k.a. quantity per territory) cannot exceed a cluster’s defined capacity. We have chosen Workload for this quantity and hence we set that each territory should not contain too much work for the salesperson. Under Clusterer options we have told the algorithm to create 10 territories (see number of clusters) and we have set the capacity of each to be 300,000 as the total workload across all areas together is a little under 3,000,000.
We have also set the Territory column in the Area table to be the component’s clusterId column. The clusterer will therefore write the assigned cluster number back onto the Territory column in the Area table. The statistics controls you configured in the previous step (query table and barchart) use the Territory column and hence they will update whenever the clusterer runs.
Tip – the clusterer algorithm has many additional features not documented here – for example you can have different capacities per territory or set the centres of some of the territories to be fixed and optimise others. Contact us for more details.
Press play to run the script. The optimiser will automatically design your sales territories. The resulting territories should be similar to the following:
Because the total available capacity across all territories is only a little larger than the total workload, each territory has a very similar amount of work which is close to its capacity limit.