Clarke-Wright savings algorithm for vehicle routing problem (VRP) with single depot and vehicle capacity constraints.
In one of my courses, we were asked to manually solve a vehicle routing problem (a kind of optimization problem) . It turns out I don't want to manually solve it, so I wrote this code. It has each step reported. Feel free to use it for your own purpose.
A complete description of Single Depot VRP can be found here: http://web.mit.edu/urban_or_book/www/book/chapter6/6.4.12.html
In order to get the code run, you need 2 input files in .csv format:
- Nodes' distances to depot and the demands on them.
- Pairwise distances between nodes. If your nodes are in coordinate format, you can actually convert them to pairwise easily using other tools.
I have the sample data files uploaded here. They correspond to the textbook link above, so that you can check if the results are correct.