In the current sharing and ‘on demand’ economy, the number of services available and the demand for them have increased (Schor and Fitzmaurice 2015). New services, such as Uber, DiDi or GOGOVAN have emerged. One of the benefits of such a system is the ability to develop optimisation logic that increases profits for partners, and decreases the costs for customers (Nguyen, Rintamäki and Saarijärvi 2018). It is no different in logistics, where Capacitated Vehicle Routing Problem with Time Windows makes goods delivery more efficient by optimising fleets of vehicles - allowing them to deliver more parcels and helping each driver to complete more deliveries on a daily basis.
Problems such as the Travelling Salesperson Problem (TSP) or Vehicle Routing Problem (VRP) have always been given much attention in the literature. TSP was first explored by (Flood 1956) and VRP was introduced using the example of optimal routing of gasoline trucks by (Dantzig and Ramser 1959). Ever since, both of these problems have been important ones in the field of Operations Research.
In this work, we focus on solving the special case of the Vehicle Routing Problem, where customers must be served within the given time window and each of the vehicles has a limited capacity - namely the Capacitated Vehicle Routing Problem with Time Windows (CVRPTW). Vehicle Routing Problem with Time Windows was proved to be NP-hard (Solomon 1986).
Throughout the time, there have been many proposed solutions to the CVRPTW. The first exact method to be proposed was the branch-and-bound approach(Christofides and Eilon 1969), which is the basis for the branch-and-cut exact algorithm (Baldacci, Hadjiconstantinou and Mingozzi 2004). However, even the current state-of-the-art exact methods work only for up to 360 waypoints (Pecin et al. 2017), which is not enough in our use case.
Another approach is to use metaheuristics in order to improve a suboptimal solution. Three metaheuristics (Laporte et al. 2006)
are the most efficient: Genetic Algorithms (GA)(Baker and Ayechew 2003) (Alba and Dorronsoro 2006) (Karakatič and Podgorelec 2015), Local Search (Cordeau, Gendreau and Laporte 1998), (Nagata and Braysy 2008) or Ant Colony Optimisation (ACO) (Gambardella, Taillard and Agazzi 1999).
There have been quite a few frameworks that are based on these algorithms, both open source and commercial. For open source solutions, there are VRPH (Groer, Golden and Wasil 2010) and Google Optimization Tools (OR-tools) (Perron 2011). While for commercial solutions, Gurobi (Gurobi 2018), LocalSolver (Zhang, Qi and Miao 2015) and other Constraint Programming solvers are used.
For our work, we decided to include the use of OR-tools, as it has got a Python API and it supports multiple VRP cases. In this paper, we focus on improving the performance of aforementioned framework by using a modified version of the DBSCAN clustering algorithm (Ester et al. 1996), which we refer to as ”Recursive-DBSCAN”. The reason why we decided to do so, is because the runtimes of OR-tools solvers increase rapidly (Fig. 1) and also, consume a lot of RAM memory (almost 20GB for 2000 waypoints).
In the Section 2 of this paper we formally formulate our problem. Section 3 describes our proposed method, with the results being presented in Section 4 and discussed in Section 5. Section 6 proposes some future work on the problem.
2 Problem Formulation
Vehicle Routing Problem can be subjected to various constraints such as constraints on vehicle capacity and time window of arrival. We look into VRP’s particular case - Capacitated Vehicle Routing Problem with Time Windows. We can describe the problem as follows:
Goods are to be delivered to a set of delivery points by a number of vehicles departing from the central depot. The vehicles are supposed to pick up all the packages from the depot within a certain time window. Similarly, each delivery vehicle needs to arrive at each delivery point within a certain time window specific to that point. Each vehicle has a limited capacity and each delivery has a certain size.
The goal is to determine a route schedule which minimises the travelled distance, given the following constraints:
Each vehicle starts its route at the depot.
The total size of packages assigned to a particular driver cannot exceed the capacity of the vehicle.
Each delivery waypoint is to be served by one and only one vehicle.
Each delivery needs to be completed within a given time window.
There are N delivery waypoints to be visited by the maximum of M vehicles. Let’s assume that the depot is node . The size of each delivery , , is defined as , while the time window is . The pickup time at the depot is . Each vehicle , , has got a maximum capacity . We define travel time between nodes and for the vehicle as , while is the distance between nodes and for the vehicle .
As in our case, we do not force vehicles to return back to the depot, we set
We can describe the problem mathematically (Szeto, Wu and Hoc 2011) as:
where is the number of deliveries, is the number of delivery vehicles, is the arrival time of the vehicle at node and is the arrival of the vehicle at the depot.
The objective function in Eq. (1) is to minimise the total travelled distance for all the vehicles. Constraints in Eq. (3) and Eq. (4) ensure that one and only one vehicle respectively arrives at and departs from each of the nodes. Eq. (5) ensures the route continuity. Eq. (6) ensures that the total size of packages taken by a vehicle does not exceed its capacity. Eq. (7) and Eq. (8) ensure that the time windows are met. Eq. (9) and Eq. (10) make sure that each vehicle is used no more than once.
3.1 Data Collection and Processing
The datasets are prepared from a sample of GOGOVAN trips completed in Hong Kong in 2017. They contain more than 10,000 delivery waypoints, provided in the GPS format. The datasets are randomised during the analysis.
The tests are conducted on a 2017 Macbook Pro 13”, with 2.3 GHz dual-core Intel Core i5, 16GB 2133 Mhz LPDDR3 RAM and 256GB SSD. For distance calculation, we use straight-line distance.
3.2 Algorithms for Vehicle Routing Problem
We decided to present our proposed Recursive-DBSCAN solution and benchmark it against two other methods.
The first method involves passing all the waypoints and vehicles, along with the constraints to the Google Optimization Tools solver and treating its output as the final solution. The other two methods are clustering-based approaches, where we first attempt to cluster the delivery waypoints and then try to optimise each of the clusters separately, by also passing it to the OR-tools Routing solver. The second method uses classical DBSCAN, while the third one is the proposed Recursive-DBSCAN clustering approach.
3.2.1 Google Optimization Tools
As a baseline, we chose to solve the CVRPTW problem using the OR-tools library.
The parameters we call Google Optimization Tool’s Routing library with every time are as follows:
|first_solution_strategy||PATH_CHEAPEST_ARC||First solution strategies, used as starting point of local search. Starting from a route ”start” node, connect it to the node which produces the cheapest route segment, then extend the route by iterating on the last node added to the route.|
|optimization_step||1||Minimum step by which the solution must be improved in local search.|
|solution_limit||9223372036854775807||Limit to the number of solutions generated during the search.|
|time_limit_ms||5000||Limit in milliseconds to the time spent in the search.|
|use_light_propagation||true||Use constraints with light propagation in routing model. Extra propagation is only necessary when using depth-first search or for models which require strong propagation to finalise the value of secondary variables. Changing this setting to true will slow down the search in most cases and increase memory consumption in all cases.|
One of the approaches explored is to use the DBSCAN clustering algorithm to cluster the waypoints to be optimised into several clusters of different size that will then be optimised one by one using the OR-tools method.
We define one very important constant here - , which represents the maximum number of delivery points in each cluster. Our goal is to obtain the clusters of maximum possible average size, while each of them is smaller than the aforementioned constant. We then pass these clusters as input to the OR-tools routing solver to obtain the optimised routes.
The pseudocode of such a method looks as follows:
Such a method already divides the routing problem into several smaller problems, consequently improving the performance of the algorithm.
We also propose a modification of the method described above, which applies DBSCAN recursively to each cluster, with the aim to make clusters more well-balanced in terms of number of waypoints in each of them (while decreasing the spatial balance).
We use binary search to find the initial feasible radius that maximises . We then identify clusters which contain too many nodes and apply recursively the same binary search logic in order to break down those large clusters into smaller, constituent clusters. Such an approach ensures that the found final clusters are of maximum possible average size, while at the same time they all lie within the preset size boundaries.
Such a method creates clusters of large radii in the less dense regions and smaller clusters in the high-density regions. The aim of that method is to obtain clusters that contain a similar number of waypoints and yet different radii. Such an approach resolves one issue encountered with classical DBSCAN - clusters in regions with more nodes contain more nodes than clusters in less dense regions. It also avoids a situation when a vehicle is assigned to a point within a cluster that contains only a few nodes.
We have a few constraints, namely: , and .
By reducing the variance of the number of nodes in clusters and putting constraints on both the maximum and minimum number of nodes per cluster, we obtain splits which can be effectively optimised separately, as they are smaller in terms of number of nodes. That should lead to improvement in runtimes of classical VRP solvers.
The pseudocode of the proposed can be found below:
3.3 Optimisation with OR-tools call
Having already produced the clusters using either the DBSCAN or the Recursive-DBSCAN method, we have obtained clusters of delivery points ready to be optimised. We attempt to optimise cluster-by-cluster and with each iteration we remove vehicles marked as “busy” - which means these “busy” vehicles are not considered for assignment for other clusters.
The following pseudocode illustrates that method:
3.4 Setting of Testing Parameters
The algorithm’s final output is an optimised delivery route, a sample of which is visualised in Fig. 2.
To test the performance. we chose the batches of size between 500 and 5000 waypoints, every 500. Three different metrics were used to measure the performance: runtime, total distance of the routes and the number of vehicles that are busy. For each data point, there were 15 different tests conducted.
Also, the following parameters presented in Table 2 were used during the analysis:
|capacity of each vehicle||30|
Our goal in this test was to reduce the runtime, without much impact on total distance and the number of vehicles. The OR-tools result, as presented in Fig. 1., was treated as the benchmark.
4.1 Total Travelled Distance
As can be seen in Fig. 3, for DBSCAN and Recursive-DBSCAN the distance increases linearly with the waypoints. The gradient of the Recursive-DBSCAN curve is similar to the gradient of the OR-tools. DBSCAN curve increases more rapidly than both Recursive-DBSCAN and OR-tools curves.
The DBSCAN curve is cut off at 2000 waypoints due to consuming more than 20GB of memory. That caused the program to crash.
4.2 Average Number of Busy Vehicles
Similarly to the Total Travelled Distance, Fig. 4. shows that OR-tools and Recursive-DBSCAN increase linearly with the number of waypoints, while DBSCAN solution has got a sharp increase.
As can be reasoned from Fig. 5., the runtimes are exponentially increasing. The Recursive-DBSCAN curve possesses the lowest gradient, followed by DBSCAN. The OR-tools solution has got the greatest gradient.
4.4 Overall Performance of the Algorithms
Both Recursive-DBSCAN and DBSCAN methods lead to a significant drop in runtime. DBSCAN has large increase in total distance travelled and the number of busy vehicle as measured against OR-tools. For Recursive-DBSCAN, the differences in total distance travelled and the number of busy vehicles are below 3.6% and 6.4% respectively. Summary fo results is presented in Table 3.
As we can see in Fig. 3, Fig. 4, Fig. 5 and Table 3, our proposed Recursive-DBSCAN method has better runtimes than both the DBSCAN and OR-tools (by ) methods. It is because Recursive-DBSCAN divides the node-set into a lower number of clusters, which decreases the number of times the OR-tools Routing library needs to be invoked. Both Recursive-DBSCAN and DBSCAN have better runtimes than OR-tools as they do not have to invoke OR-tools Routing library for more than max_cluster_size number of nodes.
The total distance for Recursive-DBSCAN is lower than for DBSCAN and higher than for OR-tools. In terms of total distance, Recursive-DBSCAN performs better than DBSCAN because it creates less clusters, which in turn means that less vehicles are required, which leads to lower distance. However, Recursive-DBSCAN performs worse than OR-tools, because it does not allow vehicles to be assigned to orders within different clusters and therefore does not take into account the relationships between the clusters.
Both the DBSCAN and the OR-tools solvers would crash at 2000 waypoints due to an extreme RAM usage, while the Recursive-DBSCAN method would find solutions up to 5000 waypoints.
In summary, Recursive-DBSCAN performs better than OR-tools in terms of runtime thanks to dividing the node-set into smaller clusters, for which the optimisation results can be obtained more quickly than for the whole set being optimised at once, as the number of possible assignments and routes is greatly limited by breaking down the problem into constituent parts. Having less possible solutions to be checked means that the optimisation finishes more quickly.
At the same time, Recursive-DBSCAN performs better than DBSCAN in terms of total distance and number of vehicles used, as it simply creates less clusters than DBSCAN, which also leads to clusters containing more nodes on average. That allows the optimisation within clusters to be of better quality, as there is enough nodes to fully utilise the capacity of each vehicle.
Most importantly, the Recursive-DBSCAN method runtimes are more acceptable to be used in the ‘on-demand’ economy, as it reduces the time drivers would be required to wait compared to OR-tools and supports instances of more than 2000 nodes.
This paper has described Recursive-DBSCAN - a new clustering approach to solve Capacitated Vehicle Routing Problem. By recursively clustering nodes together in batches that contain a similar number of nodes, we were able to reduce the runtimes by as benchmarked against Google Optimization Tools. That improvement is caused by splitting the node-set into constituent parts, consequently reducing the possible number of assignments and routes. At the same time, the total distance for Recursive-DSBCAN routes was higher than for OR-tools. Currently, the presented approach is used by GOGOVAN to optimise their routes on a daily basis.
We look forward to continue the work in that field. The next steps are to implement and benchmark the Recursive-DBSCAN clustering approach against some state-of-the-art solvers (Uchoa et al. 2016) using the test dataset provided by (Uchoa et al. 2016) as well. We hope to observe an improvement in runtimes against the state-of-the-art approaches, similarly to the improvement we have observed against Google Optimization Tools routing solver.
- Alba and Dorronsoro (2006) E. Alba and B. Dorronsoro. 2006. “Computing nine new best-so-far solutions for Capacitated VRP with a cellular Genetic Algorithm.” Information Processing Letters 98. 225–-230.
- Baker and Ayechew (2003) Barrie M.Baker, M.A.Ayechew. 2003. “A genetic algorithm for the vehicle routing problem.” Computers & Operations Research. Vol. 30, No. 5: 787–800.
- Baldacci, Hadjiconstantinou and Mingozzi (2004) R. Baldacci, E. Hadjiconstantinou, A. Mingozz. 2004. “An Exact Algorithm for the Capacitated Vehicle Routing Problem Based on a Two-Commodity Network Flow Formulation.” Operations Research. Vol. 52, No. 5: 723–738.
- Christofides and Eilon (1969) N. Christofides, S. Eilon. 1969. “An Algorithm for the Vehicle-dispatching Problem.” Journal of the Operational Research Society. Vol. 20, No. 3: 309–318.
- Contardo and Martinelli (2014) Claudio Contardo and Rafael Martinelli. 2014. “A new exact algorithm for the multi-depot vehicle routing problem under capacity and route length constraints.” Discrete Optimization. Vol. 12: 129–146.
Cordeau, Gendreau and Laporte (1998)
Jean‐François Cordeau, Michel Gendreau, Gilbert Laporte. 1998. “A tabu search heuristic for periodic and multi‐depot vehicle routing problems.”Networks. Vol. 30, No. 2: 105–119.
- Dantzig and Ramser (1959) G. B. Dantzig and J. H. Ramser. 1959. “The Truck Dispatching Problem.” Management Science. Vol. 6, No. 1 (October). 80–91.
- Ester et al. (1996) M. Ester, H. Kriegel, J. Sander, and X. Xu. 1996. “A density-based algorithm for discovering clusters in large spatial databases with noise.” Proc. 2nd Int. Conf. Knowledge Discovery and Data Mining (KDD’96). 226–-31.
- Gambardella, Taillard and Agazzi (1999) Luca Maria Gambardella, Éric Taillard and Giovanni Agazzi. 1999. “MACS-VRPTW: A Multiple Colony System For Vehicle Routing Problems With Time Windows.” New Ideas in Optimization. 63–76. England: McGraw-Hill Ltd.
- Groer, Golden and Wasil (2010) Chris Groer, Bruce Golden and Edward Wasil. 2010. “A library of local search heuristics for the vehicle routing problem”. Mathematical Programming Computation. Vol. 2, No. 2: 79–101.
- Gurobi (2018) Gurobi Optimization. 2018.
- Flood (1956) Merill M. Flood. 1956. “The Travelling Salesman Problem.” Operations Research. Vol. 4, No. 1 (February): 61–75.
- Karakatič and Podgorelec (2015) S. Karakatič and V. Podgorelec. 2015. “A survey of genetic algorithms for solving multi depot vehicle routing problem.” Applied Soft Computing. Vol. 27: 519–532.
- Laporte et al. (2006) G. Laporte, M. Gendreau, J‐Y. Potvin and F. Semet. 2006. “Classical and modern heuristics for the vehicle routing problem.” Internation Transactions in Operations Research. Vol. 7, No. 4-5: 285–300.
- Nagata and Braysy (2008) Y. Nagata and O. Braysy. 2008. “Efficient Local Search Limitation Strategies for Vehicle Routing Problems.”
- Nguyen, Rintamäki and Saarijärvi (2018) Hong Ngoc Nguyen, Timo Rintamäki and Hannu Saarijärvi. 2018. “Customer Value in the Sharing Economy Platform: The Airbnb Case.” Collaborative Value Co-creation in the Platform Economy. Translational Systems Sciences. Vol. 11: 225–246.
- Pecin et al. (2017) D. Pecin, A. Pessoa, M. Poggi, E. Uchoa. 2017. “Improved branch-cut-and-price for capacitated vehicle routing.” Integer Programming and Combinatorial Optimization. Vol. 9, No.1: 393–403.
- Perron (2011) Laurent Perron. 2011. “Operations Research and Constraint Programming at Google.” Principles and Practice of Constraint Programming – CP 2011. 2–2.
- Schor and Fitzmaurice (2015) Juliet B. Schor and Connor J. Fitzmaurice. 2015. “26. Collaborating and connecting: the emergence of the sharing economy.” Handbook of research on sustainable consumption. 410–25.
- Solomon (1986) Marius M. Solomon. 1986. “On the worst‐case performance of some heuristics for the vehicle routing and scheduling problem with time window constraints”. Networks. Vol. 16, No. 2: 161–174.
- Szeto, Wu and Hoc (2011) W. Y. Szeto, Yongzhong Wu and Sin C. Hoc. 2011. “An artificial bee colony algorithm for the capacitated vehicle routing problem.” European Journal of Operations Research. Vol. 215, No. 1: 126–135.
- Uchoa et al. (2016) E. Uchoa, D. Pecin, A. Pessoa, M. Poggi, A. Subramanian and T. Vidal. 2016. “New Benchmark Instances for the Capacitated Vehicle Routing Problem.” European Journal of Operational Research. Vol. 257, No. 3: 845–858.
- Zhang, Qi and Miao (2015) Y. Zhang, M. Qi, L. Miao and G. Wu. 2015. “A generalized multi-depot vehicle routing problem with replenishment based on LocalSolver.” International Journal of Industrial Engineering Computations. Vol. 6, No. 1: 81–98.
Appendix A Testing Results
Below, we present the exact results of each CVRPTW optimisation request we have run. For data privacy reasons, unfortunately we cannot share the exact input.