Skip to main content

Model-Based Local Search algorithm designer built on Routix

Project description

mbls

A Python toolkit for Model-Based Local Search (MBLS) algorithm design, built on top of Routix. This library provides a modular framework for orchestrating subroutines, managing experimental runs, and integrating mathematical models into heuristic search routines, with a focus on CP-SAT (OR-Tools) integration.

Features

  • Modular Architecture: Compose and extend LNS-style or hybrid metaheuristics using reusable subroutine components.
  • CP-SAT Integration: Ready-to-use classes for fixed and optional interval scheduling, custom CP models, and modern solution progress logging.
  • Experiment Management: Leverage Routix for structured routine execution, logging, timers, and experiment summarization.
  • Extensible Modeling Layer: Easily add custom models, constraints, or solvers for new problem domains.
  • Objective Tracking: Built-in utilities for tracking objective values and bounds over time, with type-safe callback recorders.
  • Visualization Tools: Painter module for objective value and time series plotting.

Installation

pip install mbls
  • Requires Python 3.11
  • Core dependency: routix
  • For CP-SAT features: ortools

Quick Example

from mbls.cpsat import CustomCpModel, ObjectiveValueRecorder, ObjectiveBoundRecorder

model = CustomCpModel()
# Define variables, constraints, and objective
# ...

# Attach recorders for progress logging
model.init_solver(computational_time=10.0, num_workers=4) # recorders are attached automatically
cp_solver_status = model.solver.solve(
    model, solution_callback=model.obj_value_recorder
)

# Access logs:
print(model.obj_value_recorder.elapsed_time_and_value)
print(model.obj_bound_recorder.elapsed_time_and_bound)

Extending mbls

mbls is designed for research and experimentation. You can:

  • Subclass CpSubroutineController to define custom LNS or hybrid metaheuristics
  • Extend CustomCpModel or use CpModelWithFixedInterval / CpModelWithOptionalFixedInterval for new scheduling domains
  • Compose repeatable flows with structured routine names and modular inputs

Project Structure

src/mbls/
    __init__.py
    solver_status.py
    cpsat/
        __init__.py
        callbacks/
            __init__.py
            objective_value_recorder.py
            objective_bound_recorder.py
            search_stopper.py
        cp_model_with_fixed_interval.py
        cp_model_with_optional_fixed_interval.py
        cp_subroutine_controller.py
        custom_cp_model.py
        obj_value_bound_store.py
        solver_report.py
        status.py
        solution_progress_logger.py  # (deprecated)
    painter/
        __init__.py
        obj_value_bound_plotter.py
        time_series_plotter.py

tests/
    test_custom_cp_model.py
    test_cp_subroutine_controller.py
    test_objective_recorders.py
    test_obj_value_bound_store.py
    test_solver_report.py
    ...

Notes

  • All progress logging and callback utilities are now routed through ObjectiveValueRecorder and ObjectiveBoundRecorder.
  • The legacy SolutionProgressLogger is deprecated. solution_progress_logger.py is retained for reference only.
  • The codebase is fully type-annotated and tested with pytest.

License

MIT License

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

mbls-0.0.12.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mbls-0.0.12-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file mbls-0.0.12.tar.gz.

File metadata

  • Download URL: mbls-0.0.12.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for mbls-0.0.12.tar.gz
Algorithm Hash digest
SHA256 b42a92c4306a77ab3b8632e801e5f8e153a8423cf7ab3e8df1359166db4d4836
MD5 6717d19c4944d616e88ccf6eea98a49f
BLAKE2b-256 84acbb19692706a873ae84ad1d21a66698ef7e64be4ed87b6920fbfe36dd8f26

See more details on using hashes here.

File details

Details for the file mbls-0.0.12-py3-none-any.whl.

File metadata

  • Download URL: mbls-0.0.12-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.2

File hashes

Hashes for mbls-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 c51445bf60255b18679c41ccc4632d15f1c7c7ed6e6686066a3298421448c146
MD5 5729ba99dcf5308f305948559005c39c
BLAKE2b-256 be8918c6e3a1fe551c585c9da3e851c6ec7e10970b96f6a62ff830b8658ccbb9

See more details on using hashes here.

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