9 stable releases

2.0.0 May 12, 2024
1.3.0 Nov 16, 2021
1.2.0 Oct 19, 2021
1.0.4 May 18, 2021
1.0.1 Feb 18, 2021

#82 in Math

Download history 35/week @ 2024-02-17 13/week @ 2024-02-24 12/week @ 2024-03-02 23/week @ 2024-03-09 15/week @ 2024-03-16 14/week @ 2024-03-23 25/week @ 2024-03-30 11/week @ 2024-04-06 29/week @ 2024-04-13 17/week @ 2024-04-20 14/week @ 2024-04-27 12/week @ 2024-05-04 205/week @ 2024-05-11 39/week @ 2024-05-18

273 downloads per month
Used in 2 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.3–1.8MB
~41K SLoC