org.ocopomo.endorsement
Class EndorserAgent

java.lang.Object
  extended by org.ocopomo.drams.modelling.Agent
      extended by org.ocopomo.endorsement.EndorserAgent
All Implemented Interfaces:
org.ocopomo.drams.modelling.IAgent

public abstract class EndorserAgent
extends org.ocopomo.drams.modelling.Agent

This abstract class contains methods useful for the management of the endorsements: agent-classes that need to use endorsements should extend this class.

Author:
Francesco Poggi, Scott Moss

Constructor Summary
EndorserAgent(java.lang.String name, EndorserModel model)
           
 
Method Summary
 void addEndorsementFact(org.ocopomo.drams.modelling.Agent endorsee, java.lang.String endorsement, EndorsementScheme scheme)
          Add a new endorsement to the agent's fact base using the current tick.
 void addEndorsementFact(org.ocopomo.drams.modelling.Agent endorsee, java.lang.String endorsement, EndorsementScheme scheme, double tick)
          Add a new endorsement to the agent's fact base using the specified tick.
 void addEndorsementScheme(java.lang.String schemeName, EndorsementScheme scheme)
           
 int doubleToInt(double val)
          In DRAMS the evaluation of a math expression returns a double.
 java.lang.Double endorsementsValue(java.lang.Object[] endorsements, java.lang.String schemeName)
          Returns a double that represents the evaluation of the ArrayList of endorsement-Objects in input in relation to the endorsement scheme named schemeName.
 java.lang.Double endorsementsValue(java.lang.String[] endorsements, java.lang.String schemeName)
          Returns a double that represents the evaluation of the array of endorsements in input in relation to the endorsement scheme named schemeName.
 void generateRandomEndorsement(org.ocopomo.drams.modelling.Agent agent, EndorsementScheme scheme)
          Adds to this agent's fact base a random endorsement chosen inside the scheme given in input relative to the endorsee agent
 void generateRandomEndorsement(java.lang.String schemeName, org.ocopomo.drams.modelling.Agent endorsee)
          Adds to this agent's fact base a random endorsement chosen inside the scheme given in input relative to the endorsee agent
 void generateRandomEndorsements(java.util.ArrayList<? extends org.ocopomo.drams.modelling.Agent> researchCentreList, java.lang.String schemeName)
          Generate random endorsements relative to an endorsement scheme for the agents given in input.
 EndorsementScheme getEndorsementScheme(java.lang.String endSchemeName)
          Search for the endorsement scheme named endSchemeName inside the endorsement dictionary
 int nextInt(int val)
          In DRAMS the evaluation of a math expression returns a double.
static java.util.ArrayList<? extends org.ocopomo.drams.modelling.Agent> selectRandomAgents(java.util.ArrayList<? extends org.ocopomo.drams.modelling.Agent> agentList)
           
 void setBeneconModel(EndorserModel m)
           
 
Methods inherited from class org.ocopomo.drams.modelling.Agent
getFactBase, getName, getRuleBase
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EndorserAgent

public EndorserAgent(java.lang.String name,
                     EndorserModel model)
Method Detail

addEndorsementScheme

public void addEndorsementScheme(java.lang.String schemeName,
                                 EndorsementScheme scheme)

setBeneconModel

public void setBeneconModel(EndorserModel m)

addEndorsementFact

public void addEndorsementFact(org.ocopomo.drams.modelling.Agent endorsee,
                               java.lang.String endorsement,
                               EndorsementScheme scheme)
Add a new endorsement to the agent's fact base using the current tick.

Parameters:
endorsee - The endorsee of the new endorsement
endorsement - The new endorsement (token-value inside the endorsement scheme) to be added
scheme - The scheme to be used to evaluate the new endorsement

addEndorsementFact

public void addEndorsementFact(org.ocopomo.drams.modelling.Agent endorsee,
                               java.lang.String endorsement,
                               EndorsementScheme scheme,
                               double tick)
Add a new endorsement to the agent's fact base using the specified tick.

Parameters:
endorsee - The endorsee of the new endorsement
endorsement - The new endorsement (token-value inside the endorsement scheme) to be added
scheme - The scheme to be used to evaluate the new endorsement
tick - The tick to be used for the new endorsement fact

generateRandomEndorsement

public void generateRandomEndorsement(org.ocopomo.drams.modelling.Agent agent,
                                      EndorsementScheme scheme)
                               throws java.lang.Exception
Adds to this agent's fact base a random endorsement chosen inside the scheme given in input relative to the endorsee agent

Parameters:
agent - The endorsee of the endorsement
scheme - The scheme within which the endorsement token has to be choosen
Throws:
java.lang.Exception - A generic exception caused by wrong arguments passing

generateRandomEndorsement

public void generateRandomEndorsement(java.lang.String schemeName,
                                      org.ocopomo.drams.modelling.Agent endorsee)
Adds to this agent's fact base a random endorsement chosen inside the scheme given in input relative to the endorsee agent

Parameters:
agent - The endorsee of the endorsement
scheme - The name of the scheme within which the endorsement token has to be chosen
Throws:
java.lang.Exception - A generic exception caused by wrong arguments passing

selectRandomAgents

public static java.util.ArrayList<? extends org.ocopomo.drams.modelling.Agent> selectRandomAgents(java.util.ArrayList<? extends org.ocopomo.drams.modelling.Agent> agentList)

generateRandomEndorsements

public void generateRandomEndorsements(java.util.ArrayList<? extends org.ocopomo.drams.modelling.Agent> researchCentreList,
                                       java.lang.String schemeName)
Generate random endorsements relative to an endorsement scheme for the agents given in input. The random process is performed as follows: for each agent in input 1. the probability to be known is 50% 2. if the agent is known, a number of random endorsement between 0 and the number of endorsements within the scheme are generated

Parameters:
researchCentreList - A list containing the agent for wich to generate random endorsements
schemeName - The name of the scheme to use. the endorsements are generated randomly among the endorsements contained inside this scheme.

endorsementsValue

public java.lang.Double endorsementsValue(java.lang.String[] endorsements,
                                          java.lang.String schemeName)
Returns a double that represents the evaluation of the array of endorsements in input in relation to the endorsement scheme named schemeName.

Parameters:
endorsements - An array containing the name of the endorsements
schemeName - The name of the endorsement scheme
Returns:
the evaluation of the endorsements in input if the scheme exists, null otherwise.

endorsementsValue

public java.lang.Double endorsementsValue(java.lang.Object[] endorsements,
                                          java.lang.String schemeName)
Returns a double that represents the evaluation of the ArrayList of endorsement-Objects in input in relation to the endorsement scheme named schemeName.

Parameters:
endorsements - An array of Objects containing the name of the endorsements
schemeName - The name of the endorsement scheme
Returns:
the evaluation of the endorsements in input if the scheme exists, null otherwise.

getEndorsementScheme

public EndorsementScheme getEndorsementScheme(java.lang.String endSchemeName)
Search for the endorsement scheme named endSchemeName inside the endorsement dictionary

Parameters:
endSchemeName - the name of the scheme
Returns:
returns the endorsement scheme named endSchemeName if present inside the dictionary, null otherwise.

nextInt

public int nextInt(int val)
In DRAMS the evaluation of a math expression returns a double. This method calculates the next of an int value (is {val + 1} ) in DRAMS returns a double

Parameters:
val -
Returns:
val + 1

doubleToInt

public int doubleToInt(double val)
In DRAMS the evaluation of a math expression returns a double. This method converts a double to an int

Parameters:
val - The double to be converted
Returns:
The double obtained by converting val to double