Leviathan_no_group
|
#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< Agent > | agents |
bool | useBorder |
bool | oneInteractionParStep |
std::uniform_real_distribution< float > | g_noise |
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
Leviathan::Leviathan | ( | float | delta_, |
float | sigma_, | ||
unsigned int | nbAgents_, | ||
unsigned int | nbGossips_ | ||
) |
Constructor
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 |
float Leviathan::borne | ( | float | value | ) |
return the value limited between -1 and 1
void Leviathan::directInteraction | ( | IdAgent | Ai, |
IdAgent | Aj | ||
) |
run the direct interaction between Ai and Aj
Ai | id of the first agent of the direct interaction |
Aj | id of the second agent of the direct interaction |
float Leviathan::getAverageOpinion | ( | ) |
return the average of the opinions about agents
float Leviathan::getAverageOpinionTo | ( | IdAgent | a | ) |
return the average of the opinions about agent a
a | the id of the agent |
float Leviathan::getAverageStdOpinion | ( | ) |
return the average of the standard deviation of the opinion about each agent
|
inline |
return the number of agents
|
inline |
return the average of the opinions about the agents return the opinon of i about j
|
inline |
return the id of a random agent
float Leviathan::getStdOpinion | ( | ) |
return the standard deviation of the opinions about agents
float Leviathan::getStdOpinionTo | ( | IdAgent | a | ) |
return the standard deviation of the opinions about agent a
a | the id of the agent |
float Leviathan::getStdReputation | ( | ) |
return the standard deviation of the reputations of agents
void Leviathan::gossipInteraction | ( | IdAgent | Ai, |
IdAgent | Aj | ||
) |
run the gossips between Ai and Aj
Ai | id of the first agent of the direct interaction |
Aj | id of the second agent of the direct interaction |
void Leviathan::oneGossip | ( | IdAgent | Ai, |
IdAgent | Aj | ||
) |
run the direct interaction between Ai and Aj
Ai | id of the agent who receives the gossip |
Aj | id of the agent who gossips |
void Leviathan::selectCoupleForInterraction | ( | IdAgent & | Ai, |
IdAgent & | Aj | ||
) |
select two random agents for one interaction and put them in Ai and Aj
Ai | put the id of the first agent of the interaction in this value |
Aj | put the id of the second agent of the interaction in this value |
void Leviathan::setAgentReputation | ( | IdAgent | Ai, |
float | newReputation | ||
) |
set the opinions of all agents about Ai equal to newReputation
Ai | id of the agent whose reputation is set |
newReputation | new opinion of all agents about Ai |
void Leviathan::step | ( | ) |
run one random pair interactions per agent
void Leviathan::writeOpinions | ( | std::string | fileName | ) |
write in a file the matrix of opinion (.csv format)
the | path and the name of the output file to create |
std::vector<Agent> Leviathan::agents |
the agents of the simulations
float Leviathan::delta |
the amplitude of the uniformly distributed errors in the reception of the opinions
std::uniform_real_distribution<float> Leviathan::g_noise |
random generator for the noise
unsigned int Leviathan::gossip |
the number of agents subject of gossip in each pair interaction
unsigned int Leviathan::nbStep |
number of steps done yet (1 pair interaction per agent per step)
bool Leviathan::oneInteractionParStep |
if equal true : 1 interaction per step. If equal false : nb agent interaction per step (default value = true)
float Leviathan::sigma |
defines the shape of the propagation function (the more sigma is small, the more the function is tilted)
bool Leviathan::useBorder |
if equal false, the opinions are not between -1 and 1 (default value = true)