Package libai.ants
Class Ant
- java.lang.Object
-
- libai.ants.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 graphprotected int
index
This Ant's position in the Enviroment's Ants arrayprotected 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 solutionvoid
clearSolution()
Clears the ant's current solutionjava.util.List<java.lang.Integer>
copySolution()
Returns a copy of the Vector with the ant's current solutionint
getCurrentPos()
Returns the ant's current positionjava.util.List<java.lang.Integer>
getSolution()
Returns a reference to the Vector with the ant's current solutionint
getSolutionSize()
Returns the size of the ant's current solutionvoid
printSolution()
Prints the ant's current solution to the standard outputprotected void
setCurrentPos(int pos)
Sets the ant's current positionvoid
setSolution(java.util.List<java.lang.Integer> solution)
Sets a Vector to be the ant's current solutionjava.lang.String
toString()
Return the string representation of an ant.
-
-
-
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 classjava.lang.Object
- Returns:
- An string with the ant's index an current solution.
-
-