Trying to resolve the Travelling Salesman Problem in Salesforce
Below is a screen showing one attempt at finding the best route to visit several accounts using the Artificial Bee Colony algorithm. The best route is defined as the route with minimal total sum of the distances between accounts. In other words, the route to spent the least amount of time and gas.
I am not sure anyone has ever had that problem to resolve in a Salesforce application but I found it was a good way to test my implementation of the Artificial Bee Colony (ABC) optimization algorithm, which could be used in many other optimization problems.
This implementation offers a fairly good approximation of the best route – definitely not the best route as you can see below: you would go from Plano to Richardson before Garland and then from Garland to Mesquite to save a few miles/gallons.
The implementation is split into 2 main classes: the Hive, which implements the ABC algorithm, and the TravellingSalesmanProblem class, which is in charge of storing the accounts latitude/longitude, calculate the distances between accounts and getting the next best route.
Other potential applications of the Travelling Salesman Problem could be:
- deciding the different routes each truck should follow in a delivery/courier company fleet
- wiring together memory elements in digital circuits in a sequence to minimize length of wire
- finding a sequence of advertising spots where ads from one company would not be shown immediately after its competitor (say, keep a Coke ad away from an Pepsi ad)
- in robotic welding, find a good sequence of tasks and path for the robot arm to weld the seams faster
- likewise, find the optimum path for a CNC machine to drill multiple holes