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.0.tar.gz (110.0 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.0-py3-none-any.whl (28.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: jgot-0.2.0.tar.gz
  • Upload date:
  • Size: 110.0 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.0.tar.gz
Algorithm Hash digest
SHA256 7cb86bb6e1711e159174ff25c299e828062cbee0e15b0720ad76b705066898a0
MD5 f561cbc466841e458ec90fb5be4dd431
BLAKE2b-256 6b30432691ce5fd6ef9efb4f26acb0ab03f4051e2cf19860ee4b949f885ea3fa

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: jgot-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 28.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0dd15293f478355d9667bd0bfad1d932cb5608f9fd7633cd2d77a399dbca2da6
MD5 0578c8671495451cbfdfb5bc34ccc144
BLAKE2b-256 b1eacb0e8a32806c4559913b7329675079cbdc44d49d554647b677234e9dff6d

See more details on using hashes here.

Provenance

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