# 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 https://projects.coin-or.org/svn/Ipopt/stable/3.11 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).

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/.

# cyipopt

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 https://bitbucket.org/amitibo/cyipopt
$cd cyipopt  I installed on Ubuntu 14.04 so I had to do some pruning in the setup.py file. Basically just remove some odd stuff from main_unix() so it looks like this: def main_unix(): setup( name=PACKAGE_NAME, version=VERSION, description=DESCRIPTION, author=AUTHOR, author_email=EMAIL, url=URL, packages=[PACKAGE_NAME], cmdclass={'build_ext': build_ext}, ext_modules=[ Extension( PACKAGE_NAME + '.' + 'cyipopt', ['src/cyipopt.pyx'], **pkgconfig('ipopt') ) ], )  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 setup.py install
$python test/examplehs071.py$ python test/lasso.py


And it worked.

# Other Things

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