Skip to main content

Dynamic optimal transport on sparse reversible graphs in JAX

Project description

JGOT (JAX Graph Optimal Transport)

PyPI

jgot solves two-endpoint dynamic optimal transport on sparse reversible graphs using JAX, following the time-discrete formulation of Erbar et al. (2020).

Install

PyPI package:

Core library:

pip install jgot

Examples (plotting dependencies included):

pip install "jgot[examples]"

Development environment:

uv sync --group dev

Minimal Example

import jax.numpy as jnp
from jgot import (
    GraphSpec,
    LogMeanOps,
    OTConfig,
    OTProblem,
    TimeDiscretization,
    solve_ot,
)

graph = GraphSpec.from_undirected_weights(
    num_nodes=2,
    edge_u=[0],
    edge_v=[1],
    weight=[1.0],
)

mass_a = jnp.array([1.0, 0.0])
mass_b = jnp.array([0.0, 1.0])
rho_a = mass_a / graph.pi
rho_b = mass_b / graph.pi

problem = OTProblem(
    graph=graph,
    time=TimeDiscretization(num_steps=64),
    rho_a=rho_a,
    rho_b=rho_b,
    mean_ops=LogMeanOps(),
)

sol = solve_ot(problem, OTConfig())
print(float(sol.distance), sol.converged, sol.iterations_used)

Important:

  • Densities are represented with respect to pi.
  • Endpoints must satisfy sum(pi * rho) == 1.

Documentation

Detailed docs live under docs.

Recommended starting points:

Examples

Runnable scripts:

  • examples/two_node_benchmark/run.py
  • examples/cycle_neighbor_transport/run.py
  • examples/line_chain_transport/run.py
  • examples/directed_reversible_transport/run.py
  • examples/large_grid_transport/run.py

See examples/README.md for commands and outputs.

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

jgot-0.2.2.tar.gz (111.9 kB view details)

Uploaded Source

Built Distribution

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

jgot-0.2.2-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file jgot-0.2.2.tar.gz.

File metadata

  • Download URL: jgot-0.2.2.tar.gz
  • Upload date:
  • Size: 111.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jgot-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ed2de55d0ffce66ab1e56b2c47fd92edf061e90a62fe22872d939a51489484b9
MD5 8cd5340b165dfdde7da2c77bde37ece5
BLAKE2b-256 3fdd6d440b00fa430ff4db89c27b4593bafd2715abe2928754a87c6c28d851e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for jgot-0.2.2.tar.gz:

Publisher: publish.yml on LvDAO/JaxGraphOT

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

File details

Details for the file jgot-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: jgot-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for jgot-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b89940357e4c0629c655b83d99be06ca73d2faee8458f926c793ee56145824f5
MD5 d0945d068116fea2aa0f295f2d6ae99f
BLAKE2b-256 75d14e9b352aded0b84f8004b3c0c87c3ac230d9b913a392545e917c92b5128a

See more details on using hashes here.

Provenance

The following attestation bundles were made for jgot-0.2.2-py3-none-any.whl:

Publisher: publish.yml on LvDAO/JaxGraphOT

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