net.sf.myra.framework
Class Ant

java.lang.Object
  extended by net.sf.myra.framework.Ant
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.lang.Comparable<Ant>, java.util.EventListener

public class Ant
extends java.lang.Object
implements java.beans.PropertyChangeListener, java.lang.Comparable<Ant>

This class represents an artificial ant.

Version:
$Revision$ $Date:: $
Author:
Fernando Esteban Barril Otero

Field Summary
static int MINIMUM_MEMORY_SIZE
          The minimum memory size allowed.
 
Constructor Summary
Ant(Colony colony)
          Creates a new ant.
Ant(Colony colony, int memory)
          Creates a new ant.
 
Method Summary
 int compareTo(Ant o)
           
 Trail getBestTrail()
          Returns the best trail constructed by the ant.
 java.util.List<Trail> getMemory()
          Returns the ordered (descendant order) ant trail memory list.
 Trail getTrail()
          Returns the current ant trail.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Updates the memory status when a trail has its cost associated.
 void setTrail(Trail trail)
          Sets the current ant trail.
 java.lang.String toString()
           
 Trail walk()
          Creates a new trail by walking in the problem construction graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MINIMUM_MEMORY_SIZE

public static final int MINIMUM_MEMORY_SIZE
The minimum memory size allowed.

See Also:
Constant Field Values
Constructor Detail

Ant

public Ant(Colony colony)
Creates a new ant.

Parameters:
colony - the colony of the ant.

Ant

public Ant(Colony colony,
           int memory)
Creates a new ant.

Parameters:
colony - the colony of the ant.
memory - the ant memory size.
Method Detail

walk

public Trail walk()
Creates a new trail by walking in the problem construction graph.


getMemory

public java.util.List<Trail> getMemory()
Returns the ordered (descendant order) ant trail memory list.

Returns:
the ordered ant trail memory list.

getTrail

public Trail getTrail()
Returns the current ant trail.

Returns:
the current ant trail.

getBestTrail

public Trail getBestTrail()
Returns the best trail constructed by the ant.

Returns:
the best trail constructed by the ant.

setTrail

public void setTrail(Trail trail)
Sets the current ant trail.

Parameters:
trail - the trail to set.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Updates the memory status when a trail has its cost associated.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - the PropertyChangeEvent instance.

compareTo

public int compareTo(Ant o)
Specified by:
compareTo in interface java.lang.Comparable<Ant>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2013. All Rights Reserved.