Package libai.ants
Class Ant
- java.lang.Object
-
- libai.ants.Ant
-
public class Ant extends java.lang.ObjectThis 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 intcurrentPosCurrent Ant position, i.e.: the index of a node in the problem graphprotected intindexThis Ant's position in the Enviroment's Ants arrayprotected java.util.List<java.lang.Integer>solutionCurrent Ant solution
-
Constructor Summary
Constructors Modifier Constructor Description protectedAnt(int index, int initialPos)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSolution(int Solution)Ads a component to the ant's current Vector solutionvoidclearSolution()Clears the ant's current solutionjava.util.List<java.lang.Integer>copySolution()Returns a copy of the Vector with the ant's current solutionintgetCurrentPos()Returns the ant's current positionjava.util.List<java.lang.Integer>getSolution()Returns a reference to the Vector with the ant's current solutionintgetSolutionSize()Returns the size of the ant's current solutionvoidprintSolution()Prints the ant's current solution to the standard outputprotected voidsetCurrentPos(int pos)Sets the ant's current positionvoidsetSolution(java.util.List<java.lang.Integer> solution)Sets a Vector to be the ant's current solutionjava.lang.StringtoString()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:
toStringin classjava.lang.Object- Returns:
- An string with the ant's index an current solution.
-
-