tucoopy-py
Python package for cooperative game theory (TU) algorithms and for generating animation specs (JSON) consumed by the JS renderer.
Optional speedups:
pip install "tucoopy[fast]"(uses NumPy for small linear solves in geometry helpers)pip install "tucoopy[lp]"(enables LP-based methods like least-core / nucleolus via SciPy)
Optional visualization:
pip install "tucoopy[viz]"for Matplotlib visualization (2 or 3 players only)
Optional extras (feature -> extra)
| Feature | Extra | Notes |
|---|---|---|
| LP-backed methods | lp |
SciPy backend (recommended) |
| LP-backed methods (fallback) | lp_alt |
PuLP backend |
| Speedups | fast |
NumPy helper routines |
| Static visualization | viz |
Matplotlib (2 or 3 players only) |
| Dev tools | dev |
pytest + mypy + ruff |
| Docs build | docs |
mkdocs + mkdocstrings |
Package layout
tucoopy.base: game/coalition primitives (bitmask-based)tucoopy.properties: game properties / recognizerstucoopy.games: classic games (glove, weighted voting, airport, bankruptcy, savings, unanimity, apex, ...)tucoopy.geometry: geometry for visualization (core vertices, ...)tucoopy.solutions: solution concepts (Shapley, Banzhaf, ...)tucoopy.power: voting/simple-game power indicestucoopy.transforms: transforms/representations (Harsanyi dividends, ...)tucoopy.viz: optional visualization with Matplotlib (games with 2 or 3 players only)tucoopy.io: JSON + animation spec helperstucoopy.backends: adapters for optional dependencies (LP, NumPy, ...)
Docs (in this repo): see packages/tucoopy-py/docs/en/index.md (EN) and packages/tucoopy-py/docs/pt/index.md (PT).
Examples (runnable scripts): see packages/tucoopy-py/examples/README.md.
Install
pip install tucoopy
Optional extras:
pip install "tucoopy[lp]"for LP-based methods (least-core / nucleolus / modiclus / balancedness) using SciPy (recommended)pip install "tucoopy[lp_alt]"for LP-based methods (least-core / nucleolus / modiclus / balancedness) using PuLP (fallback)pip install "tucoopy[fast]"for NumPy speedups (kernel / prekernel and helpers)pip install "tucoopy[viz]"for Matplotlib visualization (2 or 3 players only)
Quick example (generate an animation spec)
from tucoopy import Game
from tucoopy.solutions import shapley_value
from tucoopy.io.animation_spec import build_animation_spec
game = Game.from_coalitions(
n_players=3,
values={
(): 0.0,
(0,): 1.0,
(1,): 1.2,
(2,): 0.8,
(0, 1): 2.8,
(0, 2): 2.2,
(1, 2): 2.0,
(0, 1, 2): 4.0,
},
player_labels=["P1", "P2", "P3"],
)
phi = shapley_value(game)
spec = build_animation_spec(
game,
series_id="shapley",
allocations=[phi] * 60,
dt=1 / 30,
series_description="Shapley value (static).",
include_analysis=True,
)
print(spec.to_json())
Nucleolus / least-core (LP)
LP-based methods are behind the optional lp extra:
from tucoopy import Game
from tucoopy.solutions import least_core, nucleolus
g = Game.from_coalitions(
n_players=3,
values={
(): 0.0,
(0,): 1.0,
(1,): 1.2,
(2,): 0.8,
(0, 1): 2.8,
(0, 2): 2.2,
(1, 2): 2.0,
(0, 1, 2): 4.0,
},
)
lc = least_core(g)
nu = nucleolus(g)
print(lc.epsilon, lc.x)
print(nu.levels, nu.x)
Core non-emptiness certificate (LP)
Bondareva–Shapley balancedness check (behind lp):
from tucoopy import Game
from tucoopy.properties.balancedness import balancedness_check
g = Game.from_coalitions(
n_players=3,
values={
(): 0.0,
(0,): 0.0,
(1,): 0.0,
(2,): 0.0,
(0, 1): 1.0,
(0, 2): 1.0,
(1, 2): 1.0,
(0, 1, 2): 1.0,
},
)
res = balancedness_check(g)
print(res.core_nonempty, res.objective, res.weights)
Schema (Python <-> JS contract)
- Canonical schema:
schema/tucoopy-animation.schema.json - Bundled schema (package data):
packages/tucoopy-py/src/tucoopy/io/schemas/tucoopy-animation.schema.json
Metadata
Release files for tucoopy 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tucoopy-0.1.0.tar.gz | 172.8 kB | With provenance | Details for tucoopy-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tucoopy-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for tucoopy-0.1.0-py3-none-any.whl |
Total release size: 400.7 kB
Release files / tucoopy-0.1.0.tar.gz
| Download URL | tucoopy-0.1.0.tar.gz |
|---|---|
| Size | 172.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa4b5f5dc82bbeea0bdbe9030445bb07e7c06882e9671bd69507041e6fc4e087
|
|
BLAKE2b-256 checksum How to use checksums |
f598e2e13dfe7db1ef47759bff608fa52132c61e5fa374a4156bfbe370db9d22
|
| 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 Feb 4, 2026.
Transparency logRelease files / tucoopy-0.1.0-py3-none-any.whl
| Download URL | tucoopy-0.1.0-py3-none-any.whl |
|---|---|
| Size | 227.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11cda703278b45ba67e1b7dac5d02d430ae722278104b1899591d5f49e72f958
|
|
BLAKE2b-256 checksum How to use checksums |
b77087e027efd5f4a2e77922aa652e746c604a6eafd287391b5bfed0940fa4e2
|
| 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 Feb 4, 2026.
Transparency logSecurity for tucoopy 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.
Attestation for tucoopy-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 Feb 4, 2026.
Transparency logA 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.