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}
}

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

s2mflow-0.1.4-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.4.tar.gz.

File metadata

  • Download URL: s2mflow-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 3ef3b2b47b0b79e800ab7406dbd70d800ac637335c0128ae24fb52f51f89e94d
MD5 8ae760797b801cca47fcd3aca74f7e34
BLAKE2b-256 c2ee606197737f066eafde046db87ec14667743c9441df8db494a9c0e7c8e4fa

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: s2mflow-0.1.4-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.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 af6917ec5f9f17a7a9b092e3fb941f1982c6c64398399906a34e2f7e7d959279
MD5 eeeb31c65850f38fe067d6edc65a25be
BLAKE2b-256 5a8d76dae8abb9a6d722138003862a367efc0c43c13148e991e9227c5a609f8d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.4-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 1f4689383353b4012f08e7a293fa72a4c71a0a20595dcf4acb9416e6acb833a0
MD5 9df85e93ca204e8986e147ed6a0e1688
BLAKE2b-256 3cd1301532d9844dbcc5bb8300b34745bec085b30810a2155f1eacbbfab4b681

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea545cea7a360bee723cbf609f724abfee23e6dd1eba276e6ec147508ccd973f
MD5 85175d0f99fc1b85fc2a66dc1f563ad5
BLAKE2b-256 dcd72358dc7fce7374dc2ce129ea5807e8ea116f3c801afec3a2a87cddc5b44d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.4-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 7a30dd72fe3c2d02757731eeef3bbae21cefe87b509db361cf1dc72be443e62e
MD5 848d667f7a4a1fcfcabeb9384ed743e1
BLAKE2b-256 3c6483b5a78051fc86c72a93b24eb2cebaa724987b63871a3dabcaf0140e9af5

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.4-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 45d76035a2aa6a06dd163edbe679938f9263ff9bafef9de9b9efef8bf8024ee3
MD5 dc3730c8c569aece9e9fa615baa58a98
BLAKE2b-256 84436a6ce4e8938547dae5ec4f9555e9450981acce3e1ef6adf4b752607e69b9

See more details on using hashes here.

Provenance

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