-
Notifications
You must be signed in to change notification settings - Fork 391
Obtaining HSL
The IPOPT solver comes with a feature to detect the presence of 'libhsl.so'/'libhsl.dll' at runtime. Here is a report on how to obtain this 'libhsl.so'/'libhsl.dll'.
The following instructions work on Linux/Mac and Msys environment on Windows.
- Make sure that BLAS, LAPACK and a Fortran compiler are installed on your system (on Ubuntu/Debian systems, you can install these by running
sudo apt-get install libblas3gf libblas-dev liblapack3gf liblapack-dev gfortran
and for Ubuntu >= 16.04sudo apt-get install libblas3 libblas-dev liblapack3 liblapack-dev gfortran
). - Obtain the proprietary source coinhsl package from http://www.hsl.rl.ac.uk/ipopt/. When filling out the forms, please mention that you plan to use the routines with Ipopt/CasADi. Note that, unfortunately, we cannot guarantee the stability of using the newer linear solvers (MA57, MA77, MA86 and MA97 that are only free for academics) since HSL has not granted us any maintenance license.
⚠️ Make sure that you download thecoinhsl-2022-11-09
package, not the 2023 one. These instructions only work with the 2022 version (and presumably earlier ones). The 2023 package does not contain theconfigure
script we use here.
-
wget http://glaros.dtc.umn.edu/gkhome/fetch/sw/metis/OLD/metis-4.0.3.tar.gz
-
tar -xvf metis-4.0.3.tar.gz
-
Unpack the coinhsl package and navigate into the resutling coinhsl sources folder.
-
mv ../metis-4.0.3 .
(For OSX inloadmetis/loadmetis.c
change#define SHLIBEXT "so"
to#define SHLIBEXT "dylib"
) -
$> ./configure --prefix=(where_you_want_to_install) LIBS="-llapack" --with-blas="-L/usr/lib -lblas" CXXFLAGS="-g -O2 -fopenmp" FCFLAGS="-g -O2 -fopenmp" CFLAGS="-g -O2 -fopenmp"
(For Windows, make sure to use forward slashes in paths. Also for Windows, you probably need to compile and include -lcoinblas and -lcoinlapack as well.) -
$> make
-
$> make install
-
Create a symbolic link from libcoinhsl.so to libhsl.so (libcoinhsl.dylib -> libhsl.dylib on OSX):
$> ln -s (hsl_install_directory)/libcoinhsl.so (hsl_install_directory)/libhsl.so
Tested on MacOS 12.3.1 - Intel core i5
Preliminary: make sure have brew
, a packet manager for MacOS.
- Run
brew install gcc
brew install gfortran
brew install metis
The libraries blas
and lapack
are already shipped in MacOS in the Accelerate Framework.
- Obtain the proprietary source coinhsl package from http://www.hsl.rl.ac.uk/ipopt/. When filling out the forms, please mention that you plan to use the routines with Ipopt/CasADi. Note that, unfortunately, we cannot guarantee the stability of using the newer linear solvers (MA57, MA77, MA86 and MA97 that are only free for academics) since HSL has not granted us any maintenance license.
- From coin-or-ipopt-guide follow the instructions HSL (Harwell Subroutines Library). Therefore run
git clone https://github.com/coin-or-tools/ThirdParty-HSL.git
cd ThirdParty-HSL
- Unpack the HSL sources archive, move and rename the resulting directory so that it becomes
ThirdParty-HSL/coinhsl
. - Add the following lines to your Bash profile (e.g.
.zshrc
) in order to compile withgcc
(MacOS deafult isclang
).
export CC=/usr/local/bin/gcc-12
export CXX=/usr/local/bin/g++-12
alias gcc=/usr/local/bin/gcc-12
alias cc=/usr/local/bin/gcc-12
- Open a new terminal in order to make effective the changes of your Bash profile. Then, run
./configure --prefix=(where_you_want_to_install) --with-metis-cflags=-I/usr/local/Cellar/metis/5.1.0/include --with-metis-lflags="-L/usr/local/Cellar/metis/5.1.0/lib -lmetis" CXXFLAGS="-g -O2 -fopenmp" FCFLAGS="-g -O2 -fopenmp" CFLAGS="-g -O2 -fopenmp" LDFLAGS="-fopenmp"
make
make install
- Create a symbolic link from
libcoinhsl.dylib
tolibhsl.dylib
:
ln -s (hsl_install_directory)/lib/libcoinhsl.dylib (hsl_install_directory)/lib/libhsl.dylib
- Restore your Bash profile by deleting the rows added at point 4.
Obtain pre-compiled libraries as a tar/zip file from http://www.hsl.rl.ac.uk/ipopt/ Note that the Win32 bit version works fine on a 64 bit machine, too.
Note: Some users reported that they had problems using the pre-compiled binaries. So in case you first try the pre-compiled binaries and fail with them, you probably have to wait an additional day until you can use the solvers since you have to request a different download link for the source files.
Once you have the solvers, you should just append the directory where it resides to the LD_LIBRARY_PATH
environment variable (or DYLD_LIBRARY_PATH on OSX
, or PATH on Windows).
The most common way to set LD_LIBRARY_PATH=(hsl_install_directory)
, or DYLD_LIBRARY_PATH
for OSX users, is to add something like this to your .bashrc
or .bash_profile
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:(hsl_install_directory/lib)
Note: if you use CasADi from Matlab, do check if your env variable is correctly passed on getenv('LD_LIBRARY_PATH')
. If it's not, try firing up Matlab from a terminal where that variable is set correctly.
On Ubuntu/Debian systems, if you configured the compilation of the solvers with --prefix=/usr
, this step 2 is not necessary.
Since you went to the trouble of compiling with -fopenmp
, you should export OMP_NUM_THREADS=7
or something so that HSL knows to go faster.