• Stars
    star
    208
  • Rank 189,015 (Top 4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Formulate trained predictors in Gurobi models

build and test build wheel Python versions Black PyPI ReadTheDocs Gurobi-forum

Gurobi

Gurobi Machine Learning

Gurobi Machine Learning is an open-source python package to embed trained regression models in a gurobipy model to be solved with the Gurobi solver.

The package currently supports various scikit-learn objects. It has limited support for the Keras API of TensorFlow, PyTorch and XGBoost. Only neural networks with ReLU activation can be used with Keras and PyTorch.

Documentation

The latest user manual is available on readthedocs.

Contact us

For questions related to using Gurobi Machine Learning please use Gurobi's Forum.

For reporting bugs, issues and feature requests please open an issue.

If you encounter issues with Gurobi or gurobipy please contact Gurobi Support.

Installation

Dependencies

gurobi-machinelearning requires the following:

The current version supports the following ML packages:

Installing these packages is only required if the predictor you want to insert uses them (i.e. to insert a Keras based predictor you need to have tensorflow installed).

The up to date supported and tested versions of each package for the last release can be found in the documentation.

Pip installation

The easiest way to install gurobi-machinelearning is using pip in a virtual environment:

(.venv) pip install gurobi-machinelearning

This will also install the numpy, scipy and gurobipy dependencies.

Please note that gurobipy is commercial software and requires a license. When installed via pip or conda, gurobipy ships with a free license which is only for testing and can only solve models of limited size.

Getting a Gurobi License

Alternatively to the bundled limited license, there are licenses that can handle models of all sizes.

As a student or staff member of an academic institution you qualify for a free, full product license. For more information, see:

For a commercial evaluation, you can request an evaluation license.

Other useful resources to get started:

Development

We value any level of experience in using Gurobi Machine Learning and would like to encourage you to contribute directly to this project. Please see the Contributing Guide for more information.

Source code

You can clone the latest sources with the command:

git clone [email protected]:Gurobi/gurobi-machinelearning.git

Testing

After cloning the project, you can run the tests by invoking tox. For this, you will need to create a virtual environment and activate it:

python3.10 -m venv .venv
. .venv/bin/activate

Then, you can install tox (>= 3.26.0) and run a few basic tests:

(.venv) pip install tox
(.venv) tox -e py310,pre-commit,docs

tox will install, among others, the aforementioned ML packages into a separate venv. These packages can be quite large, so this might take a while.

Running the full test set

In the above command, we only ran a subset of tests. Running the full set of tests requires having a Gurobi license installed, and is done by running just the tox command without the -e parameter:

(.venv) pip install tox
(.venv) tox

If you don't have a Gurobi license, you can still run the subset of tests, open a PR, and Github Actions will run the tests with a full Gurobi license.

Submitting a Pull Request

Before opening a Pull Request, have a look at the full Contributing page to make sure your code complies with our guidelines.

More Repositories

1

modeling-examples

Gurobi modeling examples
Jupyter Notebook
624
star
2

gurobi-optimods

Data-driven APIs for common optimization tasks
Python
141
star
3

gurobi-logtools

Extract and visualize information from Gurobi log files
Python
100
star
4

gurobipy-pandas

Convenience wrapper for building optimization models from pandas data
HTML
95
star
5

pres-mipheur

Presentation: Custom MIP Heuristics
Jupyter Notebook
31
star
6

gurobi-modelanalyzer

Tools to analyze models for numerical issues
Python
17
star
7

docker-optimizer

The gurobi/optimizer image provides a base Docker image for building applications using any of the supported APIs (C, C++, Java, .NET, Python, MATLAB, and R), as well as the command line tools such as gurobi_cl and the Python shell. If you are planning to only use the Python API, we recommend using the gurobi/python image instead.
Python
12
star
8

gurobipy-stubs

Python
10
star
9

docker-compute

The gurobi/compute image provides a Docker image ready to be deployed as a Compute Server node.
Dockerfile
9
star
10

docker-modeling-examples

The gurobi/modeling-example image includes a Jupyter Notebook that allows you to browse and execute any of the Python modeling examples.
Dockerfile
9
star
11

docker-manager

The gurobi/manager image provides a Docker image ready to be deployed as a Cluster Manager.
Dockerfile
6
star
12

docker-python-example

Demonstrate how to use the Gurobi Python image as a base image.
Python
5
star
13

docker-python

The gurobi/python image provides a base Docker image for applications that use the Gurobi Python interface.
Python
4
star
14

techtalks

Additional material for our TechTalks
Python
3
star