问题
Hello everyone. I have a little problem : I am working with openmdao and pyOptSparseDriver. It is working for some solvers (SLSQP, PSQP for instance) so there is no problem about that installation.
Now i'd like to try the same with IPOPT, but the code is not given with pyoptsparse. I followed the COIN-OR documentation to install IPOPT (http://www.coin-or.org/Ipopt/documentation/node10.html), and everything SEEMS ok (i don't know how to check it). Now i have a COIN-OR folder on my desk and i don't know how to make pyoptsparse take IPOPT from it (it is the line "from . import pyoptcore" that crashes), from pyIPOPT/pyIPOPT.py. Can anyone help me ? Thank you by advance
回答1:
we're using IPOPT with OpenMDAO through the pytoptsparse package, and installed it as a standalone library, like you've done. To get that to work you need to set the IPOPT_DIR
environment variable pointing to the location you installed IPOPT before running the install of pyoptsparse.
So assuming you installed IPOPT in e.g. /usr/local/IPOPT:
$ export IPOPT_DIR=/usr/local/IPOPT
$ cd /path/to/pyoptsparse/
$ python setup.py install
this should result in pyoptsparse compiling the python wrapper for IPOPT and produce the file pyoptcore.so that will be placed in Python's site-packages/pyoptsparse/pyIPOPT
.
On our cluster we had to modify the pyoptsparse/pyIPOPT/setup.py
file slightly since we compiled everything with Intel, but if you compile with gfortran the official version of pyoptsparse should work for you.
Alternatively, you can do like Justin suggests, which is essentially the instructions you find in the pyoptsparse docs.
回答2:
you have to put the ipopt source code into the src folder of pyopt-sparse and then recompile the package.
来源:https://stackoverflow.com/questions/38716581/using-ipopt-with-openmdao-or-pyoptsparse-in-python