Package libai.ants

Class Ant


  • public class Ant
    extends java.lang.Object
    This class belong to the core classes of the Ant Framework.

    It represent an Ant. An Ant is composed of a current position, an index where it belong in the Enviroment array an a current solution

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected int currentPos
      Current Ant position, i.e.: the index of a node in the problem graph
      protected int index
      This Ant's position in the Enviroment's Ants array
      protected java.util.List<java.lang.Integer> solution
      Current Ant solution
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Ant​(int index, int initialPos)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addSolution​(int Solution)
      Ads a component to the ant's current Vector solution
      void clearSolution()
      Clears the ant's current solution
      java.util.List<java.lang.Integer> copySolution()
      Returns a copy of the Vector with the ant's current solution
      int getCurrentPos()
      Returns the ant's current position
      java.util.List<java.lang.Integer> getSolution()
      Returns a reference to the Vector with the ant's current solution
      int getSolutionSize()
      Returns the size of the ant's current solution
      void printSolution()
      Prints the ant's current solution to the standard output
      protected void setCurrentPos​(int pos)
      Sets the ant's current position
      void setSolution​(java.util.List<java.lang.Integer> solution)
      Sets a Vector to be the ant's current solution
      java.lang.String toString()
      Return the string representation of an ant.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • solution

        protected java.util.List<java.lang.Integer> solution
        Current Ant solution
      • currentPos

        protected int currentPos
        Current Ant position, i.e.: the index of a node in the problem graph
      • index

        protected int index
        This Ant's position in the Enviroment's Ants array
    • Constructor Detail

      • Ant

        protected Ant​(int index,
                      int initialPos)
        Constructor. Allocates the ant's index and initial position
        Parameters:
        index - ant's index in the enviroment array
        initialPos - ant's initial position (node index) in the problem graph
    • Method Detail

      • getCurrentPos

        public int getCurrentPos()
        Returns the ant's current position
        Returns:
        the ant's current position.
      • setCurrentPos

        protected void setCurrentPos​(int pos)
        Sets the ant's current position
        Parameters:
        pos - the ant's current position
      • clearSolution

        public void clearSolution()
        Clears the ant's current solution
      • getSolution

        public java.util.List<java.lang.Integer> getSolution()
        Returns a reference to the Vector with the ant's current solution
        Returns:
        a reference to the Vector with the ant's current solution
      • setSolution

        public void setSolution​(java.util.List<java.lang.Integer> solution)
        Sets a Vector to be the ant's current solution
        Parameters:
        solution - a Vector with a solution
      • copySolution

        public java.util.List<java.lang.Integer> copySolution()
        Returns a copy of the Vector with the ant's current solution
        Returns:
        a copy of the Vector with the ant's current solution
      • addSolution

        public void addSolution​(int Solution)
        Ads a component to the ant's current Vector solution
        Parameters:
        Solution - an integer component to be added to the current ant's solution
      • getSolutionSize

        public int getSolutionSize()
        Returns the size of the ant's current solution
        Returns:
        an integer corresponding to the size of the ant's current solution
      • printSolution

        public void printSolution()
        Prints the ant's current solution to the standard output
      • toString

        public java.lang.String toString()
        Return the string representation of an ant. Useful for debugging.
        Overrides:
        toString in class java.lang.Object
        Returns:
        An string with the ant's index an current solution.