Free Python optimization framework

Saturday, March 22, 2008

Connecting IPOPT, Part 1

a Ph.D. student from Washington University has informed me, that he spent just a single day and already has working Python-IPOPT connection (of course, it requires some more time to make it appropriate enough). That one is implemented via Python's C-API, but maybe in future numpy's C-API or something else will be used.

Unfortunately, I still have some problems with build, for me it yields "/usr/lib/libipopt.so.0: undefined symbol: _gfortran_concat_string".
You could take a look at the code by yourself, the one is available here

You must have IPOPT installed (I have tried 3.3.1 and 3.3.5, note that this one requires LP solver installed such as MUMPS); modify links to IPOPT directories in batch.sh and run the file (note that for now the code is usable in Linux only).

7 comments:

Harald Schilly said...

you need -lgfortran in the gcc command. thats a library.

Dmitrey said...

Thank you, but now it yields

Traceback (most recent call last):
File "testhook.py", line 1, in module
import ipopt
ImportError: /usr/lib/libipopt.so.0: undefined symbol: dswap_

Any idea?

Eric said...

I did a google search on "dswap_", it seems to be in lapack. can you locate the lapack lib correctly?
try to add -llapack.

I didn't have this library on my machine.

Dmitrey said...

yes, with -llapack all works ok now!

So tomorrow I intend to try to write OO <-> IPOPT connection using Eric's code.

However, it would be nice if Eric provide IPOPT <-> Python connection not for Linux only but for other OSes as well.

Eric said...

I am not sure how to make it for other OS but it definitely worths a try, I will do the following three things in the next few days.
1. make nlpy and pythong-ipopt connected such that we can manipulate the whole AMPL thing within python when using ipopt solver. I am currently in a heavy debugging stage on this step.
2. Since openopt uses numpy data structure, I will use numpy's ndarray instead of list to pass value around. This is done.
3. I started to read the openopt code and kind of know the interface to add a new solver to OO. I will try to finish that soon.

Unknown said...

Guys,

I did the original work to put MUMPS into IPOPT. I have a client that is very interested in a Python wrapper for IPOPT. I'll do some work to try and make this a cross-platform solution and submit the code back. That OK with everyone?

Damien

Dmitrey said...

Hi Damien,
both Eric & I will be glad in your code contribution.
Note that Eric has some further code modification, you could access it via

http://code.google.com/p/pyipopt/ -> Source -> download via subversion.

(you can comment out those lines related to AMPL and NLPy).
I have a question: do your client wants to have IPOPT connected via Python lists or numpy arrays? Note that Python lists consumes about 2 times greater memory, and access to them is slower because they are fragmented in memory. The code you have downloaded is based on Python lists, and Eric informed me he intend to rewrite all via numpy arrays (mb something is already done in his code from google-project, but this month he has a deadline and has no possibilities to work on pyipopt).
I would contact you via email but your profile is closed.
Regards, D.