Package isula.aco

Class AntColony<C,E extends Environment>

java.lang.Object
isula.aco.AntColony<C,E>
Type Parameters:
C - Class for components of a solution.
E - Class representing the Environment.

public class AntColony<C,E extends Environment> extends Object
A group of ants. As an abstract type, you need to define how to build individual ants through the createAnt() method.
Author:
Carlos G. Gavidia
  • Constructor Details

    • AntColony

      public AntColony(int numberOfAnts)
      Creates a colony of ants
      Parameters:
      numberOfAnts - Number of ants in the colony.
  • Method Details

    • buildColony

      public void buildColony(E environment)
      Initialization code for the colony. The main responsibility is Ant instantiation.
      Parameters:
      environment - Environment where the Ants are building solutions.
    • createAnt

      protected Ant<C,E> createAnt(E environment)
      Produces a new Ant to integrate the colony.
      Parameters:
      environment - Environment with problem specific information.
      Returns:
      An Ant instance.
    • getBestPerformingAnt

      public Ant<C,E> getBestPerformingAnt(E environment)
      Returns the ant with the best performance so far, that is the one with the lowest cost.
      Parameters:
      environment - Environment where the Ants are building solutions.
      Returns:
      Best performing Ant.
    • getHive

      public List<Ant<C,E>> getHive()
      Returns a List of all the ants in the colony.
      Returns:
      List of Ants.
    • clearAntSolutions

      public void clearAntSolutions()
      Clears solution build for every Ant in the colony.
    • buildSolutions

      public boolean buildSolutions(E environment, ConfigurationProvider configurationProvider, Instant executionStartTime)
      Puts every ant in the colony to build a solution.
      Parameters:
      environment - Environment that represents the problem.
      configurationProvider - Configuration provider.
    • addAntPolicies

      @SafeVarargs public final void addAntPolicies(AntPolicy<C,E>... antPolicies)
      Adds a list of policies to every Ant in the Colony. This are ant-specific behaviours, like component selection while building solutions.
      Parameters:
      antPolicies - List of policies.
    • setTimeLimit

      public void setTimeLimit(Duration timeLimit)
    • setColonyIndex

      public void setColonyIndex(int colonyIndex)
    • getColonyIndex

      public int getColonyIndex()
    • getNumberOfAnts

      public int getNumberOfAnts()
    • setNumberOfAnts

      public void setNumberOfAnts(int numberOfAnts)
    • toString

      public String toString()
      Overrides:
      toString in class Object