Skip to the content.


example workflow packagecloud Quality Gate Status



Ant Colony Optimisation (ACO) is an algorithmic framework for solving combinatorial optimisation problems. Algorithms in the framework imitate the foraging behaviour of ants. Ants in the wild traverse a terrain looking for food, while depositing pheromones over the path they take. Pheromone is a chemical substance attractive to ants. Efficient ants find shorter paths, making more trips from the food source to the colony than fellow ants on longer routes. This produces an accumulation of pheromone over short paths, getting the attention of the rest the colony. Over time, the whole colony converges towards the shortest path found.

In a similar fashion, artificial ants in ACO algorithms traverse the solution space of an optimisation problem, depositing pheromone over the components of the solution they built. The amount of pheromone is proportional to the quality of their solution, so pheromone accumulates in the most valuable solution components. Over time, ants in the artificial colony converge to high-quality solutions for a given optimisation problem. Isula allows an easy implementation of Ant-Colony Optimisation algorithms using the Java Programming Language. It contains the common elements present in the meta-heuristic, to allow algorithm designers the reutilization of behaviors. With Isula, solving optimisation problems with Ant Colony can be done in few lines of code.



The code uploaded to this GitHub Repository corresponds to a Maven Java Project. As such, it is strongly recommended that you have Maven installed before working with Isula.

You can use Isula as a dependency on your own Ant Colony Optimization project, by adding the following to your pom.xml file:


Algorithm Configuration

To solve a problem with an Ant-Colony Optimization algorithm, you need a colony of agents (a.k.a. ants), a graph representing the problem, and a pheromone data-structure to allow communication between these agents. Isula tries to emulate that pattern:

TspProblemConfiguration configurationProvider=new TspProblemConfiguration(problemRepresentation);
        AntColony<Integer, TspEnvironment> colony=getAntColony(configurationProvider);
        TspEnvironment environment=new TspEnvironment(problemRepresentation);

        AcoProblemSolver<Integer, TspEnvironment> solver=new AcoProblemSolver<>();
        solver.addDaemonActions(new StartPheromoneMatrix<Integer, TspEnvironment>(),
        new PerformEvaporation<Integer, TspEnvironment>());


        solver.getAntColony().addAntPolicies(new RandomNodeSelection<Integer, TspEnvironment>());

That’s a snippet from our Travelling Salesman Problem solution. Some things to notice there:

Isula Workflow

Here is a sequence diagram of the solveProblem() method, for you to get an idea on how isula works:

Isula Workflow

Isula will provide you the basic execution flow for an algorithm in the ACO metaheuristic. Usually, you can rely on the implementations already available for AcoProblemSolver and AntColony but you are free to override and extend in case you need it. Take in mind that you will need to create your own Ant instance for custom problems, however the base implementation already contains a lot of functionality available. If you need some reference, please take a look to the projects on the “Examples” section.

Every ACO algorithm has a set of customized behaviours that are executed during the solution processes: this behaviours can have global impact (DaemonAction instances, like pheromone update rules) or only affect an ant and its solution (like component selection rules: they are subclasses of AntPolicy). Isula already provides these behaviours for some representative algorithms (take a look at the package) ,but you might need to define your own policies or extend the ones already available.


If you are not familiar with the framework, a good place to start is the classic Travelling Salesman Problem:

Here are some advanced examples of optimization problems solved with Isula-based algorithms:



Feel free to contact me via email, or create a GitHub Issue here.