- The
ma27
linear solver will be installed as part of theHSL
installation process. - The official installation document can be found here. This guide provides a more detailed version of the installation process.
From any directory, run the following commands to clone the ThirdParty-HSL
repository and navigate into it:
git clone [email protected]:coin-or-tools/ThirdParty-HSL.git
cd ThirdParty-HSL
-
Go to the STFC Portal.
-
Click
ORDER NOW
for theHSL Academic Licence
. You will need to create an account if you don’t have one. -
After logging in, download the appropriate
Coin-HSL
archive from your downloads section. -
Place the downloaded archive in the
ThirdParty-HSL/
directory and unpack the tarball:gunzip coinhsl-x.y.z.tar.gz tar xf coinhsl-x.y.z.tar
-
Rename the directory
coinhsl-x.y.z
tocoinhsl
or set up a symbolic link:mv coinhsl-x.y.z coinhsl
OR
ln -s coinhsl-x.y.z coinhsl
You can install Coin-HSL
either system-wide or in a specific folder.
-
Configure the installation. You can see available options with
./configure --help
../configure
-
Build the HSL library with:
make
-
Install the HSL library and header files with:
make install
Note: You may need to use
sudo
for the above commands (e.g.,sudo ./configure
,sudo make
,sudo make install
).
This method is useful if you are on a shared machine, like a server, or if you do not have sudo
access.
-
Let's say you want to install it to
$HOME/local
. -
Ensure that
$HOME/local
exists. If not, create it:mkdir -p $HOME/local
-
Configure the installation with the
--prefix
option:./configure --prefix=$HOME/local
-
Build and install:
make make install
-
Update your environment variables by adding the following lines to your
~/.bashrc
and then source it:
-
export PATH=$HOME/local/bin:$PATH
-
export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc echo 'export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc source ~/.bashrc
This step is required to link HSL
to Ipopt
.
-
System-wide:
sudo ln -s /usr/local/lib/libcoinhsl.so /usr/local/lib/libhsl.so
-
Specific folder:
ln -s $HOME/local/lib/libcoinhsl.so $HOME/local/lib/libhsl.so
If you have cyipopt
installed, you can validate the installation with the following Python script:
from cyipopt import minimize_ipopt
objective = lambda x: (x[0] - 1) ** 2 + (x[1] - 2.5) ** 2
gradient = lambda x: [2 * (x[0] - 1), 2 * (x[1] - 2.5)]
x0 = [2, 2]
res = minimize_ipopt(objective, x0, jac=gradient, options={"linear_solver": "ma27"})
print(res)
- If
HSL
is installed successfully along withma27
, you will see:
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit https://github.com/coin-or/Ipopt
******************************************************************************
message: b'Algorithm terminated successfully at a locally optimal point, satisfying the convergence tolerances (can be specified by options).'
success: True
status: 0
fun: 0.0
x: [ 1.000e+00 2.500e+00]
nit: 1
info: status: 0
x: [ 1.000e+00 2.500e+00]
g: []
obj_val: 0.0
mult_g: []
mult_x_L: [ 0.000e+00 0.000e+00]
mult_x_U: [ 0.000e+00 0.000e+00]
status_msg: b'Algorithm terminated successfully at a locally optimal point, satisfying the convergence tolerances (can be specified by options).'
nfev: 7
njev: 3
- Otherwise, you will see:
message: b'Invalid option encountered.'
success: False
status: -12
fun: 0.0
x: [ 2.000e+00 2.000e+00]
nit: 0
info: status: -12
x: [ 2.000e+00 2.000e+00]
g: []
obj_val: 0.0
mult_g: []
mult_x_L: [ 0.000e+00 0.000e+00]
mult_x_U: [ 0.000e+00 0.000e+00]
status_msg: b'Invalid option encountered.'
nfev: 0
njev: 0