Notebook Entry

uh, trying to use IPopt in Python.

Ipopt installation

I tried to install from the Ubuntu repos, but had trouble linking to it or running the example:

$ sudo aptitude install coinor-libipopt1 coinor-libipopt-dev coinor-libipopt-doc

So then I removed it:

$ sudo aptitude remove coinor-libipopt1 coinor-libipopt-dev coinor-libipopt-doc

The Ipopt documentation gives very nice instructions for installing it from source, which basically goes like this:

$ cd ~/src
$ svn co CoinIpopt
$ cd CoinIpopt/ThirdParty/Blas
$ ./get.Blas
$ cd ../Lapack
$ ./get.Lapack
$ cd ../ASL
$ ./get.ASL
$ cd ../Mumps
$ ./get.Mumps
$ cd ../Metis
$ ./get.Metis

This downloads the BLAS and LAPACK reference implementations, but I think the compilation process looks in the system for the system installed implementations and uses them if you have them.

It is a good idea to get the HSL code (but not necessarily required because Mumps can be used) and drop it in the ThirdParty/HSL directory. You have to get the free academic license 2011 code and sign a form to use it. It also takes a day to get the download link by email. (Note that this can be linked as a shared lib after compiling ipopt, so recompiling is required, but it may be easier to just recompile).

I compiled without HSL because I'm waiting for the download link.

First change into the build directory:

$ cd ../../build

And run configure:

$ ./configure

These are some potential options I may want to set in the future:

--prefix /usr/local  # for system install
--with-blas="-L$HOME/lib -lmyblas"  # link to better blas implementations

Now compile, test, and install:

$ make -j5
$ make test
$ make install  # sudo if system install

This ended up putting everything in ~/src/CoinIpopt/ like ~/src/CoinIpopt/include, ~/src/CoinIpopt/lib, etc. So I did something wrong, as I thought it should have ended up in ~src/CoinIpopt/build/.


I'm hoping to use Ipopt through a Python wrapper. Seems like there are two existing standalone wrappers pyipopt and cyipopt. I like cython and cyipopt was newer, so I gave it a shot.

I first created a conda Python 2.7 environment:

$ conda create -n cyipopt numpy scipy cython matplotlib sphinx
$ source activate cyipopt

Then got the source code from bitbucket:

$ cd ~/src
$ hg clone
$ cd cyipopt

I installed on Ubuntu 14.04 so I had to do some pruning in the file. Basically just remove some odd stuff from main_unix() so it looks like this:

def main_unix():

        cmdclass={'build_ext': build_ext},
                PACKAGE_NAME + '.' + 'cyipopt',

Since I didn't install IPopt system wide I needed to export these two environment variables to get things to work:

$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:~/src/CoinIpopt/lib/pkgconfig
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/src/CoinIpopt/lib

And finally:

$ python install
$ python test/
$ python test/

And it worked.

Other Things

Here are a bunch of other notes about things I found today: