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},
  year = {2026},
  url = {https://github.com/FelixBroesamle/s2mflow}
}

Resources

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.6.tar.gz (7.8 MB 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.6-cp313-cp313-win_amd64.whl (193.7 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

s2mflow-0.1.6-cp313-cp313-macosx_11_0_arm64.whl (295.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

s2mflow-0.1.6-cp313-cp313-macosx_10_12_x86_64.whl (305.7 kB view details)

Uploaded CPython 3.13macOS 10.12+ x86-64

s2mflow-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl (345.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.28+ x86-64

File details

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

File metadata

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

File hashes

Hashes for s2mflow-0.1.6.tar.gz
Algorithm Hash digest
SHA256 5eeb02a98da62fc6be525b211fcc4f6a3d8140152d29baccb0962270b189bc00
MD5 2a07e54901986360387b16257404c328
BLAKE2b-256 0ad0cc4efdfb3c016a9a4b455e242f8f00c3ce411759c7d198ee931d089840c0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: s2mflow-0.1.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 193.7 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9342c14011e068b589ef66dedfa79565fc220947a3a607f42603b65319db16ab
MD5 631c00e1ad1071bd389d9aae952ae234
BLAKE2b-256 2cc1b01e505fc028b5e4ee918b847f8a8778ec5d7546601dd5df6dc3bc45f8d6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.6-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3907ec68205f9348e2b649cf681dca76020ad39494bca4f1713318f9f958224c
MD5 19bbf2bc661485cf5802ed0685001b1b
BLAKE2b-256 49fb03988f72e65acc83d02f01b7c70beef46204ed1e732488eead757ed15d71

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e69830d34c07887e8457c2690abb5b1d3701f941a6e0cfd9f95e55fea4a2fff7
MD5 46587b75278643981179e856e5fc97c5
BLAKE2b-256 678bd450f9d59858ca6ab90f879248921f54dc98237de684e465ec5f21f27dd4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.6-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 a79549fd9ff346bb4e95e0b8a2c76a107ddf0a49c01332859f5e2c3e2018f9d3
MD5 5bb098eb58758fb7166a255b467722ce
BLAKE2b-256 c797dd16cafe98450d29c47c7b5f629cf18bda9ec4877e9e7d1a76973a2c4f4f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.6-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e0d376b8ab4f3f827336841a1ab65e8c61b451d7e7384324880a8dc730ad39b
MD5 ab2a9b3ce3fe0e5a63e92b959ab0c71d
BLAKE2b-256 ab342ad9ab9966633f21c6406cf624e84af1350a6b464258c3fb03f46bfaff55

See more details on using hashes here.

Provenance

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