Package libai.ants.algorithms
Class AntColonySystem
- java.lang.Object
-
- libai.ants.algorithms.Metaheuristic
-
- libai.ants.algorithms.AntColonySystem
-
- All Implemented Interfaces:
java.util.Comparator<Ant>
- Direct Known Subclasses:
AntQ
public abstract class AntColonySystem extends Metaheuristic
This class belong to the core classes of the Ant Framework.Implements the Ant Colony System algorithm.
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
debug
If true, print debug information over System.out.printlnprotected static int
maxCandidates
Maximum number of candidates to be included in the candidate listprotected static int
r_0
Used to balance exploration and explotation.protected static int
ro_1
r_1 is a number in the range [0,1].protected static int
ro_2
r_2 is a number in the range [0,1].protected static int
tau_0
An small positive constant that reinforces pheromones on local paths.-
Fields inherited from class libai.ants.algorithms.Metaheuristic
alpha, Ants, bestSolution, beta, candidates, currentIterationNumber, destinationNode, E, Graph, initialNode, maxNumIterations, numberOfAnts, numberOfNodes, Parameters, Pheromones
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AntColonySystem()
AntColonySystem(Enviroment E)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkParameters()
Checks whether or not all of the algorithm's parameters exists.void
daemonActions()
This function is called on each iteration and it provides a way to implement centralized actionsint
decisionRule(int i, java.util.List<java.lang.Integer> currentSolution)
Used by ants to decided the next node to visit.int
decisionRuleNotFromCandidate(int i, java.util.List<java.lang.Integer> possibleNodes)
Selects a node from all posible nodes, without taking into consideration candidates list.void
localPheromonesUpdate(int i, int j)
Updates pheromone trail of a current local solutionvoid
pheromonesEvaporation()
Evaporates the pheromone trail contained in the enviroment E according to some ACO algorithm specific logicvoid
pheromonesUpdate()
Updates the pheromone trail contained in the enviroment E according to some ACO algorithm specific logicvoid
solve()
This is the body of the algorithm.-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from class libai.ants.algorithms.Metaheuristic
candidateList, compare, constrains, f, getBestSolution, getCurrentIterationNumber, getE, getNumberOfNodes, getParam, heuristicInfo, setE, setNumberOfNodes, setParam
-
-
-
-
Field Detail
-
debug
public static final boolean debug
If true, print debug information over System.out.println- See Also:
- Constant Field Values
-
maxCandidates
protected static final int maxCandidates
Maximum number of candidates to be included in the candidate list- See Also:
- Constant Field Values
-
r_0
protected static final int r_0
Used to balance exploration and explotation. r_0 is a number in the range [0,1] If r_0 is close to zero, the algorithm explores new paths If r_0 is close to one, the algorith exploits by favoring the best edge accoriding to the candidate list- See Also:
- Constant Field Values
-
ro_1
protected static final int ro_1
r_1 is a number in the range [0,1]. For small values of ro_1, the existing pheromone concentrations on links evaporate slowly, while the influence of the best route is dampened. For larger values of ro_1, previous pheromone deposits evaporate rapidly, but the influence of th best rout is emphasized Used inpheromonesUpdate()
andpheromonesEvaporation()
- See Also:
- Constant Field Values
-
ro_2
protected static final int ro_2
r_2 is a number in the range [0,1]. Deals with local pheromone evaporation, in the same manner that ro_1 deals with global pheromone update- See Also:
- Constant Field Values
-
tau_0
protected static final int tau_0
An small positive constant that reinforces pheromones on local paths. Experimental results on different TSPs showed tattau_0 = 1 / (N_g * L)
provided good resultsN_g
is the number of nodes in the graph andL
is the lenght of a tour produced by a nearest neighbor heuristic for TSPs.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AntColonySystem
public AntColonySystem(Enviroment E)
-
AntColonySystem
protected AntColonySystem()
-
-
Method Detail
-
checkParameters
public void checkParameters() throws AntFrameworkException
Description copied from class:Metaheuristic
Checks whether or not all of the algorithm's parameters exists. If some obligatory parameter do not exist, the function throws an exception. If some other parameter do not exists but it is possible to set a default value, here is the place to do it.- Specified by:
checkParameters
in classMetaheuristic
- Throws:
AntFrameworkException
-
daemonActions
public void daemonActions()
Description copied from class:Metaheuristic
This function is called on each iteration and it provides a way to implement centralized actions- Specified by:
daemonActions
in classMetaheuristic
-
solve
public void solve() throws AntFrameworkException
Description copied from class:Metaheuristic
This is the body of the algorithm. Implements the fundamental logic and calls to other functions: pheromonesUpdate,pheromonesEvaporation.. according to some ACO algorithm specific logic- Specified by:
solve
in classMetaheuristic
- Throws:
AntFrameworkException
- AntFrameworkException
-
localPheromonesUpdate
public void localPheromonesUpdate(int i, int j)
Updates pheromone trail of a current local solution- Parameters:
i
- position i of the solutionj
- position j of the solution
-
pheromonesUpdate
public void pheromonesUpdate()
Description copied from class:Metaheuristic
Updates the pheromone trail contained in the enviroment E according to some ACO algorithm specific logic- Specified by:
pheromonesUpdate
in classMetaheuristic
-
pheromonesEvaporation
public final void pheromonesEvaporation()
Description copied from class:Metaheuristic
Evaporates the pheromone trail contained in the enviroment E according to some ACO algorithm specific logic- Specified by:
pheromonesEvaporation
in classMetaheuristic
-
decisionRule
public int decisionRule(int i, java.util.List<java.lang.Integer> currentSolution)
Description copied from class:Metaheuristic
Used by ants to decided the next node to visit.- Specified by:
decisionRule
in classMetaheuristic
- Parameters:
i
- source nodecurrentSolution
-currentSolution
- Returns:
- destination node
-
decisionRuleNotFromCandidate
public int decisionRuleNotFromCandidate(int i, java.util.List<java.lang.Integer> possibleNodes)
Selects a node from all posible nodes, without taking into consideration candidates list. This is the same desicion rule from Ant System but without the alpha parameter. It is use here when there is no candidates in the list.- Parameters:
i
- source nodepossibleNodes
-possibleNodes
- Returns:
- destination node
-
-