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 across commodities.
    • spread: Randomized, heterogeneous distribution of supply 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_file")

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

# 3. Save as a multi-commodity instance
s2mflow.save_multi_commodity_instance("output_file.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.0.tar.gz (16.2 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.0-cp313-cp313-win_amd64.whl (193.6 kB view details)

Uploaded CPython 3.13Windows x86-64

s2mflow-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl (333.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

s2mflow-0.1.0-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.0.tar.gz.

File metadata

  • Download URL: s2mflow-0.1.0.tar.gz
  • Upload date:
  • Size: 16.2 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.0.tar.gz
Algorithm Hash digest
SHA256 8798c4ae3f04c208dbef8389287a20a52fdabb5c91975bbd3c598e4c1913c653
MD5 c97c71d296933deccdd8c78ab0baf495
BLAKE2b-256 d10081f3e75f5568dc8ab8898a0a017e69b75623eb23df71bdd3dc08cf5d76bd

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.0.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.0-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: s2mflow-0.1.0-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.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 20d9bd44342531030e02b453a551ebc83dc68fa4324a95e07dd6d0d52adccdf9
MD5 f9f7ecc16b20913c7a0ce770e394a56a
BLAKE2b-256 3182cb03b896ed9a036dc6d4a6d7beeadf0475e50ff1cff7523c5d1ad77c107b

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.0-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.0-cp313-cp313-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.0-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a468debb7041a954081d28f9213a75601caf8d0ede1baa237e3cddf01bd9fb78
MD5 295e80f9e00a2fa1792ebd7b19fd016f
BLAKE2b-256 dd295c22b99d63a218b6cd1cf580b3411879cad2e0361699def7ead72b105dd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.0-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.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 40f0478169956dd3c8e0402f1dcbf45a5310bbc8e3495918604306c079fb8801
MD5 6b4b7c0ba65cb147a26383e48d636f64
BLAKE2b-256 ae6bac78f65fb494f3eb8ee6bcee8c49dd3800937a842ac228a15411a55ff2c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.0-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.0-cp313-cp313-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.0-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3382ce795f2242c146057395a9c29bc183bb13d6c7b00b6c825f32caede5d298
MD5 9a82ecdfaecdf3a7d58c9e35def91916
BLAKE2b-256 8eefa5d77cd6aeeb3c8eb7641ecdafe2a6c2f17bf655144900b3379d8e1973c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.0-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.0-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for s2mflow-0.1.0-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c1c563441ad555b954939d04596c65f4aee234faf2d52f7e01c3cd729e12f84
MD5 063d451120a64a25528ad4f1cdcd9582
BLAKE2b-256 ac570aaa903307332c366bea465e7249d9abbc584a1aa01f96b554bd4b6a28d9

See more details on using hashes here.

Provenance

The following attestation bundles were made for s2mflow-0.1.0-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