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=3,
    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.1.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.1-cp313-cp313-win_amd64.whl (193.6 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13manylinux: glibc 2.28+ ARM64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.13macOS 10.12+ x86-64

s2mflow-0.1.1-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.1.tar.gz.

File metadata

  • Download URL: s2mflow-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 f7977a543081fe9a0d9fc54312c8437613e0c649712e506cbe075b7a54f58d6e
MD5 1a754fbbc8e884bda4dc534e7411efe7
BLAKE2b-256 b05413c2cd511e060f1a81d17a75211acaa67e018bc1011975e67cc8d77168c5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: s2mflow-0.1.1-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.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 77295d1ad34353e733e81b5d3b9e1adc6441c2766990521b0b409c56b1a0c69d
MD5 764121a3a0799dec065fe6da689ffb10
BLAKE2b-256 f98ee1cad7cd6b01baa1e64f88a9982cdd3613d29e5dca14a4c298a3627bd629

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.1-cp313-cp313-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e6fa54c6e9b9e02f87196586729b1a80971c9a8a766cf71439a8430cc0a5242d
MD5 32eefa97577aa1d46e8b71fe53351d50
BLAKE2b-256 f74d2659a8f16b24f5a2cfc9fbf57de1e8e65ac42e1a92a53ef873ce59aec6a6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 151769f1d2468b7eb44be04270f61bf5730282068be31ed80d1f08db792d2c2a
MD5 77d9dbbbdb8da062a910d4f976c3e5c9
BLAKE2b-256 fa283bca924fd19bc059ac4ab17a318c991a110710c92fa9fae22b41c09bdbb2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.1-cp313-cp313-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 014ae812eef7538118ffce215be550a6ca4518eb48dd664c9e74e0030cd75597
MD5 f9d6f0d99f628467d94534dc763223db
BLAKE2b-256 73a7343624e5b88514a261d6082ea2262b1b13bd1fe6f539f91e24302bfc7e7d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for s2mflow-0.1.1-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 10de19735019273238819843a2a94aae7488624026dc33665759ec737318322b
MD5 a4dc3c979792a897529fd9101078f36c
BLAKE2b-256 5ef327cca605c85d02dde3f3d22dda959e2d0f1b48f72fd0a7c34bfd7535f84d

See more details on using hashes here.

Provenance

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