12 stable releases

2.0.3 Sep 10, 2024
2.0.1 Jun 20, 2024
1.3.0 Nov 16, 2021
1.0.4 May 18, 2021
1.0.2 Mar 2, 2021

#75 in Math

Download history 14/week @ 2024-07-29 11/week @ 2024-08-12 38/week @ 2024-08-26 317/week @ 2024-09-09 27/week @ 2024-09-16 66/week @ 2024-09-23 34/week @ 2024-09-30 13/week @ 2024-10-07 21/week @ 2024-10-14 9/week @ 2024-10-21 27/week @ 2024-10-28 9/week @ 2024-11-04

67 downloads per month
Used in 3 crates

MIT license

255KB
5.5K SLoC

grb GitHub tag (latest SemVer)

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.

This crate supports Gurobi 9.5, 10 and 11.

Installing and Linking

Before using this crate, you should install Gurobi and obtain a license.

Building

In this section, it is assumed Gurobi is installed at /opt/gurobi/linux64.

It is recommended you use the environment variables for your system's linker to ensure Gurobi can be found. For example, on Linux systems this can be done by appending the path to the lib subfolder of the gurobi installation to LIBRARY_PATH. For example, put

export LIBRARY_PATH="LIBRARY_PATH:/opt/gurobi/linux64/lib"

in your ~/.profile file. You can also set this in a PROJECT/.cargo/config.toml file on per project basis (see the [env] section).

The other option is to set the environment variable GUROBI_HOME set to the installation path of Gurobi (like eg /opt/gurobi95/linux64).

The Gurobi shared library will have the major and minor version of Gurobi in the library name. For example, Gurobi 11.0.* will have a shared library file libgurobi110.so. The grb-sys2 crate, which this crate depends on, will link against with -lgurobi110. On Linux, we make an guess for the library name based on GUROBI_HOME. If this guess is incorrect (or GUROBI_HOME is not set, or you are on Windows), you will need to the GUROBI_LIBNAME environment variable. For example, suppose you have the LIBRARY_PATH set to /opt/gurobi1003/linux64/lib (which contains libgurobi100.so), and GUROBI_HOME is not set. Then, you would set GUROBI_LIBNAME=gurobi100, so that the correct -lgurobi100 flag is emitted during compilation.

Running

When running the compiled binaries or running tests, you may get

error while loading shared libraries: libgurobi95.so: cannot open shared object file: No such file or directory

In this case, you need to set the LD_LIBRARY_PATH (on Windows I believe this is called PATH) environment variable or embed the path to libgurobi95.so in the rpath during compilation by supplying the appropriate linker flags in RUSTFLAGS.

For the example below, suppose Gurobi is in the path /opt/gurobi/linux64/lib/libgurobi95.so. You set LD_LIBRARY_PATH in the same manner as the LIBRARY_PATH variable, in your ~/.profile:

export LD_LIBRARY_PATH="LD_LIBRARY_PATH:/opt/gurobi/linux64/lib"

Documentation

Docs can be found on docs.rs

License

This software is released under the MIT license.

Dependencies

~1.4–1.9MB
~42K SLoC