milptune
Automatic MILP solver configuration by learning problem similarities
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.5%) to scientific vocabulary
Keywords
Repository
Automatic MILP solver configuration by learning problem similarities
Basic Info
- Host: GitHub
- Owner: scale-lab
- License: bsd-3-clause
- Language: Python
- Default Branch: main
- Homepage: https://rdcu.be/dgSRv
- Size: 137 KB
Statistics
- Stars: 5
- Watchers: 0
- Forks: 0
- Open Issues: 9
- Releases: 0
Topics
Metadata Files
README.md
Automatic MILP Solver Configuration by Learning Problem Similarities
A large number of real-world optimization problems can be formulated as Mixed IntegerLinear Programs (MILP). MILP solvers expose numerous configuration parameters to controltheir internal algorithms. Solutions, and their associated costs or runtimes, are significantlyaffected by the choice of the configuration parameters, even when problem instances havethe same number of decision variables and constraints. On one hand, using the default solverconfiguration leads to suboptimal solutions. On the other hand, searching and evaluatinga large number of configurations for every problem instance is time-consuming and, insome cases, infeasible. In this study, we aim to predict configuration parameters for unseenproblem instances that yield lower-cost solutions without the time overhead of searching-and-evaluating configurations at the solving time. Toward that goal, we first investigate thecost correlation of MILP problem instances that come from the same distribution when solvedusing different configurations. We show that instances that have similar costs using one solverconfiguration also have similar costs using another solver configuration in the same runtimeenvironment. After that, we present a methodology based on Deep Metric Learning to learnMILP similarities that correlate with their final solutions’ costs. At inference time, given a newproblem instance, it is first projected into the learned metric space using the trained model, andconfiguration parameters are instantly predicted using previously-explored configurationsfrom the nearest neighbor instance in the learned embedding space. Empirical results onreal-world problem benchmarks show that our method predicts configuration parametersthat improve solutions’ costs by up to 38% compared to existing approaches.
Getting Started
0. Data Management
We use MongoDB as a data store solution. It helps in the MILP sampling process as well as in the deployment of learned models for inference. While model training does not require MongoDB, it is a central component for efficient storage and parallel execution of offline space exploration using SMAC.
So, as a first step, download and run MongoDB. You may also run it using the official Docker image here.
After successfully running a DB server, perform the following steps:
1. Create a database called milptunedb.
2. Create collections for each dataset with the dataset name. You should have 3 collections named: 1_item_placement, 2_load_balancing, and 3_anonymous. In addition, create a collection named milptune_metadata.
You may use MongoDB Compass to make data management easier from a GUI.
1. Download Code/Data
- In your home directory, download this repo to your home directory.
- Download dataset and trained model from the following link
- Extract downloaded data using
tar -xzv milptune-data.tar.gz - Copy trained models to the repository using
cp -r milptune-data/models MILPTune. This will add trained models and learned embeddings to themodelsfolder. - Import parameters configuration data (inside
milptune-data/dataset) to the database -- each in its corresponding collection. This step will import all the configurations explored during the offline exploration in this work. The database is queried with a MILP instance embedding to gets its stored parameters configurations and their associated costs. - Inside the
MILPTunedirectory, create a.envfile from.env.exampleand enter database server connection credentials. - Setup the environment according to the section below.
Environment Setup There are two options to set up the environment:
(1) using conda env create -n milptune -f conda.yaml to install dependencies in a new conda environment. Activate the environment using conda activate milptune. After that, run python setup.py install from inside the MILPTune directory to install the package.
or
(2) using the docker build -t milptune . to build an image with all dependencies encapsulated. Run the docker image using docker run -it -v <local-data-dir>:/data milptune. This also mount the downloaded data directory to /data inside the container to access cached data.
2. Run MILPTune
To predict a parameters configuration for a given problem instance, simply run:
```Python from milptune.configurator.knn import getconfigurationparameters from milptune.scip.solver import solve_milp
configs, distances = getconfigurationparameters(
instancefile=
solution, cost, time = solve_milp(
params=configs[0]['params'],
instance=
where <instance-file> is the MILP instance file in .mps format, <dataset-name> is the dataset to predict from (i.e. 1_item_placement, 2_load_balancing, or 3_anonymous). The parameters n_neighbors and n_configs instruct MILPTune to predict a single parameters configuration from the nearest neighbor.
If you are running from inside docker, the <instance-file> would be /data/<instance-file-path>.
Also, make sure that the MongoDB server is reachable from inside the container.
The function solve_milp calls the SCIP solver with the predicted parameters configuration and reports back the solution, cost (i.e. primal bound) and time.
There is also a helper script inside the evaluation folder:
Shell
python evaluation/configure.py <instance-file> <dataset-name>
Reproducing The Whole Training Process
1. Data Preprocessing
Data preprocessing is the step of converting all dataset instances into their bipartite graph representation and saving them in the database for the training pipeline.
This can be done using:
```Python from milptune.train.preprocess import index_bipartite
index_bipartite("
This will preprocess all instances in thetrain` directory of a dataset to its corresponding collection in the database.
2. Training
We provide the training script for each dataset in the models directory.
The scripts load data from the database and caches them locally in the first epoch, but then uses the cached tensors for the subsequent epochs.
3. Indexing Embeddings
After training, the collection of milptune_metadata needs to be populated with the necessary metadata for the trained model.
Below is the schema of the document:
```JSON
{
"
```
After that, embeddings of the training instances are indnexed back into the database for the nearest neighbor search process.
This can be achieved by: ```Python from milptune.train.index import index_embeddings
index_embeddings("<dataset-name") ```
4. Evaluation
Evaluation and comparison against the default configuration and against using SMAC can be found under evaluation/evaluate.py.
You can run it on a single instance using:
Shell
python evaluate.py <instance-path> <dataset-name> <output-dir>
We provide evaluate.sh to run the evaluation on all instances in a given directory using:
./evaluate.sh /path/to/dataset/valid/ <dataset-name> <output-dir>
Citation
@article{hosny2023automatic,
title={Automatic MILP solver configuration by learning problem similarities},
author={Hosny, Abdelrahman and Reda, Sherief},
journal={Annals of Operations Research},
pages={1--28},
year={2023},
publisher={Springer}
}
License
BSD 3-Clause License. See LICENSE file. See licenses of some used dependencies in the milptune folder.
Owner
- Name: Brown University Scale Lab
- Login: scale-lab
- Kind: organization
- Location: Brown University
- Website: https://scale-lab.github.io
- Repositories: 23
- Profile: https://github.com/scale-lab
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If this code helped your research, please cite it as below."
authors:
- family-names: "Hosny"
given-names: "Abdelrahman"
orcid: "https://orcid.org/0000-0003-4020-7973"
- family-names: "Reda"
given-names: "Sherief"
title: "Automatic MILP solver configuration by learning problem similarities"
version: 1.0.0
doi: 10.1007/s10479-023-05508-x
date-released: 2023-07-14
url: "https://github.com/scale-lab/MILPTune"
preferred-citation:
type: article
authors:
- family-names: "Hosny"
given-names: "Abdelrahman"
orcid: "https://orcid.org/0000-0003-4020-7973"
- family-names: "Reda"
given-names: "Sherief"
doi: "10.1007/s10479-023-05508-x"
journal: "Annals of Operations Research"
month: 7
start: 1 # First page number
end: 28 # Last page number
title: "Automatic MILP solver configuration by learning problem similarities"
year: 2023
publisher: Springer
GitHub Events
Total
- Watch event: 3
Last Year
- Watch event: 3
Dependencies
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/checkout v1 composite
- actions/download-artifact v2 composite
- actions/setup-python v3 composite
- actions/upload-artifact v2 composite
- softprops/action-gh-release v1 composite
- actions/checkout v1 composite
- continuumio/miniconda3 latest build
- Sphinx >=4.3.0,<4.6.0 development
- black ==22.3.0 development
- flake8 * development
- furo ==2022.3.4 development
- isort ==5.10.1 development
- mypy ==0.942 development
- myst-parser >=0.15.2,<0.18.0 development
- packaging * development
- pytest * development
- pytest-cov * development
- pytest-sphinx * development
- setuptools * development
- sphinx-autobuild ==2021.3.14 development
- sphinx-autodoc-typehints * development
- sphinx-copybutton ==0.5.0 development
- twine >=1.11.0 development
- wheel * development