Class 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 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 in pheromonesUpdate() and pheromonesEvaporation()
        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 tat tau_0 = 1 / (N_g * L) provided good results N_g is the number of nodes in the graph and L 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 class Metaheuristic
        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 class Metaheuristic
      • 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 class Metaheuristic
        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 solution
        j - 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 class Metaheuristic
      • 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 class Metaheuristic
      • 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 class Metaheuristic
        Parameters:
        i - source node
        currentSolution - 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 node
        possibleNodes - possibleNodes
        Returns:
        destination node