es.ants.felixgm.trmsim_wsn.trm.eigentrust
Class EigenTrust_Sensor

java.lang.Object
  extended by es.ants.felixgm.trmsim_wsn.network.Sensor
      extended by es.ants.felixgm.trmsim_wsn.trm.eigentrust.EigenTrust_Sensor
All Implemented Interfaces:
java.lang.Runnable

public class EigenTrust_Sensor
extends Sensor

This class models a Sensor implementing EigenTrust

Since:
0.2
Version:
0.3
Author:
Félix Gómez Mármol, Gregorio Martínez Pérez and Antonio Bernárdez

Field Summary
protected static int _numSensors
          Number of sensors composing the network this sensor belongs to
protected static double[] _preTrustedPeersVector
          Vector p
protected static int _windowSize
          Window size for storing transactions outcomes
protected  double[] globalTrustVector
          Vector t
protected  java.util.Collection<EigenTrust_Sensor> interactedServers
          Collection of severs who this sensor has interacted with
protected  boolean isPreTrustedPeer
          Indicates if this sensor is a pre-trusted peer (true) or not (false)
protected  java.util.Collection<Transaction> transactions
          Collection of Transactions this sensor has had
 
Fields inherited from class es.ants.felixgm.trmsim_wsn.network.Sensor
_maxDistance, activeState, collusion, dynamic, id, idCount, links, numRequests, numRequestsThreshold, numRequestsTimer, outcome, requiredService, runningSimulation, servicesGoodness, sleepTimer, sleepTimerAux, transmittedDistance, trmmodelWSN, xPosition, yPosition
 
Constructor Summary
EigenTrust_Sensor()
          This constructor creates a new Sensor implementing EigenTrust
EigenTrust_Sensor(int id, double x, double y)
          This constructor creates a new Sensor implementing EigenTrust
 
Method Summary
 void addNewTransaction(EigenTrust_Sensor client, EigenTrust_Sensor server, Outcome outcome)
          This method adds a new Transaction to the collection of transactions of this sensor
 double[] get_globalTrustVector()
          Returns the current global trust vector t_i^k
static double[] get_preTrustedPeersVector()
          Returns the current pre-trusted peers vector p
 double getNormalizedLocalTrustValue(EigenTrust_Sensor server)
          This method computes the normalized local trust value c_{ij}\in[0,1]
static int getNumSensors()
          Returns the number of sensors composing the network this sensor belongs to
 boolean isPreTrustedPeer()
          Indicates if this sensor is a pre-trusted peer (true) or not (false)
 void reset()
          This method resets a Sensor to its initial state
 void set_globalTrustVector(double[] globalTrustVector)
          Sets the new global trust vector t_i^{k+1}
static void set_preTrustedPeersVector(double[] preTrustedPeersVector)
          Sets the new pre-trusted peers vector p
static void set_windowSize(int windowSize)
          Sets the window size for storing transactions outcomes
static void setNumSensors(int numSensors)
          Sets the number of sensors composing the network this sensor belongs to
 void setPreTrustedPeer(boolean isPreTrustedPeer)
          Sets this senor as a pre-trusted peer or not
 
Methods inherited from class es.ants.felixgm.trmsim_wsn.network.Sensor
addLink, addService, addTransmittedDistance, cancelAllTimers, distance, distanceInHops, equals, findSensors, get_goodness, get_numServices, get_outcome, get_requiredService, get_services, get_transmittedDistance, get_TRModel_WSN, getNeighbors, getService, getX, getY, id, isActive, isNeighbor, isRunningSimulation, offersService, offersService, removeAllNeighbors, removeLink, removeService, resetId, run, serve, set_goodness, set_requiredService, set_TRModel_WSN, setActiveState, setCollusion, setDynamic, setMaxDistance, setRunningSimulation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_numSensors

protected static int _numSensors
Number of sensors composing the network this sensor belongs to


_windowSize

protected static int _windowSize
Window size for storing transactions outcomes


transactions

protected java.util.Collection<Transaction> transactions
Collection of Transactions this sensor has had


globalTrustVector

protected double[] globalTrustVector
Vector t


_preTrustedPeersVector

protected static double[] _preTrustedPeersVector
Vector p


interactedServers

protected java.util.Collection<EigenTrust_Sensor> interactedServers
Collection of severs who this sensor has interacted with


isPreTrustedPeer

protected boolean isPreTrustedPeer
Indicates if this sensor is a pre-trusted peer (true) or not (false)

Constructor Detail

EigenTrust_Sensor

public EigenTrust_Sensor()
This constructor creates a new Sensor implementing EigenTrust


EigenTrust_Sensor

public EigenTrust_Sensor(int id,
                         double x,
                         double y)
This constructor creates a new Sensor implementing EigenTrust

Parameters:
id - Identifier of the new sensor
x - X coordinate of the new sensor
y - Y coordinate of the new sensor
Method Detail

getNormalizedLocalTrustValue

public double getNormalizedLocalTrustValue(EigenTrust_Sensor server)
This method computes the normalized local trust value c_{ij}\in[0,1]

Parameters:
server - Server j
Returns:
c_{ij}

addNewTransaction

public void addNewTransaction(EigenTrust_Sensor client,
                              EigenTrust_Sensor server,
                              Outcome outcome)
This method adds a new Transaction to the collection of transactions of this sensor

Parameters:
client - The client who requested the service
server - The server who provided the service
outcome - Outcome of the trnsaction to be added

reset

public void reset()
Description copied from class: Sensor
This method resets a Sensor to its initial state

Specified by:
reset in class Sensor

set_globalTrustVector

public void set_globalTrustVector(double[] globalTrustVector)
Sets the new global trust vector t_i^{k+1}

Parameters:
globalTrustVector - New global trust vector t_i^{k+1}

get_globalTrustVector

public double[] get_globalTrustVector()
Returns the current global trust vector t_i^k

Returns:
The current global trust vector t_i^k

set_preTrustedPeersVector

public static void set_preTrustedPeersVector(double[] preTrustedPeersVector)
Sets the new pre-trusted peers vector p

Parameters:
preTrustedPeersVector - New pre-trusted peers vector p

get_preTrustedPeersVector

public static double[] get_preTrustedPeersVector()
Returns the current pre-trusted peers vector p

Returns:
The current pre-trusted peers vector p

getNumSensors

public static int getNumSensors()
Returns the number of sensors composing the network this sensor belongs to

Returns:
The number of sensors composing the network this sensor belongs to

isPreTrustedPeer

public boolean isPreTrustedPeer()
Indicates if this sensor is a pre-trusted peer (true) or not (false)

Returns:
true if this sensor is a pre-trusted peer, false otherwise

setNumSensors

public static void setNumSensors(int numSensors)
Sets the number of sensors composing the network this sensor belongs to

Parameters:
numSensors - The number of sensors composing the network this sensor belongs to

set_windowSize

public static void set_windowSize(int windowSize)
Sets the window size for storing transactions outcomes

Parameters:
windowSize - New window size for storing transactions outcomes

setPreTrustedPeer

public void setPreTrustedPeer(boolean isPreTrustedPeer)
Sets this senor as a pre-trusted peer or not

Parameters:
isPreTrustedPeer - true if this sensor is to be a pre-trusted peer, false otherwise