Swarm intelligence: Ants
Swarm intelligence algorithms, are a family of nature-inspired algorithms. However, while evolutionary algorithms mimic genetic reproduction, swarm intelligence mimics the collective behavior of animals. When we observe the world around us, we see many life forms that are seemingly primitive and unintelligent as individuals, yet exhibit intelligent emergent behavior when acting in groups. An example of these life forms is ants. A single ant can carry 10 to 50 times its own body weight and run 700 times its body length per minute. These are impressive qualities; however, when acting in a group, that single ant can accomplish much more. In a group, ants are able to build colonies; find and retrieve food; warn other ants, show recognition to other ants, and use peer pressure to influence others in the colony. They achieve this through pheromones—essentially, dropping perfumes that signal other ants as they move. Other ants can sense these perfumes and change their behavior based on them. Ants have access to between 10 and 20 types of pheromones that can be used to communicate different intentions. Because individual ants use pheromones to indicate their intentions and needs, we observe complex emergent intelligent behavior when they are in groups.
Ant Colony Optimization (ACO)
Ant colony optimization (ACO) algorithms simulate the emergent behavior shown in this experiment. In the case of finding the shortest path, the algorithm converges to a similar state, as observed with real ants. Swarm intelligence algorithms are powerful tools for solving optimization problems where the search space is vast, rugged, and finding an absolute best solution is mathematically difficult. These problems belong to the same broad class that genetic algorithms aim to solve, but the choice between the two often comes down to how the problem is encoded. Genetic Algorithms are typically better for discrete choices (like choosing which items to pack in a knapsack). Swarm Algorithms (like Particle Swarm Optimization) excel at continuous numeric problems (like tuning the exact floating-point weights of a neural network).
Imagine that we are visiting a carnival that has many attractions. Each attraction is located in a different area, with varying distances between them. Because we don’t feel like wasting time and walking too much, we will attempt to find the shortest paths between all the attractions.

Visit the carnival better than the ACO
The simulation below lets you tap nodes to visit attractions and try to minimize the total distance traveled. The ACO tries to accomplish this by using pheromones to signal the best paths to take. The Reset button lets you start a new simulation with a random map. The Random route button lets you see how bad a random route performs based on an algorithm inspired by ants.
Pick a route or choose a random one to see how it compares to the ACO algorithm route.