Simulator for ideological competition dynamics -- replicator-mutator model with dormancy, hybridization, and endogenous environment modification
Project description
ideasim
A simulator for ideological competition dynamics over historical timescales. Models how ideological currents compete, spread, go dormant, and re-emerge using replicator-mutator dynamics with dormancy, hybridization, and endogenous environment modification. The full system is a Piecewise Deterministic Markov Process (PDMP).
Quick Start
pip install ideasim
Run the default scenario (Europe 1800-2025):
ideasim simulate -o results.json
Export and edit the default configuration:
ideasim default-config -o my_config.json
# edit my_config.json ...
ideasim simulate my_config.json -o results.json
What It Models
ideasim simulates how ideological currents (liberalism, Marxism, traditionalism,
nationalism, and their hybrids) evolve over time. The model captures:
- Manifest adoption (x): observable adherence to ideologies on the simplex.
- Latent sympathy (y): hidden reservoirs of support that enable dormancy and re-emergence (the "martyrdom effect").
- Environment (e): exogenous conditions (GDP growth, inequality, media freedom, social media penetration, conflict) that shape ideological fitness.
- Stochastic events: hybridization (new ideologies from blending two parents), charismatic bursts, and parameter mutation.
For the full mathematical framework, see the paper/ directory or
the documentation.
Installation
From PyPI
pip install ideasim
From source (development)
git clone https://github.com/LeonardoSanBenitez/ideasim.git
cd ideasim
pip install -e ".[dev]"
Docker
docker compose build
docker compose run --rm simulator
Usage
Python API
from ideasim.defaults import load_default_config
from ideasim.engine import simulate
config = load_default_config()
result = simulate(config, seed=42)
print(f"Final shares: {result.final_shares}")
print(f"Events triggered: {len(result.events)}")
CLI
# Run with default parameters
ideasim simulate -o results.json
# Custom config
ideasim simulate my_config.json -o results.json
# Export default config for editing
ideasim default-config -o default_config.json
Running Tests
python -m pytest tests/ -v
Project Structure
ideasim/
ideasim/ # Python package
types.py # Core data types (Ideology, SimulationConfig, etc.)
engine.py # PDMP simulation engine (RK4 + stochastic events)
defaults.py # Loads default scenario from JSON data file
io.py # JSON serialization/deserialization
cli.py # Command-line interface
sensitivity.py # Sensitivity analysis (OAT + LHS)
validation.py # Input validation
health.py # Health checks
evaluation/ # Validation against observed data (ParlGov)
data/
default_scenario.json
tests/ # Test suite (104 tests)
paper/ # LaTeX paper
scripts/ # Shell scripts for Docker workflows
Contributing
Contributions are welcome. Please see CONTRIBUTING.md for guidelines on setting up the development environment, running tests, and submitting pull requests.
Citation
If you use ideasim in your research, please cite:
@software{ideasim,
title = {ideasim: Ideological Dynamics Simulator},
author = {San Benitez, Leonardo},
year = {2026},
url = {https://github.com/LeonardoSanBenitez/ideasim},
}
License
Apache License 2.0. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ideasim-0.1.0.tar.gz.
File metadata
- Download URL: ideasim-0.1.0.tar.gz
- Upload date:
- Size: 57.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebcea30c373ff99a2197ad38a1d75a7c7523cde29b2b8f1b693d3a59a2ef8ae7
|
|
| MD5 |
6ed363fce7ed0bc15864caaef6d375ac
|
|
| BLAKE2b-256 |
a0f325dfc6a7bae18e1a434cb4af8b7b696d7123963589c1b0c8316490a77220
|
Provenance
The following attestation bundles were made for ideasim-0.1.0.tar.gz:
Publisher:
publish.yml on LeonardoSanBenitez/ideasim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ideasim-0.1.0.tar.gz -
Subject digest:
ebcea30c373ff99a2197ad38a1d75a7c7523cde29b2b8f1b693d3a59a2ef8ae7 - Sigstore transparency entry: 1238710836
- Sigstore integration time:
-
Permalink:
LeonardoSanBenitez/ideasim@ed4ccf2a8acd7de447518033855a6504eab0ab9b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/LeonardoSanBenitez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ed4ccf2a8acd7de447518033855a6504eab0ab9b -
Trigger Event:
release
-
Statement type:
File details
Details for the file ideasim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: ideasim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 51.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b04f4811fcd92789f7384bca8f3cc57414378afaff2e2b8fd67efef8921d792f
|
|
| MD5 |
0cb689c654feb78e1791d50193b6a31b
|
|
| BLAKE2b-256 |
95694ea63ca6dd4dba3412f22fa65487f5e701edc09fc3d9de5cd886ebcea45c
|
Provenance
The following attestation bundles were made for ideasim-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on LeonardoSanBenitez/ideasim
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ideasim-0.1.0-py3-none-any.whl -
Subject digest:
b04f4811fcd92789f7384bca8f3cc57414378afaff2e2b8fd67efef8921d792f - Sigstore transparency entry: 1238710837
- Sigstore integration time:
-
Permalink:
LeonardoSanBenitez/ideasim@ed4ccf2a8acd7de447518033855a6504eab0ab9b -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/LeonardoSanBenitez
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ed4ccf2a8acd7de447518033855a6504eab0ab9b -
Trigger Event:
release
-
Statement type: