Compiling

SHOT is programmed in C++ 17, and the build system is based on CMake. Here are some instructions for compiling SHOT.

Getting the dependencies

To compile SHOT you need to have the following component libraries available on your system.

  • A solver for mixed-integer linear programming (MILP) problems. SHOT supports the open-source solver Cbc (2.10 or newer), and the commercial solvers CPLEX (12.8 or newer) and Gurobi (8.0 or newer). If you are an academic user, you can download free versions of both CPLEX and Gurobi.

  • A solver for nonlinear programming (NLP) problems. SHOT currently supports only Ipopt (3.12 or newer). If you call SHOT from GAMS or by reading a GAMS-model file in SHOT, you can also use any licensed NLP solver available in GAMS.

Compiling Cbc

Instructions for compiling Cbc available at https://github.com/coin-or/Cbc/.

Compiling Ipopt

Instructions for compiling Ipopt available at https://github.com/coin-or/Ipopt.

Downloading the source code

Clone SHOT with git

git clone https://www.github.com/coin-or/SHOT --recursive

or manually downloading the source code from Github.

Note that there are dependencies in SHOT that utilize git submodule functionality; this is the reason for the --recursive flag, which will automatically clone these dependencies as well.

Configuring and compiling SHOT

SHOT utilizes CMake to generate the build system. The settings for CMake are specified in the file CMakeLists.txt that is available in the root SHOT folder you downloaded in step 2.

Normally you would not need to edit the CMakeLists.txt file; instead settings can be provided as arguments when calling CMake.

You can use the following arguments to configure SHOT:

So to compile a completely free version of SHOT you can issue the following commands:

git clone https://www.github.com/coin-or/SHOT
cd SHOT
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release \
  -DHAS_CBC=on -DCBC_DIR=/opt/cbc \
  -DHAS_IPOPT=on -DIPOPT_DIR=/opt/ipopt ..

Compiling on Windows

Note that compiling SHOT (and its dependencies) on Windows might be challenging. Recommended options on Windows is to either use Windows Subsystem for Linux or MSYS2, for which similar steps as above can be used.

If you want to use MSYS2, instructions are available at https://github.com/coin-or/SHOT/issues/11#issuecomment-569580328.

Installing using CMake

After compiling SHOT, you can use make install to install SHOT (including the binary, library and header files) to your system. By default the install is made into /usr/local on a Linux-system. If you want to change this, you can substitute the call to CMake above with:

cmake \
  -DCMAKE_INSTALL_PREFIX=/path/to/install/dir \
  -DCMAKE_BUILD_TYPE=Release \
  -DHAS_CBC=on -DCBC_DIR=/opt/cbc \
  -DHAS_IPOPT=on -DIPOPT_DIR=/opt/ipopt ..

and after this run make install. Note that you will need to add /path/to/install/dir/bin to your path and /path/to/install/dir/lib to your library search path (LD_LIBRARY_PATH on Linux.

Creating an installation package using CPack

You can also (only tested on Linux) create installation packages (ZIP or a self-extracting installation program) using CPack (which is a part of CMake).

To create installation files directly in the build directory, just execute the command make package or cpackafter the steps above have completed.

Integrate SHOT with GAMS

Build the SHOT library as in discussed above, but make sure to pass the GAMS system directory to the cmake call via -DGAMS_DIR=.

Then add the following entry to gmscmpun.txt (gmscmpnx.txt on Windows) in the GAMS system directory:

SHOT 1101 5 0001020304 1 0 2 MINLP MIQCP 
gmsgenus.run 
gmsgenux.out 
/path/to/libSHOTSolver.so sht 1 1 

Last updated