Skip to main content

Meta-generator: generating multicommodity flow instances from single-commodity flow instances.

Project description

s2mflow

A meta-generator for generating multicommodity flow instances from single-commodity flow instances.

s2mflow is a Python library with a high-speed Rust core (via PyO3) designed to transform single-commodity minimum-cost flow (MCF) instances into minimum-cost multicommodity flow (MCMCF) instances. It is built for researchers in Operations Research, Mathematical Optimization, and Network Optimization who need to generate reproducible, scalable test data.

Key Features

  • Blazing Fast: Core logic implemented in Rust for zero-overhead data handling.
  • DIMACS Compatible: Load standard .min single-commodity files.
  • Custom MCMCF Format: Introduces the .mcfmin format for multicommodity data.
  • Supply Partitioning:
    • uniform: Equal distribution of supply and demand across commodities.
    • spread: Randomized, heterogeneous distribution of supply and demand across commodities.
  • Randomizing Capacities and Costs: Functionality for generating randomized commodity capacities and commodity costs for each arc.
  • Network Utilities: Support for identifying incoming and outgoing edges.

Installation

pip install s2mflow

Quick Start

# .min example data:
# c  *** Minimum cost flow ***
# c
# p min 5 10
# n 1 10
# n 5 -10
# a 1 2 0 10 9
# a 1 4 0 16 2
# a 2 4 0 10 10
# a 2 3 0 10 1
# a 3 5 0 10 10
# a 3 2 0 20 2
# a 3 4 0 17 9
# a 4 3 0 10 9
# a 4 1 0 10 3
# a 4 2 0 19 2

import s2mflow

# 1. Load a single-commodity network
network = s2mflow.load_min_instance("input.min")

# 2. Generate multicommodity data for 3 commodities
mc_data = s2mflow.generate_multi_commodity_data(
    instance=network,
    num_commodities=3,
    is_uniform=False,
    seed=42,
)

# 3. Save as a multi-commodity instance
s2mflow.save_multi_commodity_instance("output.mcfmin", network, mc_data)

# c Multicommodity flow generated by s2mflow
# p min 5 10 3 0 0 0 42
# n 1 10 2 3 5
# n 5 -10 -2 -3 -5
# a 1 2 0 10 10 9
# a 1 4 0 16 16 2
# a 2 4 0 10 10 10
# a 2 3 0 10 10 1
# a 3 5 0 10 10 10
# a 3 2 0 20 20 2
# a 3 4 0 17 17 9
# a 4 3 0 10 10 9
# a 4 1 0 10 10 3
# a 4 2 0 19 19 2

Citing

If you use s2mflow in your research, please cite the software:

@software{s2mflow2026,
  author = {Broesamle, Felix P. and Nickel, Stefan},
  title = {s2mflow: A Meta-generator for Multicommodity Flow Instances},
  version = {0.1.0},
  year = {2026},
  url = {https://github.com/FelixBroesamle/s2mflow}
}

License

Distributed under the MIT License. See LICENSE for more information.

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

s2mflow-0.1.3.tar.gz (16.3 kB view details)

Uploaded Source

Built Distributions

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

s2mflow-0.1.3-cp313-cp313-win_amd64.whl (193.6 kB view details)

Uploaded CPython 3.13Windows x86-64

s2mflow-0.1.3-cp313-cp313-manylinux_2_28_aarch64.whl (333.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

s2mflow-0.1.3-cp313-cp313-macosx_11_0_arm64.whl (295.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

s2mflow-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl (305.6 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

s2mflow-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl (345.6 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

File details

Details for the file s2mflow-0.1.3.tar.gz.

File metadata

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

File hashes

Hashes for s2mflow-0.1.3.tar.gz
Algorithm Hash digest
SHA256 5fd78d3c3a99d3537e6a12dd2e3fcdc98e29c127742d8addd390a0b3722c7444
MD5 894006583073598f67bd34662ef80c1a
BLAKE2b-256 6c4dee82e36792f5c20a2ec6bb4c1a28dffa288d612b22ca99933ffc0ef7f99f

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.3.tar.gz:

Publisher: release.yml on FelixBroesamle/s2mflow

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

File details

Details for the file s2mflow-0.1.3-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: s2mflow-0.1.3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 193.6 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for s2mflow-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 c7ae4a3e9f543e180ad93f3851dbc72eb4650827b1112717058fff8b97735d15
MD5 f3e205c4453c43f28469317c1cef8642
BLAKE2b-256 5ef300f5219796adca57c91ba9057ea8f80619012fb91dafe4d3c74c18903ff2

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.3-cp313-cp313-win_amd64.whl:

Publisher: release.yml on FelixBroesamle/s2mflow

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

File details

Details for the file s2mflow-0.1.3-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.3-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 047724d16d705eb7f73f50bbe260e206c601e961f2733f8959521ea8fa532c17
MD5 60a74c88e723f6537fecb71edcb85694
BLAKE2b-256 85f20f6524db3c7bd180e3c6eff3196e76f61160b8fe6c518db7b75c5485d1b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.3-cp313-cp313-manylinux_2_28_aarch64.whl:

Publisher: release.yml on FelixBroesamle/s2mflow

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

File details

Details for the file s2mflow-0.1.3-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0cf58b0d1e36bccd5134a15e8c1610a618f6ffbd0bc85b6d48480f9ce249d9ad
MD5 7dd607d1db5ba429eac4da3b656eeba3
BLAKE2b-256 9b09501df766144dee48d63862b2073b88f203b2d4d6a43b5ed3ec15562e6385

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.3-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on FelixBroesamle/s2mflow

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

File details

Details for the file s2mflow-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 5f8d867407f8870912bf731a3fcefcaf1fbef2e210309e3f3b993a4ab972e2b9
MD5 4b329d99b44d2ee8fbadf4ca302e9bd7
BLAKE2b-256 e72d6370c6c3bb3f21cb612d527a8cfe7c39330745ec67e91c03d1cc403f92cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl:

Publisher: release.yml on FelixBroesamle/s2mflow

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

File details

Details for the file s2mflow-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4be5a7f108de7251e6274ced28965854e4908271932fc1e5afd7bb1b95de9003
MD5 f0c18da56f8597503b1651054a27ee9f
BLAKE2b-256 72038d9e9f6601a54b8db1a279ff71102abf92e7111bbd4cc45069f6c86b004f

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.3-cp311-cp311-manylinux_2_28_x86_64.whl:

Publisher: release.yml on FelixBroesamle/s2mflow

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