8 stable releases
1.3.0 | Nov 16, 2021 |
---|---|
1.2.0 | Oct 19, 2021 |
1.0.4 | May 18, 2021 |
1.0.3 | Apr 19, 2021 |
1.0.1 | Feb 18, 2021 |
#320 in Math
127 downloads per month
Used in 2 crates
220KB
4.5K
SLoC
grb

This crate provides Rust bindings for Gurobi Optimizer. It currently requires Gurobi 9.0 or higher.
This library started as fork of the gurobi
which appears to be no longer maintained.
It has since undergone a number of fundamental API changes.
Installing and Linking
- Before using this crate, you should install Gurobi and obtain a license.
Building
Make sure that the environment variable GUROBI_HOME
is set to the installation path of Gurobi
(like C:\gurobi911\win64
or /opt/gurobi911/linux64
). If you are using the Conda package
from the Gurobi channel, the build script will fall back to GUROBI_HOME=${CONDA_PREFIX}
, so you
should not set GUROBI_HOME
.
Running
When running the compiled binaries or running tests, you may get
error while loading shared libraries: libgurobi91.so: cannot open shared object file: No such file or directory
In this case, you need to set the LD_LIBRARY_PATH
environment variable or embed the path to libgurobi.so
in the
rpath by supplying the appropriate linker flags in RUSTFLAGS
.
For the examples below, suppose Gurobi is in the path /opt/gurobi/linux64/libgurobi91.so
Method #1: LD_LIBRARY_PATH
cargo build
export LD_LIBRARY_PATH="/opt/gurobi/linux64/:${LD_LIBRARY_PATH}"
target/debug/my_program # or: cargo test
LD_LIBRARY_PATH
will need to be set every time the binary is run in a new shell session. If you use conda environments,
this is the recommended approach (see here).
Method #2: rpath
export RUSTFLAGS="-C link-args=-Wl,-rpath=/opt/gurobi/linux64/"
cargo build
target/debug/my_program # or: cargo test
This has the advantage that you don't need to set anything when you want to run the binary in a new shell
session. On the other hand, the path to Gurobi is baked into my_program
, so it is no longer portable.
Documentation
Docs can be found on docs.rs
License
This software is released under the MIT license.
Dependencies
~0.8–1.4MB
~30K SLoC