Skip to main content

PolicyFlux

A Python library for modeling legislative behavior, voting dynamics, and institutional political systems

Python 3.10+ PyPI version License: MIT Development Status

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.

Metadata

Release files for policyflux 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for policyflux 0.1.0
File Size Uploaded Provenance Actions
policyflux-0.1.0.tar.gz 79.2 kB With provenance Details for policyflux-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for policyflux 0.1.0
File Interpreter ABI Platform Actions
policyflux-0.1.0-py3-none-any.whl Python 3 none any Details for policyflux-0.1.0-py3-none-any.whl

Total release size: 191.3 kB

Release files / policyflux-0.1.0.tar.gz

Download URL policyflux-0.1.0.tar.gz
Size 79.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c18ab98111a6449d5e8769c13a22b606d78ab46b27d32757208b564cae5ae253
BLAKE2b-256 checksum
How to use checksums
815c8e7b7fdc64d9d32d7034e84b971c5e9d7c74f1e36546ec6f9ff00c927a7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

Release files / policyflux-0.1.0-py3-none-any.whl

Download URL policyflux-0.1.0-py3-none-any.whl
Size 112.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3582a1439a7ed9ace9de9a8c7d0711da47211f25ef29cd8d8251658814539f25
BLAKE2b-256 checksum
How to use checksums
91aafa19711215b84197a68f42f6bc4e2dfc7c590e091bcf36f5a0f60b738728
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

Security for policyflux 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for policyflux-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page