Skip to content

Commit 1ea989d

Browse files
committed
MIPLearn v0.3
1 parent 6cc253a commit 1ea989d

File tree

172 files changed

+10495
-24812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+10495
-24812
lines changed

Diff for: .github/ISSUE_TEMPLATE/bug_report.md

-26
This file was deleted.

Diff for: .github/ISSUE_TEMPLATE/config.yml

-8
This file was deleted.

Diff for: .github/workflows/lint.yml

-11
This file was deleted.

Diff for: .github/workflows/test.yml

-27
This file was deleted.

Diff for: .gitignore

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
*.h5
2-
*.jld2
31
TODO.md
42
.idea
53
*.gz
@@ -80,6 +78,8 @@ wheels/
8078
notebooks/
8179
.vscode
8280
tmp
83-
benchmark/tsp
84-
benchmark/stab
85-
benchmark/knapsack
81+
benchmark/data
82+
benchmark/results
83+
**/*.xz
84+
**/*.h5
85+
**/*.jld2

Diff for: .mypy.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ disallow_untyped_defs = True
44
disallow_untyped_calls = True
55
disallow_incomplete_defs = True
66
pretty = True
7-
no_implicit_optional = True
7+
no_implicit_optional = True

Diff for: .pre-commit-config.yaml

-6
This file was deleted.

Diff for: .zenodo.json

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"creators": [
3+
{
4+
"orcid": "0000-0002-5022-9802",
5+
"affiliation": "Argonne National Laboratory",
6+
"name": "Santos Xavier, Alinson"
7+
},
8+
{
9+
"affiliation": "Argonne National Laboratory",
10+
"name": "Qiu, Feng"
11+
},
12+
{
13+
"affiliation": "Georgia Institute of Technology",
14+
"name": "Gu, Xiaoyi"
15+
},
16+
{
17+
"affiliation": "Georgia Institute of Technology",
18+
"name": "Becu, Berkay"
19+
},
20+
{
21+
"affiliation": "Georgia Institute of Technology",
22+
"name": "Dey, Santanu S."
23+
}
24+
],
25+
"title": "MIPLearn: An Extensible Framework for Learning-Enhanced Optimization",
26+
"description": "<b>MIPLearn</b> is an extensible framework for solving discrete optimization problems using a combination of Mixed-Integer Linear Programming (MIP) and Machine Learning (ML). MIPLearn uses ML methods to automatically identify patterns in previously solved instances of the problem, then uses these patterns to accelerate the performance of conventional state-of-the-art MIP solvers such as CPLEX, Gurobi or XPRESS."
27+
}

Diff for: CHANGELOG.md

+21-32
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,34 @@
1-
# MIPLearn: Changelog
1+
# Changelog
22

3-
## [0.2.0] - [Unreleased]
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.3.0] - 2023-06-08
9+
10+
This is a complete rewrite of the original prototype package, with an entirely new API, focused on performance, scalability and flexibility.
411

512
### Added
613

7-
- **Added two new machine learning components:**
8-
- Added `StaticLazyConstraintComponent`, which allows the user to mark some constraints in the formulation as lazy, instead of constructing them in a callback. ML predicts which static lazy constraints should be kept in the formulation, and which should be removed.
9-
- Added `UserCutComponents`, which predicts which user cuts should be generated and added to the formulation as constraints ahead-of-time, before solving the MIP.
10-
- **Added support to additional MILP solvers:**
11-
- Added support for CPLEX and XPRESS, through the Pyomo modeling language, in addition to (existing) Gurobi. The solver classes are named `CplexPyomoSolver`, `XpressPyomoSolver` and `GurobiPyomoSolver`.
12-
- Added support for Gurobi without any modeling language. The solver class is named `GurobiSolver`. In this case, `instance.to_model` should return ` gp.Model` object.
13-
- Added support to direct MPS files, produced externally, through the `GurobiSolver` class mentioned above.
14-
- **Added dynamic thresholds:**
15-
- In previous versions of the package, it was necessary to manually adjust component aggressiveness to reach a desired precision/recall. This can now be done automatically with `MinProbabilityThreshold`, `MinPrecisionThreshold` and `MinRecallThreshold`.
16-
- **Reduced memory requirements:**
17-
- Previous versions of the package required all training instances to be kept in memory at all times, which was prohibitive for large-scale problems. It is now possible to store instances in file until they are needed, using `PickledGzInstance`.
18-
- **Refactoring:**
19-
- Added static types to all classes (with mypy).
14+
- Add support for Python/Gurobipy and Julia/JuMP, in addition to the existing Python/Pyomo interface.
15+
- Add six new random instance generators (bin packing, capacitated p-median, set cover, set packing, unit commitment, vertex cover), in addition to the three existing generators (multiknapsack, stable set, tsp).
16+
- Collect some additional raw training data (e.g. basis status, reduced costs, etc)
17+
- Add new primal solution ML strategies (memorizing, independent vars and joint vars)
18+
- Add new primal solution actions (set warm start, fix variables, enforce proximity)
19+
- Add runnable tutorials and user guides to the documentation.
2020

2121
### Changed
2222

23-
- Variables are now referenced by their names, instead of tuples `(var_name, index)`. This change was required to improve the compatibility with modeling languages other than Pyomo, which do not follow this convention. For performance reasons, the functions `get_variable_features` and `get_variable_categories` should now return a dictionary containing categories and features for all relevant variables. Previously, MIPLearn had to perform two function calls per variable, which was too slow for very large models.
24-
- Internal solvers must now be specified as objects, instead of strings. For example,
25-
```python
26-
solver = LearningSolver(
27-
solver=GurobiPyomoSolver(
28-
params={
29-
"TimeLimit": 300,
30-
"Threads": 4,
31-
}
32-
)
33-
)
34-
```
35-
- `LazyConstraintComponent` has been renamed to `DynamicLazyConstraintsComponent`.
36-
- Categories, lazy constraints and cutting plane identifiers must now be strings, instead `Hashable`. This change was required for compatibility with HDF5 data format.
23+
- To support large-scale problems and datasets, switch from an in-memory architecture to a file-based architecture, using HDF5 files.
24+
- To accelerate development cycle, split training data collection from feature extraction.
3725

3826
### Removed
3927

40-
- Temporarily removed the experimental `BranchPriorityComponent`. This component will be re-added in the Julia version of the package.
41-
- Removed `solver.add` method, previously used to add components to an existing solver. Use the constructor `LearningSolver(components=[...])` instead.
28+
- Temporarily remove ML strategies for lazy constraints
29+
- Remove benchmarks from documentation. These will be published in a separate paper.
30+
4231

4332
## [0.1.0] - 2020-11-23
4433

45-
- Initial public release
34+
- Initial public release

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ DISCLAIMER
2222

2323
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424

25-
********************************************************************************
25+
********************************************************************************

Diff for: Makefile

+6-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ PYTHON := python3
22
PYTEST := pytest
33
PIP := $(PYTHON) -m pip
44
MYPY := $(PYTHON) -m mypy
5-
PYTEST_ARGS := -W ignore::DeprecationWarning -vv --log-level=DEBUG tests
6-
VERSION := 0.2
5+
PYTEST_ARGS := -W ignore::DeprecationWarning -vv --log-level=DEBUG
6+
VERSION := 0.3
77

88
all: docs test
99

@@ -24,11 +24,8 @@ docs:
2424
cd docs; make clean; make dirhtml
2525
rsync -avP --delete-after docs/_build/dirhtml/ ../docs/$(VERSION)
2626

27-
2827
install-deps:
2928
$(PIP) install --upgrade pip
30-
$(PIP) install --upgrade -i https://pypi.gurobi.com 'gurobipy>=9.5,<9.6'
31-
$(PIP) install --upgrade xpress
3229
$(PIP) install --upgrade -r requirements.txt
3330

3431
install:
@@ -41,9 +38,11 @@ reformat:
4138
$(PYTHON) -m black .
4239

4340
test:
41+
# pyflakes miplearn tests
42+
black --check .
4443
# rm -rf .mypy_cache
45-
# $(MYPY) -p miplearn
46-
# $(MYPY) -p tests
44+
$(MYPY) -p miplearn
45+
$(MYPY) -p tests
4746
$(PYTEST) $(PYTEST_ARGS)
4847

4948
.PHONY: test test-watch docs install dist

Diff for: README.md

+31-16
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,51 @@
1414
</a>
1515
</p>
1616

17-
**MIPLearn** is an extensible framework for solving discrete optimization problems using a combination of Mixed-Integer Linear Programming (MIP) and Machine Learning (ML).
17+
**MIPLearn** is an extensible framework for solving discrete optimization problems using a combination of Mixed-Integer Linear Programming (MIP) and Machine Learning (ML). MIPLearn uses ML methods to automatically identify patterns in previously solved instances of the problem, then uses these patterns to accelerate the performance of conventional state-of-the-art MIP solvers such as CPLEX, Gurobi or XPRESS.
1818

19-
MIPLearn uses ML methods to automatically identify patterns in previously solved instances of the problem, then uses these patterns to accelerate the performance of conventional state-of-the-art MIP solvers such as CPLEX, Gurobi or XPRESS. Unlike pure ML methods, MIPLearn is not only able to find high-quality solutions to discrete optimization problems, but it can also prove the optimality and feasibility of these solutions. Unlike conventional MIP solvers, MIPLearn can take full advantage of very specific observations that happen to be true in a particular family of instances (such as the observation that a particular constraint is typically redundant, or that a particular variable typically assumes a certain value). For certain classes of problems, this approach has been shown to provide significant performance benefits (see [benchmarks](https://anl-ceeesa.github.io/MIPLearn/0.1/problems/) and [references](https://anl-ceeesa.github.io/MIPLearn/0.1/about/)).
20-
21-
Features
22-
--------
23-
* **MIPLearn proposes a flexible problem specification format,** which allows users to describe their particular optimization problems to a Learning-Enhanced MIP solver, both from the MIP perspective and from the ML perspective, without making any assumptions on the problem being modeled, the mathematical formulation of the problem, or ML encoding.
24-
25-
* **MIPLearn provides a reference implementation of a *Learning-Enhanced Solver*,** which can use the above problem specification format to automatically predict, based on previously solved instances, a number of hints to accelerate MIP performance.
26-
27-
* **MIPLearn provides a set of benchmark problems and random instance generators,** covering applications from different domains, which can be used to quickly evaluate new learning-enhanced MIP techniques in a measurable and reproducible way.
28-
29-
* **MIPLearn is customizable and extensible**. For MIP and ML researchers exploring new techniques to accelerate MIP performance based on historical data, each component of the reference solver can be individually replaced, extended or customized.
19+
Unlike pure ML methods, MIPLearn is not only able to find high-quality solutions to discrete optimization problems, but it can also prove the optimality and feasibility of these solutions. Unlike conventional MIP solvers, MIPLearn can take full advantage of very specific observations that happen to be true in a particular family of instances (such as the observation that a particular constraint is typically redundant, or that a particular variable typically assumes a certain value). For certain classes of problems, this approach may provide significant performance benefits.
3020

3121
Documentation
3222
-------------
3323

34-
For installation instructions, basic usage and benchmarks results, see the [official documentation](https://anl-ceeesa.github.io/MIPLearn/).
24+
- Tutorials:
25+
1. [Getting started (Pyomo)](https://anl-ceeesa.github.io/MIPLearn/0.3/tutorials/getting-started-pyomo/)
26+
2. [Getting started (Gurobipy)](https://anl-ceeesa.github.io/MIPLearn/0.3/tutorials/getting-started-gurobipy/)
27+
3. [Getting started (JuMP)](https://anl-ceeesa.github.io/MIPLearn/0.3/tutorials/getting-started-jump/)
28+
- User Guide
29+
1. [Benchmark problems](https://anl-ceeesa.github.io/MIPLearn/0.3/guide/problems/)
30+
2. [Training data collectors](https://anl-ceeesa.github.io/MIPLearn/0.3/guide/collectors/)
31+
3. [Feature extractors](https://anl-ceeesa.github.io/MIPLearn/0.3/guide/features/)
32+
4. [Primal components](https://anl-ceeesa.github.io/MIPLearn/0.3/guide/primal/)
33+
5. [Learning solver](https://anl-ceeesa.github.io/MIPLearn/0.3/guide/solvers/)
34+
- Python API Reference
35+
1. [Benchmark problems](https://anl-ceeesa.github.io/MIPLearn/0.3/api/problems/)
36+
2. [Collectors & extractors](https://anl-ceeesa.github.io/MIPLearn/0.3/api/collectors/)
37+
3. [Components](https://anl-ceeesa.github.io/MIPLearn/0.3/api/components/)
38+
4. [Solvers](https://anl-ceeesa.github.io/MIPLearn/0.3/api/solvers/)
39+
5. [Helpers](https://anl-ceeesa.github.io/MIPLearn/0.3/api/helpers/)
40+
41+
Authors
42+
-------
43+
44+
- **Alinson S. Xavier** (Argonne National Laboratory)
45+
- **Feng Qiu** (Argonne National Laboratory)
46+
- **Xiaoyi Gu** (Georgia Institute of Technology)
47+
- **Berkay Becu** (Georgia Institute of Technology)
48+
- **Santanu S. Dey** (Georgia Institute of Technology)
49+
3550

3651
Acknowledgments
3752
---------------
38-
* Based upon work supported by **Laboratory Directed Research and Development** (LDRD) funding from Argonne National Laboratory, provided by the Director, Office of Science, of the U.S. Department of Energy under Contract No. DE-AC02-06CH11357.
39-
* Based upon work supported by the **U.S. Department of Energy Advanced Grid Modeling Program** under Grant DE-OE0000875.
53+
* Based upon work supported by **Laboratory Directed Research and Development** (LDRD) funding from Argonne National Laboratory, provided by the Director, Office of Science, of the U.S. Department of Energy.
54+
* Based upon work supported by the **U.S. Department of Energy Advanced Grid Modeling Program**.
4055

4156
Citing MIPLearn
4257
---------------
4358

4459
If you use MIPLearn in your research (either the solver or the included problem generators), we kindly request that you cite the package as follows:
4560

46-
* **Alinson S. Xavier, Feng Qiu.** *MIPLearn: An Extensible Framework for Learning-Enhanced Optimization*. Zenodo (2020). DOI: [10.5281/zenodo.4287567](https://doi.org/10.5281/zenodo.4287567)
61+
* **Alinson S. Xavier, Feng Qiu, Xiaoyi Gu, Berkay Becu, Santanu S. Dey.** *MIPLearn: An Extensible Framework for Learning-Enhanced Optimization (Version 0.3)*. Zenodo (2023). DOI: [10.5281/zenodo.4287567](https://doi.org/10.5281/zenodo.4287567)
4762

4863
If you use MIPLearn in the field of power systems optimization, we kindly request that you cite the reference below, in which the main techniques implemented in MIPLearn were first developed:
4964

Diff for: docs/Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
16
SPHINXOPTS ?=
27
SPHINXBUILD ?= sphinx-build
38
SOURCEDIR = .
49
BUILDDIR = _build
510

11+
# Put it first so that "make" without argument is like "make help".
612
help:
713
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
814

0 commit comments

Comments
 (0)