/Covid19OpinionDynamics

Investigating social phenomena prevalent in online covid-19 discourse through network-agent based modelling

Primary LanguagePython

Project icon

Investigating social phenomena prevalent in online covid-19 discourse through network-agent based modelling

Anthony Reidy

Table of contents

Install

It is good practice to develop in a virtual environment. Note, this code contained in this assignment was written using python 3.8 and on the Ubuntu (Linux) operating system (OS). As such, all commands are setup for this installation and may not work for other OS's. To create a virtual environment called venv, execute:

python3 -m venv venv

To activate it, execute

source venv/bin/activate
  • Execute pip3 install -r requirements.txt to install requirements for development.

Report

The report for this investigation can be found here.

Usage

$ python3 model.py --help 
Usage: model.py [options]

Options:
  -h, --help            show this help message and exit
  -n NUM_AGENTS, --num_agents=NUM_AGENTS
                        Number of agents in network.
  -l N_NEIGHBORS, --n_neighbors=N_NEIGHBORS
                        Number of neighbors for each node
  -t NETWORK_TYPE, --network_type=NETWORK_TYPE
                        1 for small-world, 2 for scale free
  -b BETA_COMPONENT, --beta_component=BETA_COMPONENT
                        if network type is small world (1); this is the beta-
                        component
  -s SIMILARITY_TRESHOLD, --similarity_treshold=SIMILARITY_TRESHOLD
                        Range in which similarity holds
  -i SOCIAL_INFLUENCE, --social_influence=SOCIAL_INFLUENCE
                        The influence of neighboring agents on the forming of
                        a new preference.
  -w SWINGERS, --swingers=SWINGERS
                        Number of agents which switches opinion, preference,
                        and trust with each timestep.
  -v MALICIOUS, --malicious=MALICIOUS
                         Number of malicious agents
  -e ECHO_LIMIT, --echo_limit=ECHO_LIMIT
                        Limit for edge strength (weight) for echo chamber
                        calculation.
  -m ALL_MAJORITY, --all_majority=ALL_MAJORITY
                         If true: all agents except malicious agents have the
                        same opinion
  -o OPINIONS, --opinions=OPINIONS
                        Number of opinions 

GUI

GUI with two opinions

alt text

GUI with three opinions

alt text

The graphical user interface has five main components:

  1. Network visualisation (upper): The upper panel displays the network. The colour of each node indicates it's opinion where as the strength of the color shade indicates its preference. The strength of the edge's grey color indicates the trust between two agents In addition, the current step is displayed.
  2. Number of communities (upper left): Time series graph displaying communities over time t as defined by the Louvain algorithm.
  3. Silent Spiral, and percentage of agents with radical opinions (upper right): Time series graph displaying the number of silent spirals, and the percentage of agents with radical opinions over time t.
  4. Average Trust, percentage of agents with majority opinion (bottom left): Time series graph displaying the average trust and percentage of agents with the majority opinion throughout the network.
  5. Echo chamber and transitivity (bottom right): Time series graph displaying Transitivity, and the percentage of echo chambers over all cliques through time t.

File explanation

  1. model.py A python module that contains the majority of the code related to the model. It describes the initialization strategy (random activation), the update steps and the time series graphs visualisation.

  2. Analysis.py A python module that contains "compute functions" for the output parameters e.g. echo chamber count

  3. Visualization.py Code required to visualize the network. I decided to put this into a separate file given the size of the code required.