Configuration of SNOPT
SNOPT (Sparse Nonlinear OPTimizer) is a general-purpose system for constrained optimization, which requires a license to be executed.
It minimizes a linear or nonlinear function subject to bounds on the variables and sparse linear or nonlinear constraints.
It is suitable for large-scale linear and quadratic programming and for linearly constrained optimization, as well as for general nonlinear programs.
Simple Tutorial in 2D
Apply the license
UCSD offers evaluations versions (for 3 months) of optimization libraries SNOPT7 and SQOPT7 for macOS, Windows and Linux systems. Click here to apply the license.
Donwload libraries
After receiving the email from USCD, we can click the link approached to the email to download the libraries in different versions. As I would like to use the C++ version, libsnopt7_cpp.so
has to be downloaded. Besides,
the C++ interface is compiled from the snopt-interface github repository. For Linux and MacOS, a C++ compiler must be used to link programs to the libraries above. For example,
if we would like to compile and execute a C++ example named myProb.cpp
:
1 | >> g++ -O -I$SNOPT/include -c myProb.cpp -o myProb.o |
Step by Step Tutorial
Actually, as for a beginner, we need to do some extra works to compile and execute the program successfully. Here I will provide a step-by-step tutorial to install and configure the SNOPT:
- Apply the license.
- Download snopt-interface github repository and extract in the
$HOME
folder. Then we can rename the folder to SNOPT. - Enter to the folder and create folders named lib and lic in it.
1 | >> cd SNOPT |
- Download the license approached to the UCSD email and move it to the lic folder.
- Download the library
libsnopt7_cpp.so
in Linux version from the links approached to the UCSD email and move it into the lib folder. - Edit the
~/.bashrc
file as follow:
1 | >> export SNOPT_LICENSE=$HOME/SNOPT/lic/snopt7.lic |
- Test if we configure the environment successfully by compiling and executing the routines in cppexamples folder.
1 | >> cd SNOPT/cppexamples |
If utilizing shared libraries .dylib/.so
, the location of the library files must be added to LD_LIBRARY_PATH
on Linux.
If the error libgfortran.so.4
required occurs, it means that gcc-7 and gfortran7 are required to be installed to meet the dependencies.
- Install gfortran7
1 | >> sudo add-apt-repository ppa:jonathonf/gcc-7.1 |
In the end, after compiling the linking the sntoya.cpp
, we get an executable file sntoya
. If no error throws while we execute it, it means the we configure SNOPT successfully.