The problem I am facing is clustering problem, needed for a Vehicular Routing Problem (VRP) I'm tackling. It is a heterogeneous VRP with Time Window (TW) and a capacity utilization constraint, i.e. a truck can be routed only if its loading factor is more than 80%.
We have a set of customers dispersed on the map. Each customer has placed an order of a certain volume, varying from 1.000 to 36.000lt of a petroleum product.
I need to cluster these customers, in order to route them. Right now, I am using the $k$-means algorithm, and to find the number of clusters I am taking the integer value of $$\frac{\text{Sum Of Unrouted Orders}}{\text{Capacity Of Biggest Idle Vehicle}}.$$
Unfortunately, this method is kind of faulty, because of the following problems:
1) A cluster may be very small because the algorithm MUST create a certain number of clusters. In this case the customers of this small cluster will not be routed, due to the capacity utilization constraint.
2) Clusters with customers that are far away from the other are created, in order to reach the target volume of the cluster (close to the vehicle's capacity)
So my question is the following:
a) Do you know any method of finding the optimal number of clusters, beside the elbow and silhouette methods, as the clustering part is running several times, and I cannot spend time picking the number of clusters in each iteration.
b) Do you know a variation of the $k$-means algorithm that takes into consideration the volumes of the orders?
Edit: Some further research lead me to the capacitated clustering problem, which seems to be perfectly fit to what I'm looking for. As I was reading the work from Marcos Negreirosa, Augusto Palhano found at The capacitated centred clustering problem, I realised that the work suggested was similar to what I have implemented. My implementation is the following: Clustering Algorithm:
1. Initialize k centers (random points from dataset which are scattered on the map)
2. For each center, perform Range search around it with radius 1, 2, 4, …. and collect points in cluster with total capacity ~ C/2.
3. Update centers using the median per cluster
4. Assignment: For each point P that does not belong to any cluster
I. Sort centers by distance to P
II. Assign P to nearest cluster with availability in capacity
5. Update each center with cluster's median
6. Repeat steps 2-5, until the algorithm converges i.e. the centers do not change much in step 5.
but some of the results were a disappointment, along the run, as
1) Many customers were left unrouted (Cluster didn't fit perfectly in a vehicle, so a cluster could leave unrouted customers, even though the volume was close the its capacity).
2) Clusters created, after the creation of some routes, were combining customers very far from each other, as these customers were left off from when the cluster was routed.