Class PherMatrix

java.lang.Object
  extended by PherMatrix

public class PherMatrix
extends java.lang.Object

PherMatrix keep tracks of the pheromone values for individual moves and updates them as requested. Pheromone values are used in determining the atractiveness of a certain move.


Field Summary
 ACS acsLocal
           
 double CONSTANTQ
           
 int[][] distances
           
 Node[] nodes
           
 double PHEREVAP
           
 double[][] pherValues
           
 double[] resetValues
           
 int[] valids
           
 
Constructor Summary
PherMatrix(ACS acs)
           
 
Method Summary
 void addNode(int n)
          Notifies PherMatrix of a node addition.
 void addNodeDistanceBased(int n)
          Notifies PherMatrix of a node addition.
 void addPher(Route route)
          Adds pheromone to the arcs that compose the given route.
 void addPherACS(Route route)
          Adds pheromone to the arcs that compose the given route, based on ACS implementation.
 void adjustMinMax(double lower, double upper)
          Modifies pheromone values such that they fall between a lower and upper value.
 void arcCrossed(int n, int k)
          Removes pheromone from an arc, based on ACS implementation.
 void evaporatePher()
          Evaporates all pheromone values.
 double findMaxDistance()
          Debugging method to view largest pheromone value.
 double findMinDistance()
          Debugging method to view smallest pheromone value.
 double findPherAverage()
          Debugging method to view average pheromone value.
 HashRoute getPossiblesHash()
          Creates a hashroute containing all the avaliable nodes to move to.
 int greatestDistanceFromNode(int r)
          Helper method for node addition/removal.
 void implementResetValues()
          Resets all pheromone based on their individual reset values.
 void intializePherValues()
          Intializes the pheromone matrix.
 void removeNode(int n)
          Notifies PherMatrix of a node removal.
 void resetProblem()
          Resets all pheromone to their intial values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

public Node[] nodes

valids

public int[] valids

resetValues

public double[] resetValues

distances

public int[][] distances

pherValues

public double[][] pherValues

CONSTANTQ

public double CONSTANTQ

PHEREVAP

public double PHEREVAP

acsLocal

public ACS acsLocal
Constructor Detail

PherMatrix

public PherMatrix(ACS acs)
Method Detail

intializePherValues

public void intializePherValues()
Intializes the pheromone matrix. Since all problems are symmetric, pheromone[r][c] = pheromone[c][r]. All pheromone values are intially the constant 1/(n-1), where n is the problem size.


getPossiblesHash

public HashRoute getPossiblesHash()
Creates a hashroute containing all the avaliable nodes to move to. The set of valid nodes changes for dyanmic problems

Returns:
HashRoute containing all valid nodes

evaporatePher

public void evaporatePher()
Evaporates all pheromone values. Evaporation is given by the equation: pherValues[r][c] = pherValues[r][c]*(1-PHEREVAP), where PHEREVAP is a constant. Not used in ACS implementation.


addPher

public void addPher(Route route)
Adds pheromone to the arcs that compose the given route. The amount of pheromone added is proportional to the inverse of the given route.

Parameters:
route - The route that pheromone is added to

addPherACS

public void addPherACS(Route route)
Adds pheromone to the arcs that compose the given route, based on ACS implementation. In ACS, the amount of pheromone added is a constant (.25*PHEREVAP).

Parameters:
route - The route that pheromone is added to

arcCrossed

public void arcCrossed(int n,
                       int k)
Removes pheromone from an arc, based on ACS implementation. Called by Agents after they cross that particular arc.

Parameters:
n - First node of the arc
k - Second node of the arc

adjustMinMax

public void adjustMinMax(double lower,
                         double upper)
Modifies pheromone values such that they fall between a lower and upper value. Not used in ACS implementation.

Parameters:
lower - The lower limit on pheromone
upper - The upper limit on pheromone

removeNode

public void removeNode(int n)
Notifies PherMatrix of a node removal. PherMatrix keeps track of the proximity of all other nodes to the removed node, since that information is needed in distance-based reseting. For dynamic problems only.

Parameters:
n - The node removed

addNode

public void addNode(int n)
Notifies PherMatrix of a node addition. For dynamic problems only.

Parameters:
n - The node added
See Also:
addNodeDistanceBased(int n)

addNodeDistanceBased

public void addNodeDistanceBased(int n)
Notifies PherMatrix of a node addition. PherMatrix keeps track of the proximity of all other nodes to the added node, since that information is needed in distance-based reseting. For dynamic problems only.

Parameters:
n - The node added

greatestDistanceFromNode

public int greatestDistanceFromNode(int r)
Helper method for node addition/removal.

Parameters:
r - The node being added/removed
Returns:
The greatest distance from node r to another node

resetProblem

public void resetProblem()
Resets all pheromone to their intial values. Effectively drops all gained information about the problem.


implementResetValues

public void implementResetValues()
Resets all pheromone based on their individual reset values. Reset values are found during node addition and removal steps. Keeps gained information about the problem based on distance from changes.


findPherAverage

public double findPherAverage()
Debugging method to view average pheromone value.

Returns:
The average pheromone value

findMaxDistance

public double findMaxDistance()
Debugging method to view largest pheromone value.

Returns:
The largest pheromone value

findMinDistance

public double findMinDistance()
Debugging method to view smallest pheromone value.

Returns:
The smallest pheromone value