Finding the shortest bus route implies finding a path that connects points (bus stops) on a map. This is an instance of the traveling salesman problem. In this recipe, we'll approach the problem of finding the shortest bus route with different algorithms, including simulated annealing and ant colony optimization.
Getting ready
Apart from standard dependencies such as scipy and numpy, which we always rely on, we'll be using the scikit-opt library, which implements many different algorithms for swarm intelligence.
Swarm intelligence is the collective behavior of decentralized, self-organized systems that leads to the emergence of apparent intelligence in the eyes of an observer. This concept is used in work based on artificial intelligence. Natural systems, such as ant colonies, bird flocking, hawks hunting, animal herding, and bacterial growth, display a certain level of intelligence at the global level, even though ants, birds, and hawks typically...