Documentation - PGiagkoulas/a9_fake_news_simulator GitHub Wiki
Detailed documentation of the project files and properties.
First the Agent class attributes:
- opinion: integer number in {-1, 0, 1}. Represents the agents opinion on a subject. -1 supports the "fake news" version, 1 supports the "true facts" and 0 is neutral and has not formed an opinion yet.
- opinion_base: A dictionary with the agent's id as key (id is the order in which an agent was generated for the simulation) and their opinions as values. The values are initialized as Null.
- skepticism: float number in [0, 1] that represents how difficult it is for the agent to change her opinion. The higher the value, the more difficult it is. Experts and liars have a skepticism value of 1 while the skepticism value of regulars is randomly selected from a normal distribution with mean 0.5 and standard deviation 0.1.
- persuasiveness: float number in [0, 1] that represents how convincing an agent is during an interaction. The higher the value, the more convincing the agent is. Experts have a persuasiveness value of 1 while the persuasiveness value of regulars and liars is randomly selected from a normal distribution with mean 0.5 and standard deviation 0.1. This value is used only in the Discussion communication protocol.
- expert: boolean indicating if an agent is an expert and thus can demonstrate a warrant to agents she convinces.
- seen_warrant: boolean indicating if an agent has been convinced by an expert and thus has seen evidence of the "true facts".
As for the methods:
- evaluate_opinion(): used to determine if an agent will change her opinion right after being presented with a different opinion than the one she holds. It is used specifically when the Discussion and Simple communication protocols are used and relies simply on the agent's skepticism and whether she has been convinced by an expert or not.
- form_opinion(): used to determine if an agent will change her opinion based on the her opinion base, taking into account the other parameters, like skepticism and receiving the opinion of an expert.
The Environment class acts as a medium and facilitates the simulation. Therefore a considerable number of attributes is required. They are as follows:
-
num_agents: integer indicating the total number of agents that will take part in the simulation.
-
num_liars: integer indicating the number of liars among the agents.
-
num_experts: integer indicating the number of experts among the agents.
-
num_connections: integer indicating the initial number of connections in the network between the agents.
-
num_news: integer indicating the number of news that will be propagated through the network during the simulation. At this point only the case with one piece of news is studied.
-
num_steps: integer indicating the maximum number of steps a simulation may run. It is usually set in very high numbers (circa 20 thousand) to examine the point of convergence based on the communication protocol used.
-
agent_list: list of Agent objects with all their attributes. Used to easily update the agents after each simulation step and to efficiently monitor these changes.
-
connectivity_matrix: a square, two-dimensional NumPy array with length equal to number of agents. It can have values of either zero or one, indicating absence or existence of a connection between agents respectively. More specifically [r,c]=1 in the matrix translates into a connection from agent in position r to agent in position c. The matrix is not symmetrical, meaning that the agent in position r can contact agent in position c but the opposite is not true by default. Thus row-wise we can see the outgoing connections and column-wise the incoming connections of an agent. More specifically, a row-wise traversing of the matrix will serve as each agent's phone book. The main diagonal was chosen to always be zero, because it was found to be more efficient in different implementation details.
-
communication_protocol: string indicating the communication protocol to be used in the current simulation. It can take on of the following values:
- random: indicating the ANY protocol.
- CO: indicating the CMO protocol.
- LNS: indicating the LNS protocol.
- SYO: indicating the SYO protocol.
-
conversation_protocol: string indicating the interaction protocol to be used in the current simulation. It can take on of the following values:
- simple: indicating the Convince Receiver protocol.
- discussion: indicating the Discussion protocol.
- majority_opinion: indicating the Majority Opinion protocol.
-
connectivity: string indicating the initial architecture of the network. It can take on of the following values:
- random: indicating the Random architecture.
- cluster: indicating the Spatially Clustered architecture.
- sun: indicating the Sun Graph architecture.
-
num_isolates: integer indicating the number of possible isolates in the network. This number is calculated right after the initialization of the network. An isolated agent is identified by the absence of both incoming and outgoing connections. It is important to know if and which agents are isolates so as to accommodate for them during the evaluation of the stopping criteria. Therefore all isolates are considered as having the attribute seen_warrant = True, as they cannot be convinced of any opinion other than their own.
All aforementioned attributes are used in the following methods to run the simulations:
- generate_agents: initializes the requested num_agents number of agents for in the network. From them num_liars and num_experts} are randomly selected and the remaining agents will be regulars. Each agent is assigned specific opinion, skepticism, persuasiveness}, expert and seen_warrant values, to match their roles.
- initialize_connectivity_matrix: defines the initial connectivity of the network. In total num_connections agent will be selected based on the chosen connectivity and will be given a connection to another agent. There is no strict restriction in the agent selection, therefore an agent can be selected multiple times. After initialization of the connectivity matrix, each row will represent each agent's phone book.
- init_random: implementation of Random connectivity. Two agents a and b are randomly selected and if there is no connection from a to b, one is established.
- init_cluster: implementation of Spatially Clustered. Selection of agents a and b takes place similarly to random but in this case all agents are first placed on a grid and the closer two agents are the higher probability for a connection to be established between them.
- init_sungraph: implementation of the Sun Graph architecture. Half of the agents form a central ring while the rest connect to them individually.
- convince_isolates: detects agents that are isolated in the network. Specifically an agent is isolated if she is in no phone books and her phone book is empty (i.e. has no incoming and outgoing connections). All isolated agents change their seen_warrant attribute to true, in order to be excluded by the process that track the termination conditions of the simulation.
- run_simulation: assembles all functions necessary to run a simulation and also keeps track of the termination criteria, either by step count or by communication protocol restrictions.
- run_communication_protocol: executes the series of actions involved in the selected communication protocol.
- exchange_phonebooks: enriches the phone books of each of the agents by filling in the connectivity_matrix.
- choose_random_sender: selects a sender at random to interact with an already selected agent.
- agent_conversation: executes the series of actions involved in the selected interaction protocol.
- calculate_winner: evaluates the winner between two agents when the Discussion interaction protocol is used. The selected opinion is the one to be propagated.
- converged: checks if simulation has converged (no more opinion propagation is possible).
- all_contacted: checks if there are still valid pairs of sender/receiver in the network.
- simulations_stats: provides a brief overview of the simulation state.
- output_measures: outputs the measurements that represent the network growth and the opinion propagation in the network.