Skip to main content

A tool for social network simulations in the Alvim-Knight-Valencia model.

Project description

akvmodel: A Python Tool for Social Network Simulations in the Alvim-Knight-Valencia Model

DOI

Formal models for social networks aim to capture the crucial aspects of the evolution of agents' beliefs over time, as communication occurs in a network. The Alvim-Knight-Valencia (AKV) social network model (2019) works on the dynamics of belief updates using a quantitative spectrum of belief values, and an influence graph representing the relationships between agents. Previous work on the AKV model developed belief update functions representing a range of belief update methods.

This package implements the AKV model and a catalog of its belief updates, initial configurations, and update functions from the literature, creating a general tool that incorporates a wide range of possible approaches to belief updates. In addition, we allow the AKV model to have multiple outcomes (or truth values) for the proposition used in the model. This tool facilitates future research using the AKV model without the need to reimplement it also allowing its reproducibility.

Installation

Use the package manager pip to install akvmodel.

pip install akvmodel

Usage

The full reference of the package can be found in DOCUMENTATION.md.

import numpy as np
from akvmodel import *

# Create model with 10 agents, mildly polarized initial configuration, faintly communicating influence graph, and confirmation bias belief update.
akvmodel = AKV(
    belief_state=InitialConfigurations.mildly(10),
    influence_graph=InfluenceGraphs.faintly(10),
    update_function=UpdateFunctions.confirmation_bias,
)

# Update the model 100 times
for _ in range(100):
    akvmodel.update()

# Get polarization
p = akvmodel.get_polarization()

# Plot polarization evolution for the first outcome in the domain
plt.plot(p[0])

Full example can be found in the Jupyter Notebook example.ipynb.

Trying the package with Docker

This project includes a Dockerfile that builds an image with Jupyter Notebook and necessary requirements to run the example.

Build the image:

docker build -t akvmodel-test .

Run the image:`

docker run -p 8888:8888 akvmodel-test

Open localhost:8888 on your browser, use the password test and open the file example.ipynb. Changes on example.ipynb will not be saved.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

akvmodel-1.2.1.tar.gz (21.8 kB view hashes)

Uploaded Source

Built Distribution

akvmodel-1.2.1-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page