Skip to content

Compiling HSL Libraries for use with NLPModelsAlgencan.jl

Ilan Francisco da Silva edited this page Jan 10, 2021 · 1 revision

This page documents how to compile HSL MA57 to use with Algencan (only MA57 for now).

  1. Get the source code from HSL from http://www.hsl.rl.ac.uk/catalogue/hsl_ma57.html. I only have access to the academic version, so this documentation is assuming that you have that version. Probably the code is the same for both the academic and paid version, so the documentation should work anyhow. After downloading the code you should have a file named hsl_ma57-5.2.0.tar.gz.

  2. Get the latest version of 4.0.X METIS from http://glaros.dtc.umn.edu/gkhome/fsroot/sw/metis/OLD. In my case I got the file metis-4.0.3.tar.gz.

  3. Grab the patches from the NLPModelsAlgencan.jl project page (it is in the deps/patches subdir).

  4. Put the sources and patches obtained above in a new directory that you created only for the compilation and move there.

  5. Unpack metis, compile it with -fPIC and save in the METISPATH variable its location. I did

    tar xvf metis-4.0.3.tar.gz
    cd metis-4.0.3
    make COPTIONS="-fPIC -O3"
    export METISPATH=$PWD
    cd ..
  6. Unpack hsl_ma57-5.2.0.tar.gz and patch it using the patch_ma57.txt and compile it. In my case I did

    tar xvf hsl_ma57-5.2.0.tar.gz
    cd hsl_ma57-5.2.0
    patch -p1 < ../patch_ma57.txt
    ./configure --with-metis=$METISPATH/libmetis.a --prefix=$PWD CFLAGS="-fPIC -O3" FCFLAGS="-fPIC -O3" FFLAGS="-fPIC -O3"
    make
    make install
    export MA57PATH=$PWD
    cd ..

    Obs: Note that we use the $METISPATH variable that was defined above to point to the METIS source.

    Obs2: If you want you can run a make check to verify the compilation.

  7. Unpack Algencan-3.1.1.tgz, apply the patch and compile.

    cd algencan-3.1.1
    patch -p1 < ../patch_algencan.txt
    make

    Obs: You may want to test Algencan with a CUTEst problem.

  8. Generate the shared library. From the top Algencan dir do:

    cd lib
    gfortran -shared -o libalgencan.so -Wl,--whole-archive libalgencan.a -Wl,--no-whole-archive -l gfortran -lblas -llapack
    export ALGENCAN_LIB_DIR=$PWD

Now you can install NLPModelsAlgencan.jl using in the package mode of Julia's REPL

(1.x) pkg> add NLPModelsAlgencan
julia> using NLPModelsAlgencan

Obs: If you installed Algencan before and compiled a new shared library it is better to uninstall it, garbage collect and then install it with the ALGENCAN_LIB_DIR pointing to the newly compiled library.

(v1.x) pkg> rm NLPModelsAlgencan
(v1.x) pkg> gc
(v1.x) pkg> add NLPModelsAlgencan
julia> using NLPModelsAlgencan
Clone this wiki locally