Skip to main content

mc_dagprop

PyPI version
Python Versions
License

mc_dagprop is a fast propagation toolkit for directed acyclic graphs (DAGs), with a C++ Monte Carlo engine and a Python analytic engine.

The package provides two propagation modes:

  • Monte Carlo simulation based on sampled edge delays.
  • Analytic propagation of full discrete probability mass functions (PMFs).

Both engines share the same event/activity DAG model and expose aligned naming: MonteCarloPropagator and AnalyticPropagator.

Background

mc_dagprop was developed as part of the SORRI project at the Institute for Transport Planning and Systems (IVT), ETH Zurich. The SORRI project— Simulation-based Optimisation for Railway Robustness Improvement —focuses on learning real-life constraints and objectives to determine timetables optimized for robustness interactively. This research is supported by the SBB Research Fund, which promotes innovative studies in transport management and the future of mobility in Switzerland.


Features

  • High-performance Monte Carlo core in C++ via pybind11.
  • Deterministic analytic propagator for full event-time PMFs.
  • Custom per-activity-type Monte Carlo delay distributions:
    • Constant
    • Exponential
    • Gamma
    • Empirical absolute/relative
  • Single-run (run(seed)) and batched (run_many(seeds)) Monte Carlo APIs.
  • Shared DAG concepts (Event, Activity, DagContext) and unified naming.
  • Optional global max_delay cap available in both engines.

Note: For Monte Carlo, configuring multiple distributions for the same activity_type overrides previous settings. Keep exactly one distribution per type.


Installation

This library requires Python 3.12 or newer.

# with poetry
poetry add mc-dagprop

# or with pip
pip install mc-dagprop

Quickstart (Monte Carlo)

from mc_dagprop import (
  Activity,
  DagContext,
  Event,
  EventTimestamp,
  GenericDelayGenerator,
  MonteCarloPropagator,
)

# 1) Build your DAG timing context
events = [
  Event("A", EventTimestamp(0.0, 100.0, 0.0)),
  Event("B", EventTimestamp(10.0, 100.0, 0.0)),
]

activities = {
  (0, 1): Activity(idx=0, minimal_duration=60.0, activity_type=1),
}

precedence = [
  (1, [(0, 0)]),
]

ctx = DagContext(
  events=events,
  activities=activities,
  precedence_list=precedence,
  max_delay=1800.0,
)

# 2) Configure a delay generator (one distribution per activity_type)
gen = GenericDelayGenerator()
gen.add_constant(activity_type=1, factor=1.5)

# 3) Run propagation
sim = MonteCarloPropagator(ctx, gen)
result = sim.run(seed=42)

print("Realized times:", result.realized)
print("Edge durations:", result.durations)
print("Causal predecessors:", result.cause_event)

Simulator remains available as a compatibility alias of MonteCarloPropagator.


Analytic Propagator

Use AnalyticPropagator to propagate discrete delay PMFs deterministically.

from mc_dagprop import (
  AnalyticContext,
  Event,
  EventTimestamp,
  OverflowRule,
  UnderflowRule,
  create_analytic_propagator,
)
from mc_dagprop.analytic import AnalyticActivity, exponential_pmf

step = 1.0

delay_pmf = exponential_pmf(scale=10.0, step=step, start=0.0, stop=300.0)

events = (
  Event("A", EventTimestamp(0.0, 10.0, 0.0)),
  Event("B", EventTimestamp(0.0, 20.0, 0.0)),
)

activities = {
  (0, 1): (0, AnalyticActivity(idx=0, pmf=delay_pmf)),
}

precedence = (
  (1, ((0, 0),)),
)

ctx = AnalyticContext(
  events=events,
  activities=activities,
  precedence_list=precedence,
  step=step,
  underflow_rule=UnderflowRule.TRUNCATE,
  overflow_rule=OverflowRule.TRUNCATE,
  max_delay=None,
)

sim = create_analytic_propagator(ctx)
pmfs = sim.run()

print(pmfs[1].pmf.values)
print(pmfs[1].pmf.probabilities)

Notes:

  • step is the shared PMF grid spacing for the analytic context.
  • create_analytic_propagator(..., validate=True) validates PMF alignment, mass consistency, indices, and DAG acyclicity before running.
  • PMF binary operations (convolve and maximum) use numerically stable intermediates (np.longdouble) and a post-operation mass correction. This prevents tiny probabilities from being lost to cumulative floating-point drift in deep analytic propagation chains.
  • max_delay mirrors Monte Carlo semantics by capping each event at min(latest, earliest + max_delay).

Package structure

  • mc_dagprop.monte_carlo — compiled Monte Carlo core and delay generator.
  • mc_dagprop.analytic — pure-Python PMF types, distributions, and propagator.
  • mc_dagprop.types — shared typed aliases.
  • demo/ — runnable examples for analytic and Monte Carlo usage.

Install the distribution as mc-dagprop and import from mc_dagprop:

from mc_dagprop import Simulator

Building wheels for Windows, macOS, and Linux

Cross-platform wheel builds are configured through GitHub Actions in .github/workflows/build-wheels.yml using cibuildwheel.

  • Windows (windows-latest)
  • macOS (macos-latest, x86_64 and arm64)
  • Linux (ubuntu-latest)

To run a local source build without the CI workflow:

python -m pip install --upgrade build
python -m build

References

Metadata

Release files for mc-dagprop 0.9.1

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

Source distribution (sdist)

