BilevelPy
An extensible Python framework for building, solving, and evaluating Gurobi-based optimization models, with built-in support for hub-location problems.
Project status: BilevelPy is an alpha release. Its public API may change before version 1.0.0.
Overview
BilevelPy provides reusable abstractions for implementing optimization models with Gurobi. It separates data preparation, model construction, solver execution, and solution extraction into focused components.
The current release includes:
- composable
VariableandConstraintclasses - dependency-aware model construction through
BaseModel - structured datasets and preprocessing pipelines
- configurable Gurobi execution and structured solutions
- built-in hub-location components
- CAB25 and CAB100 benchmark datasets
Installation
pip install bilevelpy
Requirements:
- Python 3.11–3.14
- Gurobi Optimizer 11.0 or newer
- a valid Gurobi licence
BilevelPy is licensed separately from Gurobi. Installing BilevelPy does not provide a licence for Gurobi Optimizer.
See the installation guide for development setup and further details.
Typical workflow
from bilevelpy import Dataset, ModelSolver
from bilevelpy.data.builder import DatasetBuilder
from bilevelpy.data.loaders import HLPLoader
from bilevelpy.data.processor import HLPNodeSelector
dataset = (
DatasetBuilder()
.pipe(HLPLoader(Dataset.CAB100))
.pipe(HLPNodeSelector(n_nodes=10))
.build()
)
# Define a BaseModel subclass with the required variables,
# constraints, and objective.
model = MyModel(data=dataset)
solution = ModelSolver(model).solve()
print(solution)
The quickstart tutorial contains a complete single-allocation hub-location model.
Documentation
- Installation
- Quickstart tutorial
- Architecture
- Dataset guide
- Model guide
- Solver guide
- Full pipeline example
- API reference
Research implementation
A complete research implementation built with BilevelPy is available in An Oracle-based Approach for Price-setting Problems in Logistics.
Citation
Citation metadata is available in CITATION.cff.
Changelog
See CHANGELOG.md for the release history.
Licence
BilevelPy is licensed under the Apache License 2.0.
Gurobi Optimizer and gurobipy are proprietary software distributed and
licensed separately by Gurobi Optimization, LLC.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bilevelpy-0.1.0.tar.gz.
File metadata
- Download URL: bilevelpy-0.1.0.tar.gz
- Upload date:
- Size: 93.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9544feee0648a16aa3ce1384a7ec99f57c1ff2798dc81429820eddaa6e8e4104
|
|
| MD5 |
73088de7cf359e95052251172bae83fd
|
|
| BLAKE2b-256 |
7e044fdda08c969fe4da3eb6fde5f77d484167b8041d5fcbda6c89782da53da1
|
File details
Details for the file bilevelpy-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bilevelpy-0.1.0-py3-none-any.whl
- Upload date:
- Size: 99.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.4.1 CPython/3.14.5 Windows/11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26a962c2b5fb14dee2dd32cb641eb93cd85e2aa68f0cfc71d69bdbce03deee90
|
|
| MD5 |
3496421577a1eefdcd263ca48e702186
|
|
| BLAKE2b-256 |
7d6c1b51370582fd6daed65cb091feefcdfb1aa416826609de29792ca2b84aeb
|