Giter Site home page Giter Site logo

melikcakir / isula Goto Github PK

View Code? Open in Web Editor NEW

This project forked from cptanalatriste/isula

0.0 0.0 0.0 969 KB

A Java Framework for Ant Colony Optimization algorithms.

Home Page: https://www.sciencedirect.com/science/article/pii/S2352711019300639

License: MIT License

Java 100.00%

isula's Introduction

Isula: A Framework for Ant Colony Algorithms

Build Status packagecloud

For an in-depht discussion of the framework and its features you can read our paper in the SoftwareX journal: https://www.sciencedirect.com/science/article/pii/S2352711019300639

Isula allows an easy implementation of Ant-Colony Optimization algorithms using the Java Programming Language. It contains the common elements present in the meta-heuristic to allow algorithm designers the reutilization of common behaviors. With Isula, solving optimization problems with Ant Colony can be done in few lines of code.

Isula in Action

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:

An Isula Primer

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.

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 this 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.initialize(environment, colony, configurationProvider);
    solver.addDaemonActions(new StartPheromoneMatrix<Integer, TspEnvironment>(),
            new PerformEvaporation<Integer, TspEnvironment>());

    solver.addDaemonActions(getPheromoneUpdatePolicy());

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

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

  • Problem and algorithm configuration is provided by ConfigurationProvider instances. Make your own with the values you need.
  • The class that does everything is AcoProblemSolver. In this case, we're using the same one provided by the framework but you can extend it to suit your needs.
  • The Problem Solver needs an Environment that manages the problem graph and the pheromone matrix. You need to extend the Environment class provided with the framework to adjust it to support your problem.
  • And we need an Ant Colony, of course. The Ant Colony main responsibility is to create Ants, and make them built solutions in iterations. The robust base AntColony class makes implementing this very easy.
  • The hearth of the algorithm is the Ant class. You will need to define an Ant that suits your needs.
  • Isula supports daemon actions -global behaviors- and ant-level policies, such as the ones present in multiple ACO Algorithms. You can add daemon actions to a solver via the addDaemonActions method and ant policies to a colony via the addAntPolicies method.
  • Finaly, you call the solveProblem() method and wait for the best solution to be shown.

Isula internals

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

Alt text

Isula will provide you the basic execution flow for an algorithm in the ACO metaheuristic. On a common use case, 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 usually you will need to create your own Ant instance according to your project needs, 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 "Isula in action" 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 this behaviours for some representative algorithms -take a look at the isula.aco.algorithms package- but you might be in the need of defining your own policies or extending the ones already available.

Read about Isula

The Javadoc of every class on the framework is available here: http://cptanalatriste.github.io/isula/doc/

Also, in this article Ant Colony Optimization algorithms are discussed and Isula is used to implement them in the Java Programming Language: http://www.codeproject.com/Articles/1011148/A-Java-Primer-of-Ant-Colony-Algorithms

How to use this 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 personal Ant Colony Optimization project by adding the following to your pom.xml file:

<repositories>
    <repository>
        <id>isula</id>
        <url>https://packagecloud.io/cgavidia/isula/maven2
        </url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>isula</groupId>
        <artifactId>isula</artifactId>
        <version>2.0.1</version>
    </dependency>
</dependencies>

Questions, issues or support?

Feel free to contact me at [email protected].

isula's People

Contributors

cptanalatriste avatar jbrcaballero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.