[Ipopt] How a novice installed Ipopt for Windows 10 64-bit, with HSL linear solvers, for use with R interface Ipoptr

Don Boyd donboyd5 at gmail.com
Sat Jun 10 08:04:22 EDT 2017


Hi,

This note is NOT a question. Its purpose is to help other novices who may
have similar goals to mine. Some of the settings I used/learned of may be
useful to others.

I thank Tony Kellman and Stefan Vigerske for advice that led to success,
and Tony for relentlessly following up.

I am happy to provide further details if anyone wants. I am happy to
edit/improve the explanation if more-experience users point out things that
could be improved or where I am using terminology imprecisely.

Don




My goals were:

 1. Compile Ipopt library for Windows 10 64-bit, in a manner that will me
to compile the R interface, Ipoptr, so that I can call Ipopt from R.
 2. Compile the HSL linear solvers (coinhsl-2014.01.10.zip, academic
license) with Ipopt, in addition to Mumps. Ideally allow them to run in
parallel.
 3. Compile using the same MinGW compilers that are used by R to compile
Ipoptr. These are the Rtools compilers that were already installed on my
system.
 4. Compile with the Blas and Lapack dll libraries included with R, to
avoid any possible conflict among versions.
 I am not SURE steps 3 and 4 were essential, but I wanted to avoid
potential incompatibilities

MANY things went wrong, largely because I don't really understand configure
and make well enough to tell gcc what tools to use and how, and where to
find them. I was like a monkey randomly choosing path statements, configure
options, compiler flags, linker flags, and other settings I didn't
understand. Finally I asked for and received advice.

Here are the key steps that were critical to success:

1. Cleaning up my environment - getting rid of unnecessary compilers or
path directories pointing to unneeded compilers. As a novice, I found the
free Rapid Environment Editor (https://www.rapidee.com) less intimidating
than Windows tools.

2. Getting rid of Msys1.0 and using Msys2.0 (http://www.msys2.org/).

Only thing I had to do in addition to the installation instructions, was
install make.exe (pacman -S make).

After installation I put msys on the path (c:\msys64\usr)

I'm sure installation can be done with Msys1.0, also, but apparently it is
buggy and Msys2.0 is nicer.

3. Putting an export PATH statement in my script telling the system where
to find my Rtools MinGW compilers. Here is the one I used:

export PATH=/c/Rtools/mingw_64/bin:$PATH

I also have the following in my Windows path:

C:\Rtools\mingw_64

Honestly, I don't know if both are needed.

4. Properly defining location and use of Blas and Lapack libraries:

a. I had to tell configure that I needed BOTH Blas and Lapack. (The HSL
documentation speaks only of Blas, and perhaps that is all that is needed,
but when I compiled with Ipopt rather than as dll, apparently I needed
both.)

b. I needed to use linker flags rather than the --with-blas configure flag
mentioned in the HSL documentation. (Again, may be a quirk of my setup and
not a problem with HSL documentation.)

c. Ensuring that the Blas and Lapack libraries can be found during the make
phase, by using "-Wl," (that's dash/upper-case-W/lower-case-L/comma with
absolutely no spaces -- because syntax is crucial). Here is the precise
LDFLAGS element of my configure statement

LDFLAGS="-LC:/PROGRA~1/R/R-34~1.0PA/bin/x64 -Wl,-lRblas -Wl,-lRlapack"

5. Using the -fopenmp flag so that the HSL solvers can run in parallel.

6. Here is the resulting configure line that I used:

../../configure --prefix="${BLD_DIR}/${R_ARCH}" --enable-static
--disable-shared LDFLAGS="-LC:/PROGRA~1/R/R-34~1.0PA/bin/x64 -Wl,-lRblas
-Wl,-lRlapack" ADD_CFLAGS=-fopenmp ADD_FFLAGS=-fopenmp ADD_CXXFLAGS=-fopenmp

where ${BLD_DIR}/${R_ARCH} is the name of the empty directory into which I
was going to compile Ipopt and the configure file was two directories up
(hence ../../configure).

7. So the full operation for me, after:

(a) getting Ipopt source code per instructions, and
(b) extracting the HSL source to a directory that I renamed to hslcoin and
placed under the HSL directory in ThirdParty (resulting in
<ipot>/3.12/ThirdParty/HSL/coinhsl) per the HSL README

was to run:

export PATH=/c/Rtools/mingw_64/bin:$PATH
<define ${BLD_DIR}/${R_ARCH} -- the location for the build >
cd ${BLD_DIR}/${R_ARCH}
../../configure --prefix="${BLD_DIR}/${R_ARCH}" --enable-static
--disable-shared LDFLAGS="-LC:/PROGRA~1/R/R-34~1.0PA/bin/x64 -Wl,-lRblas
-Wl,-lRlapack" ADD_CFLAGS=-fopenmp ADD_FFLAGS=-fopenmp ADD_CXXFLAGS=-fopenmp
make
make test
make install

8. AFTER make install:

a. Copying files for the R interface Ipoptr, per Ipoptr instructions:

1) copy Makevars.win from
${BLD_DIR}/${R_ARCH}/Ipopt/contrib/RInterface/src  (your build directory
will be different)
to
${IPOPT_DIR}/Ipopt/contrib/RInterface/src  (where $IPOPT_DIR is your "3.12"
directory if you are using version 3.12)

2) OPTIONAL:  If you want a much faster version of the make.sparse function
than what comes with Ipoptr, replace the version that is in
${IPOPT_DIR}/Ipopt/contrib/RInterface/R/make.sparse.R
with the version below.

make.sparse <- function(A) {
  f <- function(x) which(x!=0, arr.ind=TRUE)
  rownames(A) <- NULL # just to be safe
  S <- apply(A, 1, f)
  S <- as.list(S)
  return(S)

b. Installing Ipoptr from within R -- I needed the --no-multiarch flag
shown below. Not sure if others will need it:

ipoptdir <- "C:/Ipopt2017/3.12/Ipopt/contrib/RInterface"
install.packages(ipoptdir, repos=NULL, type='source', INSTALL_opts=c("--no-
multiarch"))



That's it. After the installation from within R, I am able to call Ipopt
and use any of the HSL linear solvers, or use mumps.



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#m_-8170399122605157599_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.coin-or.org/pipermail/ipopt/attachments/20170610/182a19d5/attachment.html>


More information about the Ipopt mailing list