Skip to main content

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

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.

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

policyflux-0.1.0.tar.gz (79.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

policyflux-0.1.0-py3-none-any.whl (112.1 kB view details)

Uploaded Python 3

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

Hashes for policyflux-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c18ab98111a6449d5e8769c13a22b606d78ab46b27d32757208b564cae5ae253
MD5 6b005446cf7ee652202798284dcaa0f5
BLAKE2b-256 815c8e7b7fdc64d9d32d7034e84b971c5e9d7c74f1e36546ec6f9ff00c927a7d

See more details on using hashes here.

Provenance

The following attestation bundles were made for policyflux-0.1.0.tar.gz:

Publisher: publish.yml on MayoDetermined/policyflux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for policyflux-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3582a1439a7ed9ace9de9a8c7d0711da47211f25ef29cd8d8251658814539f25
MD5 e4cde9224594e4cd401e7fb2be6602d2
BLAKE2b-256 91aafa19711215b84197a68f42f6bc4e2dfc7c590e091bcf36f5a0f60b738728

See more details on using hashes here.

Provenance

The following attestation bundles were made for policyflux-0.1.0-py3-none-any.whl:

Publisher: publish.yml on MayoDetermined/policyflux

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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