pylimid
Mixed-type limited-memory influence diagrams, on NumPyro.
pylimid is a Python library for decision models that mix discrete and continuous variables. You describe chance, decision, and utility nodes; it validates the diagram, infers posteriors, and returns the optimal policy.
Exact tabular solvers like pyAgrum are the right tool for fully discrete influence diagrams, but they cannot express a continuous variable or a payoff that is not a table. pylimid takes the other trade. Distributions, decisions, and utilities are ordinary NumPyro callables evaluated with JAX, and every answer is a Monte-Carlo estimate from a solver with a stated guarantee. That makes reachable models that tabular solvers cannot express: arbitrary continuous distributions, mixed diagrams, and payoffs like jnp.log(wealth).
Early development. pylimid is pre-1.0; the public API may change between releases. Pin a version if you build on it.
Capabilities
- Mixed-type by construction. Chance nodes can be discrete, continuous, or mixed, using any NumPyro distribution.
- Callables, not tables. A distribution or utility is a Python function of its parents, so a payoff can be any JAX-traceable expression.
- Explicit information sets. A decision observes exactly the parents you draw — there is no implicit no-forgetting. Anything an agent should remember is a memory arc you add, and a classical influence diagram is the special case where all of them are drawn.
- Two verbs.
infercomputes posterior draws — exact enumeration for discrete sites, NUTS for continuous ones — andsolvereturns an optimal policy with its expected utility. - Monte-Carlo with stated guarantees. Backward induction on solvable diagrams, an exhaustive scan otherwise; the result records which solver ran.
- A mutable workspace. Build incrementally, wire and rewire edges, and gate inference behind an explicit
validate()/snapshot()checkpoint.
Decision problem example
A newsvendor stocks newspapers before the day's demand is known. Each paper costs $1 and sells for $10; leftovers are worthless. Demand is a right-skewed Gamma — quiet days average 40, busy days average 120 — and the profit is an arbitrary function of what is stocked and demanded.
import jax.numpy as jnp
import numpyro.distributions as dist
from pylimid import ChanceNode, DecisionNode, InfluenceDiagram, UtilityNode, solve
orders = jnp.arange(0, 261, 20) # discrete stock levels
rates = jnp.array([0.1, 1 / 30]) # Gamma rate: quiet mean 40, busy mean 120
diagram = InfluenceDiagram()
diagram.add_node(
ChanceNode(
name="day",
states=("quiet", "busy"),
dist=lambda: dist.Categorical(probs=jnp.array([0.7, 0.3])),
)
)
diagram.add_node(
ChanceNode(
name="demand",
parents=("day",),
dist=lambda day: dist.Gamma(concentration=4.0, rate=rates[day]),
)
)
diagram.add_node(
DecisionNode(name="order", parents=("day",), states=tuple(str(n) for n in orders))
)
diagram.add_node(
UtilityNode(
name="profit",
parents=("order", "demand"),
values=lambda order, demand: (
10.0 * jnp.minimum(orders[order], demand) - 1.0 * orders[order]
),
)
)
solution = solve(diagram)
solution.policy # stock 60 on a quiet day, 200 on a busy day
The solver stocks well above the average demand — 60 on a quiet day (mean 40), 200 on a busy day (mean 120) — because a missed sale forfeits the $9 margin while an unsold paper costs only $1, so the optimum tracks the 90th percentile. The newsvendor tutorial walks through the full derivation.
Installation
Requires Python 3.12.
pip install pylimid
The default install runs on the CPU. For an NVIDIA GPU, install the CUDA extra — it pulls the matching CUDA-enabled JAX plugin:
pip install "pylimid[cuda12]" # or "pylimid[cuda13]" for newer drivers
For a development checkout, see CONTRIBUTING.md.
Documentation
Contributing
Contributions are welcome. See CONTRIBUTING.md for the development setup, the checks, and the conventions.
License
Apache 2.0 — see LICENSE.md.
Metadata
Release files for pylimid 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 | |
|---|---|---|---|
| pylimid-0.1.0.tar.gz | 786.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pylimid-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 842.9 kB
Release files / pylimid-0.1.0.tar.gz
| Download URL | pylimid-0.1.0.tar.gz |
|---|---|
| Size | 786.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d8c87c361681f81595de26b50ace04aab8c9b1b0e7bbff036c939bdf41ec3fc
|
|
BLAKE2b-256 checksum How to use checksums |
2800013f92347c0dcdf7b722224b0dc5cf0245dccbf52e4d4833faf7d5eaac04
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 4, 2026.
Transparency logRelease files / pylimid-0.1.0-py3-none-any.whl
| Download URL | pylimid-0.1.0-py3-none-any.whl |
|---|---|
| Size | 56.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca38229946bac9d06bb1f7b3889a40571d25e55bcda0e3d5cb880f7d761b8781
|
|
BLAKE2b-256 checksum How to use checksums |
a29ef549a4feb53d21bdb3b20d84a108b9e3d4800d773a3dc2062b71e14a2f11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Oct 4, 2026.
Transparency log