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.2.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.2-cp313-cp313-win_amd64.whl (193.6 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

s2mflow-0.1.2-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.2.tar.gz.

File metadata

  • Download URL: s2mflow-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 853e80a25f3ce14e673eeed9ec51b5cc55e10846f30e1eaed0cf4fce1faefc20
MD5 638ecd6c4b0cf2400107d894a590c77a
BLAKE2b-256 7fe181dfd8d08bdbfb94450305198c42ae09d4db94e29320ec0205de50e197c5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: s2mflow-0.1.2-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.2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 089efb82f51ff31732451e3e607c7a6a0620d95f78e3298693aafe0c7a2cdeb4
MD5 8f27a421ab7dd4f9b1a6796289f62fb0
BLAKE2b-256 5172749342d35e3668a72329c140be2185f03fa700054184b0d0595d0479cb89

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.2-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3257902c4d2fac8a7c74867460e5b1ae94d5673c7bc44a25d8c957c92b163996
MD5 859acc6a52a206db158150aad2591371
BLAKE2b-256 a1438784da448510709a126505269c03e631a9b88e559dcd8015465f3132f0f3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 89e37c151102bb58f68a0e40605a827c1b707e7cfeb0529ed3825f83b4fa6175
MD5 08ed59e71fdefeff61ab04b1a14d1ea0
BLAKE2b-256 154b66c285593ba5af8fe2b1a0c5b7cbc12b1708e3493dd1f94e146607d2adc1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.2-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 290bd288c7116c5bc855dcff1ca9327085d80dc838177054479c86f949a87434
MD5 f3f974e803214626c6d521c6220c5089
BLAKE2b-256 f851d08d8d84d6ece744845a27e39c75df7389915d4f8d3e4ee84c6c67101fdf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.2-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bef3cb7b4b43035875db8b6d53c939dc9a5444c392c909dad4ebf2a60baa84a1
MD5 5ecbc1d42d69da1e76f0266b8036c08d
BLAKE2b-256 e225bbeee4d6eaa083864c5a191e1df5745615952e7e9148ba7b42b2efe7cbf7

See more details on using hashes here.

Provenance

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