Skip to main content

mlafactory

PyPI version License: BSD-3 Python 3.11+

mlafactory is an open-source discrete-event simulation framework for modeling Multi-Level Assembly (MLA) manufacturing systems. Built on top of SimPy, it enables flexible simulation of factories with dynamic inventory management, heterogeneous machine pools, stochastic order arrivals, and configurable production and replenishment policies.

The framework is designed for research, experimentation, and reproducible evaluation of manufacturing strategies.


Features

  • Multi-level bill of materials (BOM) — recursive assembly of products from sub-components and raw materials
  • Heterogeneous machine pools — multiple machine types with configurable setup times, cycle times, and costs
  • Dynamic inventory management — min/max stock policies with async waiting and automatic replenishment
  • Stochastic order arrivals — fixed, random, spread, or distribution-based inter-order intervals
  • Configurable replenishment — per-component reorder delays for raw materials
  • Multiple inventory initialization strategies — zero, min, max, or random initial stock levels
  • Rich reporting — production service levels, machine utilization, and inventory summaries exported as CSV
  • CLI and Python API — run simulations without writing code or integrate programmatically
  • YAML / JSON configuration — fully reproducible experiments via configuration files

Requirements

  • Python 3.11+
  • SimPy >= 4.0
  • NumPy
  • pandas
  • PyYAML

Installation

pip install mlafactory

Install from source:

git clone https://gitlab.com/uniluxembourg/hpc/research/cadom/mla_factory.git
cd mla_factory
pip install -e .

Quick Start

Command Line

The CLI uses the bundled example configuration when no input options are provided. Print a summary with:

mlafactory --print-summary

Run a custom YAML or JSON configuration:

mlafactory --factory-config my_factory.yml --print-summary

Python API

from mlafactory import FactoryRunner

runner = FactoryRunner.from_config("my_factory.yml")
result = runner.run()

print(result.fulfillment_ratio)
print(result.production)  # pandas DataFrame, including a TOTAL row

# Score a run directly. "production" aliases total "produced_qty".
score = runner.run_objective("fulfillment_ratio")

To configure a runner in Python, create a FactoryConfig and RunOptions:

from mlafactory.config.config import FactoryConfig, RunOptions
from mlafactory import FactoryRunner

# config_data is a mapping with the fields in the sample YAML/JSON file.
# congid_data must contain 'orders', 'bom', 'initial_inventory', 'machines', 'inventory_policy_bounds', and 'supplier_lead_times'
config = FactoryConfig.from_dict(config_data)
options = RunOptions(print_summary=True)
runner = FactoryRunner(config, options)
result = runner.run()

The full sample configurations are min_example.yaml and min_example.json.


Documentation

Additional documentation is available in docs/:

File Description
docs/cli.md Additional command-line usage notes
docs/simulation_model.md Simulation architecture and event flow

Configuration

Use one YAML or JSON configuration file with these top-level sections:

  • orders: mapping of order IDs to product quantities
  • bom: products and components, each with a machine type and nested bom
  • machines: machine names, types, setup/cycle times, and optional costs
  • supplier_lead_times: raw material reorder delays
  • inventory_policy_bounds: min and max stock limits for every BOM or supplier item
  • initial_inventory: optional explicit starting stock
  • Optional run settings include factory_name, months, hours_per_month, seed, inventory_strategy, order_mode, and order_mode_params

For complete, valid examples, see min_example.yaml or min_example.json. Machine setup and cycle times are expressed in minutes; the simulation duration and reorder delays use simulation-time hours.

Order interval modes are fixed, random, spread, and distribution. Distribution mode supports poisson and normal. The configured seed controls random initial inventory and stochastic order intervals.

To export CSV reports, set export_reports: true in the configuration or pass --export-reports; choose the destination with output_dir or --output-dir. The CLI options --print-summary, --debug-logs, and --export-reports enable their respective outputs.


Project Structure

mlafactory/
├── src/mlafactory/
│   ├── cli.py                  # command-line entry point
│   ├── runner.py               # public simulation orchestrator
│   ├── config/                 # configuration, validation, and reporting
│   ├── examples/               # bundled YAML/JSON configurations
│   ├── optimization/           # stock-policy optimization adapter
│   ├── scenario/               # initial inventory and order scheduling
│   └── sim/                    # SimPy simulation entities
├── docs/
├── tests/
└── README.md

Running Tests

pip install -e ".[test]"
python -m pytest

License

BSD 3-Clause License. See LICENSE for details.


Citation

To be completed.


Authors

Developer and maintainer:

Oscar J. Castro-Lopez: Research Associate, University of Luxembourg

Contributors:

  • Pierrick Pochelu DevOps, LuxProvide
  • Georgios Kafanas Infrastructure and Architecture Engineer, University of Luxembourg

Contributions welcome — please open an issue or pull request on GitLab.

Acknowledgements

This project was created with the support of the Luxembourg National Research Fund (FNR) under project 17941664. Supported by the Ministry of Economy (MECO) under project 17941664.

Metadata

Release files for mlafactory 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mlafactory 0.2.3
File Size Uploaded Provenance Actions
mlafactory-0.2.3.tar.gz 49.9 kB Without provenance Details for mlafactory-0.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mlafactory 0.2.3
File Interpreter ABI Platform Actions
mlafactory-0.2.3-py3-none-any.whl Python 3 none any Details for mlafactory-0.2.3-py3-none-any.whl

Total release size: 94.6 kB

Release files / mlafactory-0.2.3.tar.gz

Download URL mlafactory-0.2.3.tar.gz
Size 49.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7c8929ff039683e38d6c513c491c0644c2a64d34680d88d9a1de61bad5c58128
BLAKE2b-256 checksum
How to use checksums
ec1281647c79de20b4f6aa92d70771c285ef75c8c6bcba854732576a400f9c9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Release files / mlafactory-0.2.3-py3-none-any.whl

Download URL mlafactory-0.2.3-py3-none-any.whl
Size 44.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
644d8dc5cf612171d86e088c605c67223b5a5cae33db30cf3faa57e8c99db556
BLAKE2b-256 checksum
How to use checksums
a8358b106f011f5dbc5004735efc125697e454736fb6d6955ae9943e4af7d6a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.5

Security for mlafactory 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page