Source distribution for mc-dagprop 0.9.1
File Size Uploaded Provenance Actions
mc_dagprop-0.9.1.tar.gz 47.6 kB With provenance Details for mc_dagprop-0.9.1.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for mc-dagprop 0.9.1
File Actions
mc_dagprop-0.9.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for mc_dagprop-0.9.1-cp313-cp313-win_amd64.whl
mc_dagprop-0.9.1-cp313-cp313-win32.whl CPython 3.13 CPython 3.13 Windows x86-32 Details for mc_dagprop-0.9.1-cp313-cp313-win32.whl
mc_dagprop-0.9.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for mc_dagprop-0.9.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
mc_dagprop-0.9.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for mc_dagprop-0.9.1-cp313-cp313-macosx_11_0_arm64.whl
mc_dagprop-0.9.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details for mc_dagprop-0.9.1-cp312-cp312-win_amd64.whl
mc_dagprop-0.9.1-cp312-cp312-win32.whl CPython 3.12 CPython 3.12 Windows x86-32 Details for mc_dagprop-0.9.1-cp312-cp312-win32.whl
mc_dagprop-0.9.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.27+ x86-64, Linux glibc 2.28+ x86-64 Details for mc_dagprop-0.9.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
mc_dagprop-0.9.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details for mc_dagprop-0.9.1-cp312-cp312-macosx_11_0_arm64.whl

Total release size: 6.0 MB

Release files / mc_dagprop-0.9.1.tar.gz

Download URL mc_dagprop-0.9.1.tar.gz
Size 47.6 kB
Tags Source
SHA-256 checksum
How to use checksums
8d4be21316ed2cbb221d8147756c5dfd56995a6a3a372085013aba6992e4c40e
BLAKE2b-256 checksum
How to use checksums
a4440fc82f12e49c9bbafe8a07511adbecfcac24e63e7f43915fad874dd378cc
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp313-cp313-win_amd64.whl

Download URL mc_dagprop-0.9.1-cp313-cp313-win_amd64.whl
Size 181.5 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
8c89a16d6a1f73610aa07ab8c23cac97dc396043382c66b26f1ba9b351ab99ee
BLAKE2b-256 checksum
How to use checksums
12e91ce2a78b945799ea3a7a2e6fd40279fdf5395375642393ede74c6bc48ea1
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp313-cp313-win32.whl

Download URL mc_dagprop-0.9.1-cp313-cp313-win32.whl
Size 161.4 kB
Tags CPython 3.13 Windows x86-32
SHA-256 checksum
How to use checksums
409c5b4a38a74c35422db2c94a718e71db59307984be76b7fca832d19e5e13cd
BLAKE2b-256 checksum
How to use checksums
ad641744aa30facd169a00145b16ad1078ba3d7e3fc97939a63330df1ecb8d35
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL mc_dagprop-0.9.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.4 MB
Tags CPython 3.13 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
98ec599ec8d6abf42829cd3050619270b8bba74a2e57f4a78aa015d1713986ca
BLAKE2b-256 checksum
How to use checksums
bdf51d335d77d8d33818c681a79e48a6a3dcb7db1405079ede236afea61a05f3
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL mc_dagprop-0.9.1-cp313-cp313-macosx_11_0_arm64.whl
Size 202.3 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ff58509689b7f0141a6bda22526e92b3c157228adc611bd4b197a77564dff154
BLAKE2b-256 checksum
How to use checksums
2ab904a138d531e8534def8a181ab32af06ff2d3126d7b1c257bf732b4a3b765
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp312-cp312-win_amd64.whl

Download URL mc_dagprop-0.9.1-cp312-cp312-win_amd64.whl
Size 181.5 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
698bbdbecd30474beb177ab42a72b40d0216e9c635bb08ed1880e0b6df6e05cb
BLAKE2b-256 checksum
How to use checksums
dbb04c3524c64164de18936c3989ca9b925badd52835819f74a8970773f357b9
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp312-cp312-win32.whl

Download URL mc_dagprop-0.9.1-cp312-cp312-win32.whl
Size 161.4 kB
Tags CPython 3.12 Windows x86-32
SHA-256 checksum
How to use checksums
d5a8a5d957eb00ba06b3c5455a72dd347b45990da2e741a1cccc742d39782ac9
BLAKE2b-256 checksum
How to use checksums
67bcc16d674fbdef7988a6595700d5597006d684ffa7ac888f1acd97266f08f3
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl

Download URL mc_dagprop-0.9.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Size 2.4 MB
Tags CPython 3.12 Linux glibc 2.27+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
c428dd3aa6a5cdd8b27e68c034633f32efd813363437751869ca82e3172cfe92
BLAKE2b-256 checksum
How to use checksums
2987c28c40ca09e80b3fc28f9cb7eb14bc6632deadab8daf3eb53967ae3d4b9d
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 22, 2026.

Transparency log

Release files / mc_dagprop-0.9.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL mc_dagprop-0.9.1-cp312-cp312-macosx_11_0_arm64.whl
Size 202.3 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
35271641abcb2953e18db1659b7dda80ab9cefe2a2ed501221b60b933dfb6ab7
BLAKE2b-256 checksum
How to use checksums
89133dc71487a98be6fef05c820fce012d6fd295a2b33cbb2cf45465b2241753
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 22, 2026.

Transparency log

Security for mc-dagprop 0.9.1

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

All 9 files in this release have been uploaded with provenance metadata.

Select from 9 files

Attestation for mc_dagprop-0.9.1.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 22, 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.9.1 This release

9 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