Advanced library for modeling and simulating legislative processes and parliamentary behavior
Project description
PolicyFlux
A Python library for modeling legislative behavior, voting dynamics, and institutional political systems
Project status
PolicyFlux is in active early development. It is suitable for research workflows and prototyping, while parts of the API may still evolve between versions.
Recommended usage:
- ✅ Research and academic experiments
- ✅ Scenario and policy prototyping
- ⚠️ Workloads where occasional API changes are acceptable
- ❌ Stable long-term production systems
What PolicyFlux models
PolicyFlux simulates legislative outcomes by combining:
- actors with preferences in an n-dimensional policy space,
- bills represented in the same policy space,
- composable influence layers (public opinion, lobbying, media, party discipline, agenda control),
- institutional presets (presidential, parliamentary, semi-presidential),
- deterministic and Monte Carlo execution engines.
Typical users:
- political scientists studying institutional dynamics,
- data scientists running Monte Carlo experiments,
- policy analysts exploring what-if scenarios,
- educators teaching decision-making in political systems.
Installation
Requirements:
- Python 3.10+
pip
Install from PyPI:
pip install policyflux
Install from source:
git clone https://github.com/piotrpawelec/policyflux.git
cd policyflux
pip install -e .
Optional extras:
# Neural layers (PyTorch)
pip install -e ".[torch]"
# Text encoders
pip install -e ".[text-encoders]"
# Notebook/examples support
pip install -e ".[examples]"
# Developer tooling
pip install -e ".[dev]"
# All common extras
pip install -e ".[torch,text-encoders,examples,dev]"
Verify installation:
python -c "import policyflux; print(policyflux.__version__)"
Quick start
from policyflux import IntegrationConfig, LayerConfig, build_engine
config = IntegrationConfig(
num_actors=50,
policy_dim=2,
iterations=100,
seed=12345,
layer_config=LayerConfig(
include_ideal_point=True,
include_public_opinion=True,
include_party_discipline=True,
public_support=0.60,
party_discipline_strength=0.5,
),
)
engine = build_engine(config)
engine.run()
print(f"Pass rate: {engine.pass_rate:.1%}")
print(f"Accepted: {engine.accepted_bills}, Rejected: {engine.rejected_bills}")
Main API entry points
IntegrationConfig– top-level simulation parameters.LayerConfig– layer toggles and layer strengths/intensities.AdvancedActorsConfig– lobbyists, whips, and executive-specific behavior.build_engine(config)– build the configured simulation engine.create_presidential_config(...),create_parliamentary_config(...),create_semi_presidential_config(...)– ready-to-run presets.
Architecture at a glance
policyflux/
├── core/ # abstractions, contexts, strategies
├── layers/ # composable decision layers
├── engines/ # deterministic + Monte Carlo execution
├── integration/ # config, builders, presets, registry
├── toolbox/ # concrete actor/bill/congress implementations
├── data_processing/ # text and embedding helpers
└── utils/ # reports and utility helpers
Documentation
Development
pip install -e ".[dev]"
pytest tests/
ruff check policyflux/
mypy policyflux/
For contribution workflow and standards, see CONTRIBUTING.md.
License
Distributed under the MIT License. See LICENSE.
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 policyflux-0.1.0.tar.gz.
File metadata
- Download URL: policyflux-0.1.0.tar.gz
- Upload date:
- Size: 79.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c18ab98111a6449d5e8769c13a22b606d78ab46b27d32757208b564cae5ae253
|
|
| MD5 |
6b005446cf7ee652202798284dcaa0f5
|
|
| BLAKE2b-256 |
815c8e7b7fdc64d9d32d7034e84b971c5e9d7c74f1e36546ec6f9ff00c927a7d
|
Provenance
The following attestation bundles were made for policyflux-0.1.0.tar.gz:
Publisher:
publish.yml on MayoDetermined/policyflux
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
policyflux-0.1.0.tar.gz -
Subject digest:
c18ab98111a6449d5e8769c13a22b606d78ab46b27d32757208b564cae5ae253 - Sigstore transparency entry: 1105883090
- Sigstore integration time:
-
Permalink:
MayoDetermined/policyflux@cce937e8f25807ff6eaf82726bd71bab66ccf6b9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MayoDetermined
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cce937e8f25807ff6eaf82726bd71bab66ccf6b9 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file policyflux-0.1.0-py3-none-any.whl.
File metadata
- Download URL: policyflux-0.1.0-py3-none-any.whl
- Upload date:
- Size: 112.1 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 |
3582a1439a7ed9ace9de9a8c7d0711da47211f25ef29cd8d8251658814539f25
|
|
| MD5 |
e4cde9224594e4cd401e7fb2be6602d2
|
|
| BLAKE2b-256 |
91aafa19711215b84197a68f42f6bc4e2dfc7c590e091bcf36f5a0f60b738728
|
Provenance
The following attestation bundles were made for policyflux-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on MayoDetermined/policyflux
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
policyflux-0.1.0-py3-none-any.whl -
Subject digest:
3582a1439a7ed9ace9de9a8c7d0711da47211f25ef29cd8d8251658814539f25 - Sigstore transparency entry: 1105883098
- Sigstore integration time:
-
Permalink:
MayoDetermined/policyflux@cce937e8f25807ff6eaf82726bd71bab66ccf6b9 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/MayoDetermined
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@cce937e8f25807ff6eaf82726bd71bab66ccf6b9 -
Trigger Event:
workflow_dispatch
-
Statement type: