Metadata-Version: 2.3
Name: akvmodel
Version: 1.2.2
Summary: A tool for social network simulations in the Alvim-Knight-Valencia model.
Project-URL: Homepage, https://github.com/joseoliveirajr/akvmodel
Project-URL: Bug Tracker, https://github.com/joseoliveirajr/akvmodel/issues
Author-email: "José C. Oliveira" <josecarlosdeoliveirajr@gmail.com>, Sophia Knight <sophia.knight@gmail.com>
Maintainer-email: "José C. Oliveira" <josecarlosdeoliveirajr@gmail.com>
License: MIT License
        
        Copyright (c) 2024 José C. Oliveira
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.10
Requires-Dist: matplotlib
Requires-Dist: numpy
Description-Content-Type: text/markdown

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

[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10695209.svg)](https://doi.org/10.5281/zenodo.10695209)

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](https://pip.pypa.io/en/stable/) to install akvmodel.

```bash
pip install akvmodel
```

## Usage

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

```python
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:
```bash
docker build -t akvmodel-test .
```

Run the image:`
```bash
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](https://choosealicense.com/licenses/mit/)