5 releases (2 stable)

10.0.0 May 12, 2024
9.5.0 Apr 12, 2022
0.2.0 Jan 11, 2022
0.1.1 Feb 18, 2021
0.1.0 Feb 18, 2021

#18 in #declaration

Download history 17/week @ 2024-03-11 11/week @ 2024-03-18 31/week @ 2024-04-01 5/week @ 2024-04-08 24/week @ 2024-04-15 14/week @ 2024-04-22 9/week @ 2024-04-29 161/week @ 2024-05-06 61/week @ 2024-05-13 40/week @ 2024-05-20 9/week @ 2024-05-27 18/week @ 2024-06-03 15/week @ 2024-06-10 31/week @ 2024-06-17 12/week @ 2024-06-24

77 downloads per month
Used in 3 crates (via grb)

MIT license

20KB
581 lines

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

~14KB