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.1.2.tar.gz (107.3 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.1.2-py3-none-any.whl (27.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for jgot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0cc5e94405bf120479c488d5cb0a8f506fa826e941521924ffb2a89ce5612d6a
MD5 c9da4eca486bed682dc09ca8ce9c2041
BLAKE2b-256 998b7b845c781c6f7c782946d394b921e2664cf0200849afcd26c4391c16ca2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for jgot-0.1.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.1.2-py3-none-any.whl.

File metadata

  • Download URL: jgot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 27.7 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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c5cc3ad6f04d0a390e1974e0477c12e6feff4830a9304209e9e369c213e3eae
MD5 5d4c835f536f0a4721ba04e0ede791b9
BLAKE2b-256 3e5406062323f39ce68b38a9ce48920587ab7739915a08ae74f1ca74ebd20cb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for jgot-0.1.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