Metadata-Version: 2.4
Name: policyflux
Version: 0.1.0
Summary: Advanced library for modeling and simulating legislative processes and parliamentary behavior
Author-email: Piotr Pawelec <pawelecpiotr404@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Piotr Pawelec
        
        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.
        
Project-URL: Homepage, https://github.com/MayoDetermined/policyflux
Project-URL: Repository, https://github.com/MayoDetermined/policyflux
Project-URL: Documentation, https://policyflux-docs.github.io
Project-URL: Issues, https://github.com/MayoDetermined/policyflux/issues
Project-URL: Changelog, https://github.com/MayoDetermined/policyflux/blob/main/CHANGELOG.md
Keywords: simulation,legislative,political-science,monte-carlo,agent-based
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=2.0
Requires-Dist: scikit-learn>=1.3
Requires-Dist: numpy>=1.24
Requires-Dist: matplotlib>=3.5
Requires-Dist: pydantic>=1.10
Requires-Dist: pydantic-settings>=2.0
Provides-Extra: torch
Requires-Dist: torch>=2.0; extra == "torch"
Provides-Extra: text-encoders
Requires-Dist: sentence-transformers>=2.2; extra == "text-encoders"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: mypy>=1.7; extra == "dev"
Requires-Dist: ruff>=0.1.8; extra == "dev"
Requires-Dist: pyyaml>=6.0; extra == "dev"
Requires-Dist: pre-commit>=3.5; extra == "dev"
Requires-Dist: build>=1.2.0; extra == "dev"
Requires-Dist: twine>=5.1.0; extra == "dev"
Provides-Extra: examples
Requires-Dist: jupyter>=1.0; extra == "examples"
Requires-Dist: notebook>=7.0; extra == "examples"
Dynamic: license-file

# PolicyFlux

<div align="center">

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

[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![PyPI version](https://img.shields.io/pypi/v/policyflux.svg)](https://pypi.org/project/policyflux/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
[![Development Status](https://img.shields.io/badge/status-early%20development-orange.svg)](https://github.com/MayoDetermined/policyflux)

</div>

## 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:

```bash
pip install policyflux
```

Install from source:

```bash
git clone https://github.com/piotrpawelec/policyflux.git
cd policyflux
pip install -e .
```

Optional extras:

```bash
# 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:

```bash
python -c "import policyflux; print(policyflux.__version__)"
```

## Quick start

```python
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

```text
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

- [Documentation index](docs/index.md)
- [Getting started](docs/getting-started.md)
- [API overview](docs/api-overview.md)
- [Architecture](docs/architecture.md)
- [Release guide](docs/release.md)

## Development

```bash
pip install -e ".[dev]"
pytest tests/
ruff check policyflux/
mypy policyflux/
```

For contribution workflow and standards, see [CONTRIBUTING.md](CONTRIBUTING.md).

## License

Distributed under the MIT License. See [LICENSE](LICENSE).
