Leviathan_no_group
Leviathan Class Reference

#include <Leviathan.h>

Public Member Functions

 Leviathan (float delta_, float sigma_, unsigned int nbAgents_, unsigned int nbGossips_)
 
float borne (float value)
 
void step ()
 
void selectCoupleForInterraction (IdAgent &Ai, IdAgent &Aj)
 
void directInteraction (IdAgent Ai, IdAgent Aj)
 
void gossipInteraction (IdAgent Ai, IdAgent Aj)
 
void oneGossip (IdAgent Ai, IdAgent Aj)
 
void setAgentReputation (IdAgent Ai, float newReputation)
 
float getAverageOpinion ()
 
float getAverageOpinionTo (IdAgent a)
 
float getStdOpinion ()
 
float getStdOpinionTo (IdAgent a)
 
float getAverageStdOpinion ()
 
float getStdReputation ()
 
float getOpinion (IdAgent i, IdAgent j)
 
unsigned int getNbAgents ()
 
IdAgent getRandomAgent ()
 
void writeOpinions (std::string fileName)
 

Public Attributes

float delta
 
unsigned int gossip
 
float sigma
 
unsigned int nbStep
 
std::vector< Agentagents
 
bool useBorder
 
bool oneInteractionParStep
 
std::uniform_real_distribution< float > g_noise
 

Detailed Description

The class of the model : use step() to run Na random pair interactions, then use the getters and writeOpinions to have informations about the agents

Constructor & Destructor Documentation

◆ Leviathan()

Leviathan::Leviathan ( float  delta_,
float  sigma_,
unsigned int  nbAgents_,
unsigned int  nbGossips_ 
)

Constructor

Parameters
delta_the amplitude of the uniformly distributed errors in the reception of the opinions
sigma_defines the shape of the propagation function (the more sigma is small, the more the function is tilted)
nbAgents_number of agents in the simulation
nbGossips_the number of agents subject of gossip in each pair interaction

Member Function Documentation

◆ borne()

float Leviathan::borne ( float  value)

return the value limited between -1 and 1

◆ directInteraction()

void Leviathan::directInteraction ( IdAgent  Ai,
IdAgent  Aj 
)

run the direct interaction between Ai and Aj

Parameters
Aiid of the first agent of the direct interaction
Ajid of the second agent of the direct interaction

◆ getAverageOpinion()

float Leviathan::getAverageOpinion ( )

return the average of the opinions about agents

◆ getAverageOpinionTo()

float Leviathan::getAverageOpinionTo ( IdAgent  a)

return the average of the opinions about agent a

Parameters
athe id of the agent

◆ getAverageStdOpinion()

float Leviathan::getAverageStdOpinion ( )

return the average of the standard deviation of the opinion about each agent

◆ getNbAgents()

unsigned int Leviathan::getNbAgents ( )
inline

return the number of agents

◆ getOpinion()

float Leviathan::getOpinion ( IdAgent  i,
IdAgent  j 
)
inline

return the average of the opinions about the agents return the opinon of i about j

◆ getRandomAgent()

IdAgent Leviathan::getRandomAgent ( )
inline

return the id of a random agent

◆ getStdOpinion()

float Leviathan::getStdOpinion ( )

return the standard deviation of the opinions about agents

◆ getStdOpinionTo()

float Leviathan::getStdOpinionTo ( IdAgent  a)

return the standard deviation of the opinions about agent a

Parameters
athe id of the agent

◆ getStdReputation()

float Leviathan::getStdReputation ( )

return the standard deviation of the reputations of agents

◆ gossipInteraction()

void Leviathan::gossipInteraction ( IdAgent  Ai,
IdAgent  Aj 
)

run the gossips between Ai and Aj

Parameters
Aiid of the first agent of the direct interaction
Ajid of the second agent of the direct interaction

◆ oneGossip()

void Leviathan::oneGossip ( IdAgent  Ai,
IdAgent  Aj 
)

run the direct interaction between Ai and Aj

Parameters
Aiid of the agent who receives the gossip
Ajid of the agent who gossips

◆ selectCoupleForInterraction()

void Leviathan::selectCoupleForInterraction ( IdAgent &  Ai,
IdAgent &  Aj 
)

select two random agents for one interaction and put them in Ai and Aj

Parameters
Aiput the id of the first agent of the interaction in this value
Ajput the id of the second agent of the interaction in this value

◆ setAgentReputation()

void Leviathan::setAgentReputation ( IdAgent  Ai,
float  newReputation 
)

set the opinions of all agents about Ai equal to newReputation

Parameters
Aiid of the agent whose reputation is set
newReputationnew opinion of all agents about Ai

◆ step()

void Leviathan::step ( )

run one random pair interactions per agent

◆ writeOpinions()

void Leviathan::writeOpinions ( std::string  fileName)

write in a file the matrix of opinion (.csv format)

Parameters
thepath and the name of the output file to create

Member Data Documentation

◆ agents

std::vector<Agent> Leviathan::agents

the agents of the simulations

◆ delta

float Leviathan::delta

the amplitude of the uniformly distributed errors in the reception of the opinions

◆ g_noise

std::uniform_real_distribution<float> Leviathan::g_noise

random generator for the noise

◆ gossip

unsigned int Leviathan::gossip

the number of agents subject of gossip in each pair interaction

◆ nbStep

unsigned int Leviathan::nbStep

number of steps done yet (1 pair interaction per agent per step)

◆ oneInteractionParStep

bool Leviathan::oneInteractionParStep

if equal true : 1 interaction per step. If equal false : nb agent interaction per step (default value = true)

◆ sigma

float Leviathan::sigma

defines the shape of the propagation function (the more sigma is small, the more the function is tilted)

◆ useBorder

bool Leviathan::useBorder

if equal false, the opinions are not between -1 and 1 (default value = true)


The documentation for this class was generated from the following files: