mechmotum / cyipopt Goto Github PK
View Code? Open in Web Editor NEWCython interface for the interior point optimzer IPOPT
License: Eclipse Public License 2.0
Cython interface for the interior point optimzer IPOPT
License: Eclipse Public License 2.0
Reported here: conda/conda#9583
$ conda create -q -n test-env python=$TRAVIS_PYTHON_VERSION numpy cython ipopt future six setuptools sphinx numpydoc pkg-config
# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<
Traceback (most recent call last):
File "/home/travis/miniconda/lib/python2.7/site-packages/conda/exceptions.py", line 1078, in __call__
return func(*args, **kwargs)
File "/home/travis/miniconda/lib/python2.7/site-packages/conda/cli/main.py", line 84, in _main
exit_code = do_call(args, p)
File "/home/travis/miniconda/lib/python2.7/site-packages/conda/cli/conda_argparse.py", line 82, in do_call
exit_code = getattr(module, func_name)(args, parser)
File "/home/travis/miniconda/lib/python2.7/site-packages/conda/cli/main_create.py", line 37, in execute
install(args, parser, 'create')
File "/home/travis/miniconda/lib/python2.7/site-packages/conda/cli/install.py", line 116, in install
if context.use_only_tar_bz2:
File "/home/travis/miniconda/lib/python2.7/site-packages/conda/base/context.py", line 668, in use_only_tar_bz2
import conda_package_handling.api
File "/home/travis/miniconda/lib/python2.7/site-packages/conda_package_handling/api.py", line 7, in <module>
import tqdm as _tqdm
ImportError: No module named tqdm
`$ /home/travis/miniconda/bin/conda create -q -n test-env python=3.7 numpy cython ipopt future six setuptools sphinx numpydoc pkg-config`
environment variables:
CIO_TEST=<not set>
CONDA_ROOT=/home/travis/miniconda
GEM_PATH=/home/travis/.rvm/gems/ruby-2.5.3:/home/travis/.rvm/gems/ruby-2.5.3@gl
obal
GOPATH=/home/travis/gopath
MANPATH=/home/travis/.nvm/versions/node/v8.12.0/share/man:/home/travis/.rvm/ru
bies/ruby-2.5.3/share/man:/usr/local/cmake-3.12.4/man:/usr/local/clang
-7.0.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man:/h
ome/travis/.rvm/man
PATH=/home/travis/miniconda/bin:/home/travis/virtualenv/python3.7.1/bin:/ho
me/travis/bin:/home/travis/.local/bin:/usr/local/lib/jvm/openjdk11/bin
:/opt/pyenv/shims:/home/travis/.phpenv/shims:/home/travis/perl5/perlbr
ew/bin:/home/travis/.nvm/versions/node/v8.12.0/bin:/home/travis/.rvm/g
ems/ruby-2.5.3/bin:/home/travis/.rvm/gems/ruby-2.5.3@global/bin:/home/
travis/.rvm/rubies/ruby-2.5.3/bin:/home/travis/gopath/bin:/home/travis
/.gimme/versions/go1.11.1.linux.amd64/bin:/usr/local/maven-3.6.0/bin:/
usr/local/cmake-3.12.4/bin:/usr/local/clang-7.0.0/bin:/usr/local/sbin:
/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/home/travis/.r
vm/bin:/home/travis/.phpenv/bin:/opt/pyenv/bin:/home/travis/.yarn/bin
PYTHON_CFLAGS=-g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror
=format-security
PYTHON_CONFIGURE_OPTS=--enable-unicode=ucs4 --with-wide-unicode --enable-shared --enable-
ipv6 --enable-loadable-sqlite-extensions --with-computed-gotos
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
TRAVIS_APT_PROXY=<set>
rvm_bin_path=/home/travis/.rvm/bin
rvm_path=/home/travis/.rvm
active environment : None
user config file : /home/travis/.condarc
populated config files : /home/travis/.condarc
conda version : 4.8.0
conda-build version : not installed
python version : 2.7.15.final.0
virtual packages : __glibc=2.23
base environment : /home/travis/miniconda (writable)
channel URLs : https://conda.anaconda.org/conda-forge/linux-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /home/travis/miniconda/pkgs
/home/travis/.conda/pkgs
envs directories : /home/travis/miniconda/envs
/home/travis/.conda/envs
platform : linux-64
user-agent : conda/4.8.0 requests/2.22.0 CPython/2.7.15 Linux/4.15.0-1028-gcp ubuntu/16.04.5 glibc/2.23
UID:GID : 2000:2000
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
Upload successful.
The command "conda create -q -n test-env python=$TRAVIS_PYTHON_VERSION numpy cython ipopt future six setuptools sphinx numpydoc pkg-config" failed and exited with 1 during
Hi,
I was working with Linux and this Ipopt interface works very well. Recently, I am trying to install Ipopt optimization system with Anaconda python on a Windows Server. The Issue I got is that cyipopt module cannot be found after installed everything.
Here is my installation process:
First, I installed Anaconda-64bit of python 2.7, and the necessary packages for cyipopt.
Then, I download Ipopt binaries (3.11.0), and put them in the corresponding location.
Finally, I changed the PATH in cyipopt setup.py and installed it using python setup.py install
Here is the terminal information while executing cyipopt setup.py.
_(base) C:\cyipopt>python setup.py install
C:\Anaconda2\lib\site-packages\setuptools\dist.py:388: UserWarning: Normalizing
'0.1.8.dev' to '0.1.8.dev0'
normalized_version,
running install
running bdist_egg
running egg_info
writing requirements to ipopt.egg-info\requires.txt
writing ipopt.egg-info\PKG-INFO
writing top-level names to ipopt.egg-info\top_level.txt
writing dependency_links to ipopt.egg-info\dependency_links.txt
reading manifest file 'ipopt.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'include*'
writing manifest file 'ipopt.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
running build_ext
skipping 'src\cyipopt.c' Cython extension (up-to-date)
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\ipopt
copying build\lib.win-amd64-2.7\ipopt\cyipopt.pyd -> build\bdist.win-amd64\egg\i
popt
copying build\lib.win-amd64-2.7\ipopt\ipopt_wrapper.py -> build\bdist.win-amd64\
egg\ipopt
copying build\lib.win-amd64-2.7\ipopt\version.py -> build\bdist.win-amd64\egg\ip
opt
copying build\lib.win-amd64-2.7\ipopt\__init__.py -> build\bdist.win-amd64\egg\i
popt
byte-compiling build\bdist.win-amd64\egg\ipopt\ipopt_wrapper.py to ipopt_wrapper
.pyc
byte-compiling build\bdist.win-amd64\egg\ipopt\version.py to version.pyc
byte-compiling build\bdist.win-amd64\egg\ipopt\__init__.py to __init__.pyc
creating stub loader for ipopt\cyipopt.pyd
byte-compiling build\bdist.win-amd64\egg\ipopt\cyipopt.py to cyipopt.pyc
installing package data to build\bdist.win-amd64\egg
running install_data
copying lib_mt\x64\ReleaseMKL\IpOpt-vc8.dll -> build\bdist.win-amd64\egg\ipopt
copying lib_mt\x64\ReleaseMKL\IpOpt-vc10.dll -> build\bdist.win-amd64\egg\ipopt
copying lib_mt\x64\ReleaseMKL\IpOptFSS.dll -> build\bdist.win-amd64\egg\ipopt
creating build\bdist.win-amd64\egg\EGG-INFO
copying ipopt.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying ipopt.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying ipopt.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INF
O
copying ipopt.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying ipopt.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
writing build\bdist.win-amd64\egg\EGG-INFO\native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist\ipopt-0.1.8.dev0-py2.7-win-amd64.egg' and adding 'build\bdist.win
-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing ipopt-0.1.8.dev0-py2.7-win-amd64.egg
Removing c:\anaconda2\lib\site-packages\ipopt-0.1.8.dev0-py2.7-win-amd64.egg
Copying ipopt-0.1.8.dev0-py2.7-win-amd64.egg to c:\anaconda2\lib\site-packages
ipopt 0.1.8.dev0 is already the active version in easy-install.pth
Installed c:\anaconda2\lib\site-packages\ipopt-0.1.8.dev0-py2.7-win-amd64.egg
Processing dependencies for ipopt==0.1.8.dev0
Searching for setuptools==39.1.0
Best match: setuptools 39.1.0
Adding setuptools 39.1.0 to easy-install.pth file
Installing easy_install-script.py script to C:\Anaconda2\Scripts
Installing easy_install.exe script to C:\Anaconda2\Scripts
Using c:\anaconda2\lib\site-packages
Searching for future==0.16.0
Best match: future 0.16.0
Adding future 0.16.0 to easy-install.pth file
Using c:\anaconda2\lib\site-packages
Searching for six==1.11.0
Best match: six 1.11.0
Adding six 1.11.0 to easy-install.pth file
Using c:\anaconda2\lib\site-packages
Searching for Cython==0.28.2
Best match: Cython 0.28.2
Adding Cython 0.28.2 to easy-install.pth file
Installing cython-script.py script to C:\Anaconda2\Scripts
Installing cython.exe script to C:\Anaconda2\Scripts
Installing cygdb-script.py script to C:\Anaconda2\Scripts
Installing cygdb.exe script to C:\Anaconda2\Scripts
Installing cythonize-script.py script to C:\Anaconda2\Scripts
Installing cythonize.exe script to C:\Anaconda2\Scripts
Using c:\anaconda2\lib\site-packages
Searching for scipy==1.1.0
Best match: scipy 1.1.0
Adding scipy 1.1.0 to easy-install.pth file
Using c:\anaconda2\lib\site-packages
Searching for numpy==1.14.3
Best match: numpy 1.14.3
Adding numpy 1.14.3 to easy-install.pth file
Using c:\anaconda2\lib\site-packages
Finished processing dependencies for ipopt==0.1.8.dev0_
It seems only an .egg file was generated. To avoid this, I tried this:
python setup.py install --single-version-externally-managed --record=record.txt
An Ipopt folder was created under Anaconda2\Lib\site-packages to include ipopt and cyipopt binaries.
However, When I was trying to run examplehs071.py in both cases, it shows that no module named cyipopt.
I also found that someone had the same issue one year ago, but haven't been answered.
Any suggestion that how can I solve this problem? Thanks in advance!
We are trying to install cyipopt as a wrapper for ipopt on windows. Following the instructions, we modified the setup.py file accordingly and used Ipopt 3.9.2 since it was the only version with lib files at the link provided.
However, when installing cyipopt through the setup.py file, we get the following error:
error: can't copy 'C:Users...\Ipopt-3.9.2-win32-win64-dll\lib\x64\release\Ipopt39.dll': doesn't exist or not a regular file
any tips or solutions? where can we get functioning lib and dll files if that is the problem?
There is a discrepancy between the behavior of minimize_ipopt and scipy.optimize.minimize when constraints=None. When that argument is passed to scipy.optimize.minimize, it runs find, but minimize_ipopt throws an error: TypeError: 'NoneType' object is not iterable
I am trying to find a feasible solution to a set of non-linear inequality functions. I did it by passing a set of constraints and making the target function to always return constant.
I call minimize_ipopt
by
minimize_ipopt(constant, x0, method="SLSQP", constraints=cons)
where constant
is a function which always returns 1, x0 is just a random guess, and cons
is a list of constraint dictionary just as SciPy
. Then it shows the following error message:
NameError: name 'FunctionWithApproxJacobian' is not defined
Could you please help me with debugging?
We can download the latest Ipopt binary in the script and then ensure cyipopt compiles on Windows.
thanks for this repo, i'm using this to run a task, but each iteration takes more than 10 seconds, is there any way to speed up ?
Hi,
Thanks for making this nice interface to ipopt.
I was wondering why in the callbacks to the objective, constraints, jacobian, etc. the functions will catch all exceptions and continue running? For example, in the code for the objective callback:
cdef Bool objective_cb(
Index n,
Number* x,
Bool new_x,
Number* obj_value,
UserDataPtr user_data
):
log('objective_cb', logging.INFO)
cdef object self = <object>user_data
cdef Index i
cdef np.ndarray[DTYPEd_t, ndim=1] _x = np.zeros((n,), dtype=DTYPEd)
for i in range(n):
_x[i] = x[i]
try:
obj_value[0] = self.__objective(_x)
except:
self.__exception = sys.exc_info()
return True
all exceptions are caught.
I found that this can lead to really confusing behaviour. For example, if you make a small mistake in the objective function like opening a file that doesn't exist, an exception is thrown which can prevent additional stuff from computing. Since all exceptions are caught, excecution continues and ipopt will try to evaluate the gradient after. Since the objective function didn't compute properly this can lead to a new exception generated in the gradient that overwrites the previous exception. Eventually, ipopt reaches the convergence callback function and exits because there was an exception, but it's now the exception from the gradient and not the objective which makes it look the problem occurred in the gradient function, which is very confusing.
Is there a reason for catching the exceptions this way or is it possible to change it?
I should start by saying I am not a software developer. I know what dll stands for, but I don't know what it actually does, and I've never used a compiler in my life. I am an academic and want to use ipopt for research purposes.
I cannot figure out how to install the package. This is what I've tried. From the anaconda console,
conda install -c conda-forge ipopt
The package will install, and I can see it with 'conda list'. Inside python if I use " help('modules') " ipopt will not be shown.
Next I tried to install manually following the instructions given. I downloaded the ipopt 3.11 for winx64 from https://www.coin-or.org/download/binary/Ipopt/ and the source files for cyipopt. I looked inside setup.py, but I don't understand what is going on and so I'm not really sure what I am supposed to be changing here. I looked at the ipopt files and there is a folder 'lib' which contains several .lib files as well as another folder pkgconfig. There are no .dlls anywhere.
I ran setup.py and it returns this
fatal error C1083: Cannot open include file: 'IpStdCInterface.h': No such file or directory
error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.21.27702\bin\HostX86\x64\cl.exe' failed with exit status 2
Using the command make html
in docs/
I get the error:
#sphinx-build -b html -d build/doctrees source build/html
make: sphinx-build: No such file or directory
#make: *** [html] Error 1
When I try sphinx-build -b html . build/html
in #source/
I get:
File "../Documents/Python/Packages/cyipopt/doc/source/sphinxext/numpydoc.py", line 52
print "WARNING: invalid reference in %s docstring" % name
^
SyntaxError: Missing parentheses in call to 'print' #
The full traceback has been saved in /var/folders/85/czy2kfhj0sg3wshsm4gccs540000gn/T/sphinx-err-_zj80ut3.log, if you want to report the issue to the developers.
indicating that it's Python 2.
Hi,
Whenever you initialize Ipopt, it prints following:
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
As the the person who posted the question in the following thread mentioned it, I am using Ipopt in a loop so this print line could be annoying in combination with other info.
I found this issue is being addressed here by a temp solution, but I do not know how to do it in Python.
https://list.coin-or.org/pipermail/ipopt/2013-September/003510.html
I wonder is there any workaround for this problem?
Bests
In #67 I added lapack as an explicitly installed package because the lapack.pc
file was no longer being located. I think the conda-forge lapack package is the netlib version. We need to use the version provided with openblas. I don't think we should need to install lapack. Installing numpy will give openblas and thus we have lapack. This is the ipopt.pc that the conda-forge ipopt-feedstock is generating on linux:
prefix=/home/moorepants/miniconda
#prefix=${pcfiledir}/../..
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include/coin-or
Name: Ipopt
Description: Interior Point Optimizer
URL: https://github.com/coin-or/Ipopt
Version: 3.13.3
Cflags: -I${includedir}
Libs: -L${libdir} -lipopt
Requires.private: lapack blas
#Libs: -L${libdir} -lipopt -ldmumps_seq -lmumps_common_seq -lpord_seq -lmpiseq_seq -lesmumps -lscotch -lscotcherr -lmetis -lgfortran -lm -ldl
#Requires: lapack blas
I think the "Requires.private" part means that you need lapack.pc
and blas.pc
for pkg-config to work properly. I think the last two lines are commented out. They are actually the flags that are used to build ipopt in the ipopt-feedstock. So maybe those lines shouldn't be commented out but the prior two should be?
Some things to look into:
It would be useful to add manual installations to our CI build. Here are some options:
python setup.py build
to make sure it builds.pip install --user
.python setup.py build
to make sure it builds.LD_LIBRARY_PATH
and PKG_CONFIG_PATH
.python setup.py build
to make sure it compiles.LD_LIBRARY_PATH
and PKG_CONFIG_PATH
.python setup.py build
to make sure it compiles.Is it possible to get the number of function evaluation from solver results?
It is printed in output, but not sure how to retreive it from interface?
For backward compatibility I'd like to dual support:
problem
-> Problem
problem.addOption()
-> Problem.add_option()
problem.setProblemScaling()
-> Problem.set_problem_scaling()
or Problem.set_scaling()
So ipopt/__init__.py
would have:
from cyipopt import Problem
problem = Problem
And there would be dual methods:
class Problem():
def add_option(...):
# all functional code here
def addOption(self, *args, **kwargs):
# maybe add a deprecation warning here
self.add_option(*args, **kwargs)
Latest release ipopt 0.1.9 actualy doesn't reflect the setup.py in this repo.
install_requires parameter is not correctly set in the ipopt 0.1.9 .
please update it so that ipopt can be installed without user manually installing all the requirements
After successfully installing cyipopt from conda using
$ conda install -c conda-forge cyipopt
I get the following message when using ipopt
ImportError: No module named 'ipopt'
.
I'm working on a nonlinear optimization problem in which the calculation of the Jacobian is difficult to do. Is there a way to use a numerically found Jacobian in the class definition? Or must a Jacobian be explicitly created for the constraints?
I get a ValueError that:
Both the "constrains" and "jacobian" callbacks must be defined.
This would be helpful for downstream use.
I think it would be nice if scipy was an optional dependency as it was before this fork occurred.
PyPi doesn't really host documentation anymore. We should set up readthedocs or doctr if more flexibility is needed.
It would be useful for people to install via pip without having to compile. We can build wheels for various operating systems to do this.
Hi, I tried to install ipopt trough pip install ipopt
Here is my error:
ERROR: Command errored out with exit status 1:
command: /usr/local/opt/python/bin/python3.7 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/3w/zf3x85h55tv7qk2yg8ykztwc0000gn/T/pip-install-lnk4_998/ipopt/setup.py'"'"'; __file__='"'"'/private/var/folders/3w/zf3x85h55tv7qk2yg8ykztwc0000gn/T/pip-install-lnk4_998/ipopt/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/3w/zf3x85h55tv7qk2yg8ykztwc0000gn/T/pip-pip-egg-info-h1me91bv
cwd: /private/var/folders/3w/zf3x85h55tv7qk2yg8ykztwc0000gn/T/pip-install-lnk4_998/ipopt/
Complete output (11 lines):
Package ipopt was not found in the pkg-config search path.
Perhaps you should add the directory containing `ipopt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ipopt' found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/3w/zf3x85h55tv7qk2yg8ykztwc0000gn/T/pip-install-lnk4_998/ipopt/setup.py", line 102, in <module>
**pkgconfig('ipopt'))]
File "/private/var/folders/3w/zf3x85h55tv7qk2yg8ykztwc0000gn/T/pip-install-lnk4_998/ipopt/setup.py", line 58, in pkgconfig
raise OSError(msg.format(list(packages)))
OSError: pkg-config was not able to find any of the requested packages ['ipopt'] on your system. Make sure pkg-config can discover the .pc files associated with the installed packages.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Command pkg-config --variable pc_path pkg-config
gives:
/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/pkgconfig:/usr/local/Homebrew/Library/Homebrew/os/mac/pkgconfig/10.15
Then which pkg-config
:
/usr/local/bin/pkg-config
And making this doesn't solve the problem:
export PKG_CONFIG_PATH=/usr/local/bin/pkg-config
macOS Catalina
python 3.7
pkg-config was installed through brew install pkg-config
System info:
Microsoft (R) C/C++ Optimizing Compiler Version 19.21.27702.2 for x86
)Steps taken:
...Finished processing dependencies for ipopt==0.2.0.dev0
import ipopt
prints>python
Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\...\AppData\Local\Programs\Python\Python37\lib\site-packages\ipopt-0.2.0.dev0-py3.7-win-amd64.egg\ipopt\__init__.py", line 43, in <module>
from cyipopt import *
ImportError: DLL load failed: The specified module could not be found.
>ls C:\Users\...\AppData\Local\Programs\Python\Python37\Lib\site-packages\ipopt-0.2.0.dev0-py3.7-win-amd64.egg
EGG-INFO IpOptFSS.dll __pycache__ cyipopt.py msvcp100.dll
IpOpt-vc10.dll Ipopt-vc8.dll cyipopt.cp37-win_amd64.pyd ipopt msvcr100.dll
Debugging so far:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "setup.py", line 28, in <module>
exec(open('ipopt/version.py').read())
File "/usr/local/lib/python3.6/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 199: ordinal not in range(128)
cyipopt is very useful, thanks for providing it.
The info dictionary returned by the solve method lacks information about the CPU runtime and the number of iterations needed. Of course, you can get this using the intermediate method or a callback, but other interfaces seem to have this. Any chance to include this as well?
I noticed a problem in the tutorial, notably the sample code:
def hessianstructure(self):
#
# The structure of the Hessian
# Note:
# The default hessian structure is of a lower triangular matrix. Therefore
# this function is redundant. I include it as an example for structure
# callback.
#
global hs
hs = sps.coo_matrix(np.tril(np.ones((4, 4))))
return (hs.col, hs.row)
This makes it sound as though the tuple to be returned is of the form (column_indices, row_indices)
, although it should
be the other way around, i.e., (row_indices, column_indices)
. This is inconsequential in the example, since the indices are identical, but it really matters in case of the structure of a sparse non-rectangular Jacobian.
Hi Everyone,
I have been using cyipopt for some time now with the mumps solver, which proved to not be optimal for my task so I decided to try different solvers.
I first updated Ipopt to the latest release 3.13.2, by downloading the file Ipopt-3.13.2-win64-msvs2019-md.zip, dumping its content into the cyipopt directory, and updating setup.py.
cyipopt works well with the new default pardiso solver.
Next, I obtained HSL files from http://www.hsl.rl.ac.uk/ipopt/, and I was able to build the library libhsl.dll and libmetis.dll. Everything went well during the build.
Could you please tell me how I can make cyipopt detect the hsl solvers? wenever I try to use the option 'linear_solver':'ma27', or anyother from HSL it results in an error.
Has someone been able to use HSL solvers with cyipopt using the LinearSolverLoader?
Firstly, I would like to thank you for this repo.
Secondly, as the title suggests, are there any plans to update this repo to make it compatible with the newest version of IPOPT? There is one pre-compiled by them 23 days ago: https://github.com/coin-or/Ipopt/releases/tag/releases%2F3.13.2
I've tried myself to install on Windows 10 using the folders lib and include from the newest compiled version (3.13.2), but failed:
After a quick inspection, I've found that the files from 3.11.0 (the recommended version by you) and the 3.13.2 are not the same, maybe that is the reason.
3.11.0 runs great. But it would be nice to have the newest (and probably with a lot of bugfixes) code.
Thank you once again for this amazing repo!
Hi,
I cloned this cyipopt from source and would like to install this interface for my Ipopt. Even though the LD_LIBRARY_PATH and PKG_CONFIG_PATH have already been set to the correct path, pkgconfig('ipopt') cannot find the installed package.
The output is as follows
Package ipopt was not found in the pkg-config search path.
Perhaps you should add the directory containing `ipopt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ipopt' found
My PKG_CONFIG_PATH is: (Path to Ipopt)/Ipopt-3.12.4/_build/lib/pkgconfig
My LD_LIBRARY_PATH is: (Path to Ipopt)/Ipopt-3.12.4/_build/lib
Can you help me with this problem?
The original maintainer of this package told me by email that he is no longer maintaining it. The pypi package (https://pypi.org/project/ipopt/) is now stale too. It'd be nice if this fork could take that over. Would you be willing to ask the owner of the pypi page to take it over?
Hi,
Is there a way to install the package using pip3?
Ideally and hopefully a user only needs to use "pip3 install" and does not need to worry about compilations, etc
Thanks.
Text taken from #78:
This is the exception_handling.py output with Py 2.7, IPOPT 3.13.2 (official binary) on Windows:
python test/exception_handling.py
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
This is Ipopt version 3.13.2, running with linear solver pardiso.
Number of nonzeros in equality constraint Jacobian...: 4
Number of nonzeros in inequality constraint Jacobian.: 4
Number of nonzeros in Lagrangian Hessian.............: 10
Total number of variables............................: 4
variables with only lower bounds: 0
variables with lower and upper bounds: 4
variables with only upper bounds: 0
Total number of equality constraints.................: 1
Total number of inequality constraints...............: 1
inequality constraints with only lower bounds: 1
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 0
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.6109693e+01 1.12e+01 1.02e+00 0.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.7346108e+01 7.50e-01 2.37e+01 -0.3 7.22e-01 - 3.51e-01 1.00e+00f 1
2 1.7922201e+01 7.70e-03 5.29e+00 -0.2 6.00e-02 2.0 9.96e-01 1.00e+00h 1
3 0.0000000e+00 6.72e-02 1.66e+00 -0.8 1.37e+00 - 9.95e-01 6.98e-01f 1
Number of Iterations....: 3
(scaled) (unscaled)
Objective...............: 0.0000000000000000e+00 0.0000000000000000e+00
Dual infeasibility......: 1.6551098674064002e+00 8.2755493370320010e-01
Constraint violation....: 6.7248402765482496e-02 6.7248402765482496e-02
Complementarity.........: 2.6927701887990801e-01 1.3463850943995401e-01
Overall NLP error.......: 1.6551098674064002e+00 8.2755493370320010e-01
Number of objective function evaluations = 4
Number of objective gradient evaluations = 4
Number of equality constraint evaluations = 4
Number of inequality constraint evaluations = 4
Number of equality constraint Jacobian evaluations = 4
Number of inequality constraint Jacobian evaluations = 4
Number of Lagrangian Hessian evaluations = 3
Total CPU secs in IPOPT (w/o function evaluations) = 0.102
Total CPU secs in NLP function evaluations = 0.003
EXIT: Stopping optimization at current point as requested by user.
Objective value at iteration #0 is - 16.1097
Objective value at iteration #1 is - 17.3461
Objective value at iteration #2 is - 17.9222
Caught ValueError: bum
And Python 3.8, IPOPT 3.13.3 (via conda forge), on Windows:
python test/exception_handling.py
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit https://github.com/coin-or/Ipopt
******************************************************************************
This is Ipopt version 3.13.3, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
Number of nonzeros in equality constraint Jacobian...: 4
Number of nonzeros in inequality constraint Jacobian.: 4
Number of nonzeros in Lagrangian Hessian.............: 10
Total number of variables............................: 4
variables with only lower bounds: 0
variables with lower and upper bounds: 4
variables with only upper bounds: 0
Total number of equality constraints.................: 1
Total number of inequality constraints...............: 1
inequality constraints with only lower bounds: 1
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 0
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.6109693e+01 1.12e+01 1.02e+00 0.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.7346108e+01 7.50e-01 2.37e+01 -0.3 7.22e-01 - 3.51e-01 1.00e+00f 1
2 1.7922201e+01 7.70e-03 5.29e+00 -0.2 6.00e-02 2.0 9.96e-01 1.00e+00h 1
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Cutting back alpha due to evaluation error
Warning: Evaluation error during soft restoration phase step.
Warning: Evaluation error during soft restoration phase step.
Warning: Evaluation error during soft restoration phase step.
Sorry, things failed ?!?!
Number of Iterations....: 2
(scaled) (unscaled)
Exception of type: Eval_Error in file "D:\bld\ipopt_1605616866017\work\Ipopt\src\Algorithm\IpOrigIpoptNLP.cpp" at line 487:
Exception message: success && IsFiniteNumber(ret) evaluated false: Error evaluating the objective function
Number of objective function evaluations = 45
Number of objective gradient evaluations = 3
Number of equality constraint evaluations = 41
Number of inequality constraint evaluations = 41
Number of equality constraint Jacobian evaluations = 4
Number of inequality constraint Jacobian evaluations = 4
Number of Lagrangian Hessian evaluations = 3
Total CPU secs in IPOPT (w/o function evaluations) = 0.016
Total CPU secs in NLP function evaluations = 0.003
EXIT: Invalid number in NLP function or derivative detected.
Objective value at iteration #0 is - 16.1097
Objective value at iteration #1 is - 17.3461
Objective value at iteration #2 is - 17.9222
Caught ValueError: bum
Maybe there is a difference in IPOPT 3.13.2 and 3.13.3 that prevents this exception to be properly caught?
So 3.13.2 give the same results on Py 27 and Py 38 on Windows. Maybe this due to a change introduced in 3.13.3.
The file IpOrigIpoptNLP.cpp was edited between 3.13.2 and 3.13.3. See:
But the only changes are extra forwardslashes. Not sure what that does...
I tried the official Ipopt 3.13.3 binaries with Python 3.* on Windows and that works as expected. The oddity is only from the conda forge builds. So something is likely different in the conda forge builds. I think we could merge this as is and open an issue for this exception handling issue.
Even though cyipopt is intrinsically compatible with Ipopt >=3.13.0 on Linux (and likely MacOS), the build instructions are outdated as the Ipopt structure changed. Also, CI is locked on Ipopt <3.13.0 as pkg-config seems to not be configured properly for the latest conda Ipopt.
The new build instructions using coinbrew for Ipopt are detailed on Ipopt github and their documentation.
I have written a draft of .travis.yml that would maybe work with Ipopt 3.13.2 built from source. However, I am not sure if it follows the Linux best practices as I have not much experience on the system. It would also be better to make it work with a conda installed Ipopt.
The docker & vagrant directories are not maintained and neither is the old Makefile that is specific to the original author's computer. I think we should remove these unless someone wants to maintain them.
I am currently solving a nonlinear programming problem where it is pretty difficult for me to provide explicitly gradient or jacobian matrix. I think that IPOPT should have this option to enable a finite-difference method for gradient estimation. However, I am not sure how to set this option within cyipopt wrapper. Can you provide me with some instructions?
Thanks,
moorepants@agni:~/src/cyipopt$ python setup.py sdist
Package ipopt was not found in the pkg-config search path.
Perhaps you should add the directory containing `ipopt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ipopt' found
Traceback (most recent call last):
File "setup.py", line 101, in <module>
**pkgconfig('ipopt'))]
File "setup.py", line 57, in pkgconfig
raise OSError(msg.format(list(packages)))
OSError: pkg-config was not able to find any of the requested packages ['ipopt'] on your system. Make sure pkg-config can discover the .pc files associated with the installed packages.
pkg-config should only be run when actually attempting to install.
I am trying to install ipopt through pip install ipopt
I get this error on running it.
I am using ubuntu 14.04
I tried upgrading setuptools but that doesnt fix it.
pip install ipopt
Collecting ipopt
/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/util/ssl_.py:369: SNIMissingWarning: An HTTPS request has been made, but the SNI (Server Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/urllib3/util/ssl_.py:160: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
Using cached https://files.pythonhosted.org/packages/05/57/a7c5a86a8f899c5c109f30b8cdb278b64c43bd2ea04172cbfed721a98fac/ipopt-0.1.9.tar.gz
Complete output from command python setup.py egg_info:
Package ipopt was not found in the pkg-config search path.
Perhaps you should add the directory containing `ipopt.pc'
to the PKG_CONFIG_PATH environment variable
No package 'ipopt' found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-o0IVSp/ipopt/setup.py", line 93, in <module>
**pkgconfig('ipopt'))]
File "/tmp/pip-install-o0IVSp/ipopt/setup.py", line 62, in pkgconfig
kw['include_dirs'] += [np.get_include()]
KeyError: 'include_dirs'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-o0IVSp/ipopt/
ipopt_minimize
will raise an exception when called NameError: name 'FunctionWithApproxJacobian' is not defined
It appears there is divergence between the Optpy project and cyipopt, with the implementation here ported for Python3 compatibility. However, its missing the related file jacobian.py
so the wrapper just doesn't work.
I'm trying to (naively) replace a scipy.optimize.minimize
calls with IPOPT. Figure it should be a working feature since its at the beginning of the README.
The solution doesn't look too bad. May need to merge some changes between Optpy and here, and include a Python2/3 compatible version of jacobian.py
.
e
I have packaged the tip of master of cyipopt for conda-forge:
conda-forge/staged-recipes#2273
I would like to have a tagged release for this. Can you make a new release based on the current state?
Here is an example output from Travis:
$ cd doc && make html && cd ..
sphinx-build -b html -d build/doctrees source build/html
Running Sphinx v1.8.0
making output directory...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 4 source files that are out of date
updating environment: 4 added, 0 changed, 0 removed
reading sources... [100%] tutorial
docstring of ipopt.problem:145: WARNING: toctree references unknown document u'ipopt.problem.addOption'
docstring of ipopt.problem:145: WARNING: toctree references unknown document u'ipopt.problem.close'
docstring of ipopt.problem:145: WARNING: toctree references unknown document u'ipopt.problem.setProblemScaling'
docstring of ipopt.problem:145: WARNING: toctree references unknown document u'ipopt.problem.solve'
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] tutorial
/home/travis/build/matthias-k/cyipopt/doc/source/index.rst:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.addOption'
/home/travis/build/matthias-k/cyipopt/doc/source/index.rst:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.close'
/home/travis/build/matthias-k/cyipopt/doc/source/index.rst:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.setProblemScaling'
/home/travis/build/matthias-k/cyipopt/doc/source/index.rst:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.solve'
WARNING: LaTeX command 'latex' cannot be run (needed for math display), check the imgmath_latex setting
docstring of ipopt.problem:152:<autosummary>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.addOption'
docstring of ipopt.problem:152:<autosummary>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.close'
docstring of ipopt.problem:152:<autosummary>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.setProblemScaling'
docstring of ipopt.problem:152:<autosummary>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.solve'
<partial node>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.addOption'
31;01m<partial node>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.close'
<partial node>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.setProblemScaling'
<partial node>:: WARNING: toctree contains reference to nonexisting document u'ipopt.problem.solve'
generating indices... genindex py-modindex
highlighting module code... [100%] cyipopt
writing additional pages... search
copying static files... WARNING: html_static_path entry u'/home/travis/build/matthias-k/cyipopt/doc/source/_static' does not exist
done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 18 warnings.
I am using cyipopt in Spyder (python 3.8), and everything seems to work fine, but I am not able to display the IPOPT iterations. I am using the following option:
nlp.addOption(b'print_level', 5)
However, I do not get any output from IPOPT during the optimization. Do you know how I can make sure that something is printed to see the progress?
Installing the package with anaconda and executing the minimal example of the README doesn't work. Somehow the namespace looks completely different.
from scipy.optimize import rosen, rosen_der
from cyipopt import minimize_ipopt
x0 = [1.3, 0.7, 0.8, 1.9, 1.2]
res = minimize_ipopt(rosen, x0, jac=rosen_der)
print(res)
does not find minimize_ipopt
For example:
self.addOption('derivative_test', 'second-order')
has to be
self.addOption(b'derivative_test', b'second-order')
But the b''
works in Python 2.7 and Python 3. It would be nicer if users could pass in strings without the leading b
in all Python versions.
(opty-dev) moorepants@garuda:cyipopt-git-fork(master)$ ipython
Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import ipopt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-151ed8d4c199> in <module>()
----> 1 import ipopt
/home/moorepants/src/cyipopt-git-fork/ipopt/__init__.py in <module>()
39
40 from cyipopt import *
---> 41 from .ipopt_wrapper import minimize_ipopt
42
/home/moorepants/src/cyipopt-git-fork/ipopt/ipopt_wrapper.py in <module>()
1 from __future__ import absolute_import, unicode_literals
2 import sys
----> 3 from builtins import bytes
4 import numpy as np
5 try:
ImportError: No module named builtins
After installing Cyipopt as following
MB-Pro:Python JKvanSchoubroeck$ conda install -c conda-forge cyipopt
Solving environment: done
## Package Plan ##
environment location: /Users/JKvanSchoubroeck/anaconda
added / updated specs:
- cyipopt
The following NEW packages will be INSTALLED:
cyipopt: 0.1.7-py35h7eb728f_2 conda-forge
ipopt: 3.12.8-blas_openblas_0 conda-forge [blas_openblas]
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
MB-Pro:Python JKvanSchoubroeck$
I get the following error when trying import ipopt
:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-b7ba6fc18d82> in <module>()
7 import pandas as pd
8
----> 9 import compl_mech_temp
10 import support_functions
11 import matplotlib.pyplot as plt
/Users/JKvanSchoubroeck/path_to_test_file/test.py in <module>()
13 import cvxopt.cholmod
14 from pymatbridge import Matlab
---> 15 import ipopt
16 import matplotlib.pyplot as plt
17 import PyMMA
/Users/JKvanSchoubroeck/anaconda/lib/python3.5/site-packages/ipopt/__init__.py in <module>()
38 from __future__ import absolute_import
39
---> 40 from cyipopt import *
41 from .ipopt_wrapper import minimize_ipopt
42
ImportError: dlopen(/Users/JKvanSchoubroeck/anaconda/lib/python3.5/site-packages/cyipopt.cpython-35m-darwin.so, 2): Library not loaded: @rpath/libmetis.dylib
Referenced from: /Users/JKvanSchoubroeck/anaconda/lib/libipopt.1.dylib
Reason: image not found
There are some warts that would be nice to address which require backwards incompatibility, maybe warranting a 1.0 release.
Problem
instead of problem
.problem
class).ipopt
to cyipopt
src
into a sub-directory of the main module.test
to examples
.Thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.