es.ants.felixgm.trmsim_wsn.trm.lftm
Class LFTM_Ant

java.lang.Object
  extended by es.ants.felixgm.trmsim_wsn.trm.lftm.LFTM_Ant

public class LFTM_Ant
extends java.lang.Object

This class models an ant in the ant colony system. It includes the path being built by the ant, the service it is searching and the current average pheromone of the path.

Since:
0.4
Version:
0.4
Author:
Félix Gómez Mármol, Gregorio Martínez Pérez

Field Summary
protected  double averagePheromone
          Average pheromone of the current built path
protected  LFTM_Sensor client
          Client in the network requesting a certain service
protected  Service searchingService
          Service being searched by this ant
protected  java.util.Vector<LFTM_Sensor> solution
          Current built path of nodes leading to a server offering the desired service
protected  boolean solutionFound
          Boolean indicating if a solution has been found or not
protected  java.util.Vector<LFTM_Sensor> visitedSensors
          Collection of visited servers by this ant
 
Constructor Summary
LFTM_Ant(Service searchingService, LFTM_Sensor client)
          Class LFTM_Ant constructor
 
Method Summary
 void addSensor(LFTM_Sensor sensor)
          Adds a sensor to the solution of this ant and computes the average pheromone, and the average weighted pheromone
 double get_averagePheromone()
          Returns the average pheromone of the current built path
 java.util.Vector<LFTM_Sensor> get_solution()
          Returns the current built path of nodes leading to a server offering the desired service
 double getLastNodePheromone()
          Gets the pheromone of the last edge of the built path
 LFTM_Sensor getNextSensor(double alpha, double beta, double q0)
          Returns the next node to be visited by the ant
 boolean isSolutionFound()
          Indicates if a solution has been found or not
 LFTM_Sensor moveBack()
          The ant moves back until it finds a server offering the desired service or a server with more paths to explore or until it reaches the client it departed from
 void pheromoneGlobalUpdating(double phi, double rho, double maxGlobal)
          This method carries out the pheromone global updating of the best current path
 void pheromoneLocalUpdating(double phi, Sensor nextSensor)
          This method carries out the pheromone local updating of the edge connecting the current last server in the path and the next server passed as an argument
 void reset()
          Resets the ant to its initial state, with no path and no average pheromone
 void setSolutionFound()
          Sets the current path as a final solution.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

searchingService

protected Service searchingService
Service being searched by this ant


client

protected LFTM_Sensor client
Client in the network requesting a certain service


solution

protected java.util.Vector<LFTM_Sensor> solution
Current built path of nodes leading to a server offering the desired service


visitedSensors

protected java.util.Vector<LFTM_Sensor> visitedSensors
Collection of visited servers by this ant


averagePheromone

protected double averagePheromone
Average pheromone of the current built path


solutionFound

protected boolean solutionFound
Boolean indicating if a solution has been found or not

Constructor Detail

LFTM_Ant

public LFTM_Ant(Service searchingService,
                LFTM_Sensor client)
Class LFTM_Ant constructor

Parameters:
searchingService - The service desired by the client and searched by the LFTM_Ant
client - The client asking for the service
Method Detail

addSensor

public void addSensor(LFTM_Sensor sensor)
Adds a sensor to the solution of this ant and computes the average pheromone, and the average weighted pheromone

Parameters:
sensor - Sensor to add to the current path

moveBack

public LFTM_Sensor moveBack()
The ant moves back until it finds a server offering the desired service or a server with more paths to explore or until it reaches the client it departed from

Returns:
New current server to keep exploring from or null if it reaches a server offering the desired service

reset

public void reset()
Resets the ant to its initial state, with no path and no average pheromone


isSolutionFound

public boolean isSolutionFound()
Indicates if a solution has been found or not

Returns:
true if a final solution has been found by this ant, false otherwise

setSolutionFound

public void setSolutionFound()
Sets the current path as a final solution. After a call to this method, isSolutionFound returns true


getLastNodePheromone

public double getLastNodePheromone()
Gets the pheromone of the last edge of the built path

Returns:
The pheromone of the last edge of the built path

getNextSensor

public LFTM_Sensor getNextSensor(double alpha,
                                 double beta,
                                 double q0)
Returns the next node to be visited by the ant

Parameters:
alpha - Weight of the pheromone in the transition rule of the ant colony system
beta - Weight of the heuristic in the transition rule of the ant colony system
q0 - Probability of using a pseudo random proportional transition rule or a leading exploration transition rule
Returns:
The next server to visit according to the transition rule, or null if the current node has no more neighbors or if a loop has been made

pheromoneLocalUpdating

public void pheromoneLocalUpdating(double phi,
                                   Sensor nextSensor)
This method carries out the pheromone local updating of the edge connecting the current last server in the path and the next server passed as an argument

Parameters:
phi - Parameter phi, a constant within the interval [0,1]
nextSensor - Next server to visit by the ant

pheromoneGlobalUpdating

public void pheromoneGlobalUpdating(double phi,
                                    double rho,
                                    double maxGlobal)
This method carries out the pheromone global updating of the best current path

Parameters:
phi - Parameter phi, a constant within the interval [0,1]
rho - Parameter rho, a constant within the interval [0,1]
maxGlobal - Quality of the best current path

get_solution

public java.util.Vector<LFTM_Sensor> get_solution()
Returns the current built path of nodes leading to a server offering the desired service

Returns:
The current built path of nodes leading to a server offering the desired service

get_averagePheromone

public double get_averagePheromone()
Returns the average pheromone of the current built path

Returns:
The average pheromone of the current built path