📄 antroutingentry.java
字号:
package dk.itu.nulx30.networkModel;
/**
* An <code>AntRoutingEntry</code> contains a wire and a pheromone value and is
* the basic element saved in a <code>RoutingTable</code> (one for each
* destination for each outgoing queue).
*
* @author Mikkel Bundgaard
* @author Troels C. Damgaard
* @author Federico Decara
* @author Jacob W. Winther
*
* @see RoutingTable
*/
public class AntRoutingEntry {
/** the wire to route by*/
private Wire outputWire;
/** the pheromone value of this choice*/
private double pheromoneValue;
/**
* the initial trail value in an entry (some small constant greater than 0)
*/
private static final double INITIAL_PHEROMONE_VALUE = 10.0;
/**
* Class constructor for this class which takes an wire as argument.
*
* @param wire the wire of this entry
*/
public AntRoutingEntry( Wire wire ) {
outputWire = wire;
// Initialize pheromonevalue to the constant INITIAL_PHEROMONE_VALUE
pheromoneValue = INITIAL_PHEROMONE_VALUE;
}
/**
* Accessor method for the wire of this object.
*
* @return the wire of this entry
*/
public Wire getWire() {
return outputWire;
}
/**
* Accessor method for pheromoneValue.
*
* @return the pheromone value of this entry
*/
public double getPheromoneValue() {
return pheromoneValue;
}
/**
* Sets the value of the pheromone to the value given as argument.
*
* @param newVal the new pheromone value for this entry
*/
public void setPheromoneValue( double newVal ) {
pheromoneValue = newVal;
}
/**
* Adds the value given as argument to the current value of the pheromone.
*
* @param toAdd the value to add to the pheromone value
*/
public void incrementPheromoneValue( double toAdd ) {
pheromoneValue += toAdd;
}
/**
* Evaporates the pheromone value by multiplying it with a factor
*
* @param factor the factor to multiply the pheromone value with
*/
public void evaporatePheromoneValue( double factor ) {
pheromoneValue *= factor;
}
/**
* Provides a string representation of this object.
*
* @return a string representation of this
* <code>AntRoutingEntry</code>. The string representation contains a
* string representation of the wire and of the pheromone value.
*/
public String toString() {
return new StringBuffer( "( " + outputWire + " ) : " +
pheromoneValue + "\t" ).toString();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -