ants.messor
Class ArrayMessorPheromone

java.lang.Object
  |
  +--ants.messor.ArrayMessorPheromone
All Implemented Interfaces:
Clearable, MessorPheromone, ResourceManager, Storage

public class ArrayMessorPheromone
extends Object
implements MessorPheromone

Version:
$Revision: 1.2 $
Author:
Alberto Montresor

Field Summary
static String PAR_CAPACITY
          Parameter name used to read PheromoneCapacity
static String PAR_MAXVISITS
          Parameter name used to read max visits
static String PAR_MINVISITS
          Parameter name used to read visits
static String PAR_TIMERANGE
          Parameter name used to read TimeRange
 
Fields inherited from interface ants.messor.MessorPheromone
NAME
 
Fields inherited from interface anthill.storage.Storage
DOC_STORAGE, PHR_STORAGE, URL_STORAGE
 
Constructor Summary
ArrayMessorPheromone(Factory factory, String name)
          Creates a new ArrayMessorPheromone, with the specified capacity.
 
Method Summary
 void addNest(NestId id, int load)
          Add the specified node and its associated load to the pheromone table.
 void clear()
          Restores the object to its initial state.
 PheromoneEntry[] getEntryTable()
          Add the nest identifiers contained in the nest to the set identified
 NestId getNextMaxNest(double deviation)
          Returns the next nest to be followed, depending on some parameters and on the content of the storage.
 NestId getNextMinNest(double deviation)
          Returns the next nest to be followed, depending on some parameters and on the content of the storage.
 NestId getRandomNest()
           
 boolean isOverladed()
          Returns true if the node is overloaded by ants, that have to be removed from the nest.
 boolean isUnderloaded()
          If the number of visits is smaller than the minimum amount of visits to be received, returns the number of missing visits.
 void update(NestId local, Neighbour[] nests)
           
 void update(NestId local, NestId[] nests, int[] loads)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PAR_CAPACITY

public static final String PAR_CAPACITY
Parameter name used to read PheromoneCapacity

See Also:
Constant Field Values

PAR_TIMERANGE

public static final String PAR_TIMERANGE
Parameter name used to read TimeRange

See Also:
Constant Field Values

PAR_MAXVISITS

public static final String PAR_MAXVISITS
Parameter name used to read max visits

See Also:
Constant Field Values

PAR_MINVISITS

public static final String PAR_MINVISITS
Parameter name used to read visits

See Also:
Constant Field Values
Constructor Detail

ArrayMessorPheromone

public ArrayMessorPheromone(Factory factory,
                            String name)
Creates a new ArrayMessorPheromone, with the specified capacity. Three sorted sets/maps of entries are created, in order to keep entries ordered by ascending loads, descending loads and by lru arrival time. Furthermore, a linear array of entries is also maintained, to enable to randomly select a nest in constant time.

Parameters:
factory - the factory to be used to read configuration arguments and to create other configurable objects
name - the name that is associated to this instance in the configuration file
Method Detail

clear

public void clear()
Restores the object to its initial state.

Specified by:
clear in interface Clearable

addNest

public void addNest(NestId id,
                    int load)
Description copied from interface: MessorPheromone
Add the specified node and its associated load to the pheromone table.

Specified by:
addNest in interface MessorPheromone

getNextMaxNest

public NestId getNextMaxNest(double deviation)
Returns the next nest to be followed, depending on some parameters and on the content of the storage.

Specified by:
getNextMaxNest in interface MessorPheromone

getNextMinNest

public NestId getNextMinNest(double deviation)
Returns the next nest to be followed, depending on some parameters and on the content of the storage.

Specified by:
getNextMinNest in interface MessorPheromone

getRandomNest

public NestId getRandomNest()
Specified by:
getRandomNest in interface MessorPheromone

update

public void update(NestId local,
                   NestId[] nests,
                   int[] loads)
Specified by:
update in interface MessorPheromone

update

public void update(NestId local,
                   Neighbour[] nests)
Specified by:
update in interface MessorPheromone

isUnderloaded

public boolean isUnderloaded()
If the number of visits is smaller than the minimum amount of visits to be received, returns the number of missing visits. Return 0 otherwise.

Specified by:
isUnderloaded in interface MessorPheromone

isOverladed

public boolean isOverladed()
Returns true if the node is overloaded by ants, that have to be removed from the nest.

Specified by:
isOverladed in interface MessorPheromone

getEntryTable

public PheromoneEntry[] getEntryTable()
Add the nest identifiers contained in the nest to the set identified

Specified by:
getEntryTable in interface MessorPheromone