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.
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
addAntPolicies
(AntPolicy<C, E>... antPolicies) Adds a list of policies to every Ant in the Colony.void
buildColony
(E environment) Initialization code for the colony.boolean
buildSolutions
(E environment, ConfigurationProvider configurationProvider, Instant executionStartTime) Puts every ant in the colony to build a solution.void
Clears solution build for every Ant in the colony.Produces a new Ant to integrate the colony.getBestPerformingAnt
(E environment) Returns the ant with the best performance so far, that is the one with the lowest cost.int
getHive()
Returns a List of all the ants in the colony.int
void
setColonyIndex
(int colonyIndex) void
setNumberOfAnts
(int numberOfAnts) void
setTimeLimit
(Duration timeLimit) toString()
-
Constructor Details
-
AntColony
public AntColony(int numberOfAnts) Creates a colony of ants- Parameters:
numberOfAnts
- Number of ants in the colony.
-
-
Method Details
-
buildColony
Initialization code for the colony. The main responsibility is Ant instantiation.- Parameters:
environment
- Environment where the Ants are building solutions.
-
createAnt
Produces a new Ant to integrate the colony.- Parameters:
environment
- Environment with problem specific information.- Returns:
- An Ant instance.
-
getBestPerformingAnt
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
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
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
-
setColonyIndex
public void setColonyIndex(int colonyIndex) -
getColonyIndex
public int getColonyIndex() -
getNumberOfAnts
public int getNumberOfAnts() -
setNumberOfAnts
public void setNumberOfAnts(int numberOfAnts) -
toString
-