trust_system_lib
Class EigenTM

java.lang.Object
  extended by trust_system_lib.EigenTM
All Implemented Interfaces:
TrustAlg
Direct Known Subclasses:
EtIncTM

public class EigenTM
extends java.lang.Object
implements TrustAlg

The EigenTM class conforms to the TrustAlg interface and implements the EigenTrust algorithm as described by Hector Garcia-molina, et. al.


Field Summary
private  double ALPHA
          Weighting constant making pre-trusted peers more powerful
private  double EPSILON
          Acceptable error margin in convergence tests.
private  double[][] normalized
          Matrix storing persistent normalized (pre-multiplication) values.
protected  Network nw
          The Network which this EigenTM is managing.
private  double[] pretrust
          Pre-trusted peer distribution and weighting vector
private  double[] vectorA
          Scratch space vector for multiplication purposes.
private  double[] vectorB
          Scratch space vector for multiplication purposes.
 
Constructor Summary
EigenTM(Network nw)
          Construct an EigenTM object.
 
Method Summary
 java.lang.String algName()
          Interfaced: Text name of this trust algorithm (spaces are okay).
private  int calcGlobalFBackInt(Relation rel)
          Calculate a 'feedback integer' using global feedback data.
 void computeTrust(int user, int cycle)
          Interfaced: Compute trust, exporting trust values to Network.
private  double[] constantVectorMult(double constant, double[] vector)
          Linear Algebra: Constant-vector multiplication.
 java.lang.String fileExtension()
          Interfaced: File extension placed on output files using this algorithm.
protected  boolean hasConverged(double[] vec1, double[] vec2)
          Test if the difference between two vectors is below some threshold.
private  void normalizeVector(int new_vec)
          Normalize a single vector of the persistent matrix.
private  double[] singleMultiply(double[] prev_vector)
          Perform a single multiplication iteration per EigenTrust specification.
protected  double[] trustMultiply(int user, int max_iters)
          Perform matrix multiply as a means of aggregating global trust data.
 void update(Transaction trans)
          Interfaced: Given coordinates of a feedback commitment, update as needed.
private  double[] vectorAdd(double[] vector1, double[] vector2)
          Linear Algebra: Vector-vector addition.
private  double[] vectorMatrixMult(double[] vector, double[][] matrix)
          Linear Algebra: Vector-matrix multiplication.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nw

protected Network nw
The Network which this EigenTM is managing.


ALPHA

private final double ALPHA
Weighting constant making pre-trusted peers more powerful

See Also:
Constant Field Values

EPSILON

private final double EPSILON
Acceptable error margin in convergence tests.

See Also:
Constant Field Values

pretrust

private double[] pretrust
Pre-trusted peer distribution and weighting vector


vectorA

private double[] vectorA
Scratch space vector for multiplication purposes.


vectorB

private double[] vectorB
Scratch space vector for multiplication purposes.


normalized

private double[][] normalized
Matrix storing persistent normalized (pre-multiplication) values.

Constructor Detail

EigenTM

public EigenTM(Network nw)
Construct an EigenTM object.

Parameters:
nw - Network which this EigenTM will be managing
Method Detail

algName

public java.lang.String algName()
Interfaced: Text name of this trust algorithm (spaces are okay).

Specified by:
algName in interface TrustAlg
Returns:
Text name of this trust algorithm (spaces are okay)

fileExtension

public java.lang.String fileExtension()
Interfaced: File extension placed on output files using this algorithm.

Specified by:
fileExtension in interface TrustAlg
Returns:
File extension placed on output files using this algorithm

update

public void update(Transaction trans)
Interfaced: Given coordinates of a feedback commitment, update as needed.

Specified by:
update in interface TrustAlg
Parameters:
trans - Transaction detailing feedback commitment

computeTrust

public void computeTrust(int user,
                         int cycle)
Interfaced: Compute trust, exporting trust values to Network.

Specified by:
computeTrust in interface TrustAlg
Parameters:
user - Identifier of user performing trust computation
cycle - The current cycle

trustMultiply

protected double[] trustMultiply(int user,
                                 int max_iters)
Perform matrix multiply as a means of aggregating global trust data.

Parameters:
user - Identifier of user performing trust computation
max_iters - Maximum number of multiplications to perform
Returns:
The converged global trust vector

hasConverged

protected boolean hasConverged(double[] vec1,
                               double[] vec2)
Test if the difference between two vectors is below some threshold.

Parameters:
vec1 - The first vector for comparison
vec2 - The second vector for comparison
Returns:
TRUE if variance < EPSILON at every position. FALSE otherwise.

normalizeVector

private void normalizeVector(int new_vec)
Normalize a single vector of the persistent matrix.

Parameters:
new_vec - The vector to be normalized

calcGlobalFBackInt

private int calcGlobalFBackInt(Relation rel)
Calculate a 'feedback integer' using global feedback data.

Parameters:
rel - Relation whose 'feedback integer' needs calculated
Returns:
The calculated 'feedback integer'

singleMultiply

private double[] singleMultiply(double[] prev_vector)
Perform a single multiplication iteration per EigenTrust specification.

Parameters:
prev_vector - Result of the last multiplication iteration
Returns:
A vector closer to converged global trust than that passed in

vectorMatrixMult

private double[] vectorMatrixMult(double[] vector,
                                  double[][] matrix)
Linear Algebra: Vector-matrix multiplication.

Parameters:
vector - Vector to be multiplied
matrix - Matrix to be multiplied
Returns:
The product vector*matrix, per standard matrix multiply

constantVectorMult

private double[] constantVectorMult(double constant,
                                    double[] vector)
Linear Algebra: Constant-vector multiplication.

Parameters:
constant - Constant to be multiplied
vector - Vector to be multiplied
Returns:
The product constant*vector, per standard scalar multiply

vectorAdd

private double[] vectorAdd(double[] vector1,
                           double[] vector2)
Linear Algebra: Vector-vector addition.

Parameters:
vector1 - First vector to be added
vector2 - Second vector to be added
Returns:
The sum vector1+vector2, per standard vector addition