I am trying to install ipopt with anaconda on Windows10 x64.
I already installed ipopt via "conda install -c conda-forge ipopt" in the anaconda prompt (version=3.13.4).
I built a small test-script in python to check my installation:
import pyomo.environ as pe
import pyomo.opt as po
M = pe.ConcreteModel()
M.x = pe.Var()
M.y = pe.Var(bounds=(0, None))
M.obj = pe.Objective(expr=M.x+M.y, sense=pe.minimize)
M.c1 = pe.Constraint(expr=(M.x >=4)) // this constraint expr will be replaced by M.x**2 >= 4 to test nonlinear problems
M.c2 = pe.Constraint(expr=(M.y >= M.x))
solver = po.SolverFactory('ipopt')
results = solver.solve(M, tee=True)
print(pe.value(M.x), pe.value(M.y))
Running the script, I received the following error message:
ApplicationError: No executable found for solver 'ipopt'
I could solve this problem downloading the zip-folder for 64-bit windows from https://ampl.com/products/solvers/open-source/ and extracting the files into the "Library"-folder of the anaconda environment I am working on.
Running the test script for the linear problem again, the problem is solved but I get the following information:
This is Ipopt version 3.12.13, running with linear solver mumps.
NOTE: Other linear solvers might be more efficient (see Ipopt documentation).
The nonlinear test problem, however, cannot be solved as still the linear mumps solver is applied.
EXIT: Maximum Number of Iterations Exceeded.
WARNING: Loading a SolverResults object with a warning status into
model.name="unknown";
- termination condition: maxIterations
- message from solver: Ipopt 3.12.13\x3a Maximum Number of Iterations
Exceeded.
M.x=-281240.49215541 M.y=13.01195537079578
How can I make sure that nonlinear problems are solved by ipopt as well? I am aware that there are a few similar questions on stackoverflow, but I wasn't able to solve my problem yet.
(I also tried to follow the installation guide from https://coin-or.github.io/Ipopt/INSTALL.html, but encountered the message "configure: error: no acceptable C compiler found in $PATH""" in the MSYS2 console when I tried to install ASL or HSL, even though I installed gcc as described and included the folder which contains gcc.exe into my PATH-variable.)
Probably the conda-forge package doesn't include the AMPL interface and the ipopt executable that is required by Pyomo (at least, that is the case for https://anaconda.org/conda-forge/ipopt/3.13.4/download/win-64/ipopt-3.13.4-hf6be2e5_0.tar.bz2).
MUMPS should not be the reason if Ipopt failed to solve min x+y s.t. x>=4, y>=x. One would need to inspect the Ipopt log to see what is going wrong.
If you feel that the executable from ampl.com is too old, you can try the ones that are attached to the Ipopt releases, e.g., https://github.com/coin-or/Ipopt/releases/download/releases%2F3.14.1/Ipopt-3.14.1-win64-msvs2019-md.zip for the latest.
They also include Pardiso from MKL in addition to MUMPS.
To check why the compiler check in configure failed under msys2, have a look into file config.log that is generated by configure.
Related
I am attempting to install PyGMO on Mac OS X 11.2.2 (with Anaconda which I reinstalled so the Anaconda Navigator is now upgraded to 2.0.1.)
After the installation starts, it collects package metadata and reports it found package conflicts. How can I solve the conflict so that I can run PyGMO?
Here is the start:
$ conda install -c conda-forge pygmo
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: \
Found conflicts! Looking for incompatible packages.
After few hours, the Terminal returns a long report of conflicts and stops there. Here is a representative piece of output:
Package selectors2 conflicts for:
wurlitzer -> selectors2
spyder-kernels -> wurlitzer[version='>=1.0.3'] -> selectors2
Package mpmath conflicts for:
anaconda==2020.07=py38_0 -> sympy==1.6.1=py38_0 -> mpmath[version='>=0.19']
sympy -> mpmath[version='>=0.19']
anaconda==2020.07=py38_0 -> mpmath==1.1.0=py38_0
Package anyio conflicts for:
jupyterlab -> jupyter_server[version='>=1.4,<2'] -> anyio[version='>=2.0.2|>=2.0.2,<3']
jupyterlab_server -> jupyter_server[version='>=1.4,<2'] -> anyio[version='>=2.0.2|>=2.0.2,<3']
Package py-lief conflicts for:
conda-build -> py-lief
anaconda==2020.07=py38_0 -> py-lief==0.10.1=py38haf313ee_0
Note that strict channel priority may have removed packages required for satisfiability.
I followed the official installation guidelines and set the additional channel and its priority. I also checked this command but that is essentially the same thing. I also tried the installation commands from PyPI. And I tried this hint as well
There are two possible states:
Conda solver is correct. The previous package constraints you have in the environment are incompatible with installing pygmo. In that case, you either need to track down the conflicting constraints and try to manually loosen them (not recommended for Anaconda base), or you need to make a new environment:
conda create -n pygmo_env -c conda-forge pygmo
Include whatever other packages you need in there. E.g., ipykernel if you plan on using it as a Jupyter kernel.
Conda solver is bugging out. The solver is reporting trouble solving when it really shouldn't be. This happens, and especially happens when mixing channels (defaults and conda-forge). Many find Mamba, the drop-in replacement for Conda, to be more reliable (and definitely faster!).
conda install conda-forge::mamba
mamba install -c conda-forge pygmo
Unfortunately, it's hard to tell which state it's in. Many of us have been down the rabbit hole of trying to sort through the constraint reports and sometimes there really isn't a sensible conflict to be found. For practical purposes, I'd recommend trying out mamba. If it also fails, then at least you'll have good evidence that you're in state (1).
Additional Commentary
Despite upbeat documentation about installing from any channel in Anaconda Cloud, an Anaconda distribution is highly constrained - i.e., has too many packages - and only tests for co-installation of packages from the defaults channel. Additionally, Conda Forge and Anaconda have different build stacks, so there can be runtime package incompatibilities even when the solver allows co-installation.
Generally, I'd recommend making liberal use of environment creation. Aim to have separate environments for separate tasks/projects. If you plan on frequently using more than a vanilla Anaconda distribution, consider Miniforge or one of its variants. One can always create an Anaconda environment with conda create -n foo -c defaults anaconda.
I have been trying to make ipopt work on pyomo. I've downloaded pyomo (version 5.7.3) and ipopt using Anaconda Navigator and I'm using Spyder to edit and run my .py codes. I've been using the following code from the pyomo tutorial in order to understand whether ipopt is successfully installed and works.
import pyomo.environ as pyo
from pyomo.opt import SolverFactory
model = pyo.ConcreteModel()
model.nVars = pyo.Param(initialize=4)
model.N = pyo.RangeSet(model.nVars)
model.x = pyo.Var(model.N, within=pyo.Binary)
model.obj = pyo.Objective(expr=pyo.summation(model.x))
model.cuts = pyo.ConstraintList()
opt = SolverFactory('ipopt')
opt.solve(model)
# Iterate, adding a cut to exclude the previously found solution
for i in range(5):
expr = 0
for j in model.x:
if pyo.value(model.x[j]) < 0.5:
expr += model.x[j]
else:
expr += (1 - model.x[j])
model.cuts.add( expr >= 1 )
results = opt.solve(model)
print ("\n===== iteration",i)
model.display()
When I set opt = SolverFactory('ipopt') and run the code, it gives me the following warning:
WARNING: Could not locate the 'ipopt' executable, which is required for solver ipopt
My first try to solve this problem by myself is to manually download the ipopt executable (ipopt 3.11.1-win64) from the link below:
https://www.coin-or.org/download/binary/Ipopt/
Afterwards, I extracted the files and placed them into the pyomo solver location:
C:\Anaconda\envs\myenv\Lib\site-packages\pyomo\solvers\plugins\solvers
This didn't work, so I also tried specifying the path to the ipopt executable using the code:
opt = pyo.SolverFactory("ipopt", executable="C:\Anaconda\envs\myenv\Lib\site-packages\pyomo\solvers\plugins\solvers\ipopt\bin\ipopt.exe")
However, doing this gives me the following warning:
WARNING: Failed to create solver with name 'ipopt': Failed to set executable
for solver ipopt. File with name=C:\Anaconda\envs\myenv\Lib\site-packages\
pyomo\solvers\plugins\solvers\ipopin\ipopt.exe
either does not exist or it is not executable. To skip this validation,
call set_executable with validate=False.
Reminder that the part ipopin\ipopt.exe was not a typo. I don't know why it happened. I also tried copy-pasting the executable outside the bin folder and placing it in the ipopt folder instead:
opt = pyo.SolverFactory("ipopt", executable="C:\Anaconda\envs\myenv\Lib\site-packages\pyomo\solvers\plugins\solvers\ipopt\ipopt.exe")
Unfortunately I still get the WARNING. Could not locate the 'ipopt' executable, which is required for solver ipopt in the end.
I also tried downloading the ipopt executable from the link below but ipopt.exe is eliminated by my virus scanner as it considers the downloaded file as a threat:
https://projects.coin-or.org/CoinBinary/browser/binary/Ipopt/Ipopt-3.13.2-win64-msvs2019-md.zip?rev=1072
Is there another way I can try to make IPOPT work in this case?
if you run your jupyter notebook from the anaconda then you should be able to see your solver in the installed list of anaconda
476/5000
rstudio generates error when running R code with python code. At first the code worked very well but in the second installation it started to generate faults. Here is the link of the code in case you want to play #https: //www.r-bloggers.com/r-and-python-using-reticulate-to-get-the-best-of-both-worlds/
. My laptop is hp 4 gigs of ram and 500 mb of hard disk.
I would greatly appreciate who can explain the failure and how to solve it.
I have reinstalled anaconda last version twice.
library(reticulate)
use_python("/usr/local/bin/python")
use_virtualenv("r-reticulate")
os <- import("os")
Error: lexical error: invalid char in json text.
WARNING: The conda.compat modul
(right here) ------^
os$listdir(".")
Error: object 'os' not found
py_config()
Error: lexical error: invalid char in json text.
WARNING: The conda.compat modul
(right here) ------^
Actually, it comes from a deprecation warning reported a few days ago (fix compat import showing warning #8507).
But the fact is that this warning in "conda.compat" generates some errors, for example in the case of using conda environments in R through "reticulate" functions. This issue has been reported quite recently Conda warnings taken as errors #477.
The solution is to simply install the github version of "reticulate" in order to avoid these errors and ignore the conda warnings which shouldn't necessarily impede these functionalities. You can do it like this way:
remotes::install_github("rstudio/reticulate")
And don't forget to have the latest Rtools installed in your operating system!
This might be useful for you: https://docs.anaconda.com/anaconda/user-guide/tasks/switch-environment/
I have Anaconda, and set up Python 2 environment. Once activated, run 'use_python' with the path to that environment and set the 'required' parameter to TRUE.
I had the same problem. I solved the problem by installing an older version of conda.
In anaconda promt
conda install conda = 4.1.6
UPDATE june 18:
I would like compiling my python code for windows.
I use to work with pyinstaller, python 3.5+, windows 7 and anaconda to control modules pandas, pyqt (v5) and pyqtgraph, but it seems something is not compatible. I would not be surprised if you tell me to change a version.
In previous versions, it worked with python 3.5, windows 7 and Pyinstaller 3.3.1- without pandas; the new version imports pandas and then this doesn’t work anymore:
with the usual config pyinstaller gives a message saying the C libraries are not built. Following the instructions, I should run python setup.py build_ext --inplace --force, except I don’t see the setup.py file, so I don’t know what to do. Forums tell me it should be a problem with pip but not with conda… but I use conda…
with python 3.6, I got an error message ‘RecursionError: maximum recursion depth exceeded’ (https://github.com/steph2016/profiles/blob/master/errorMessage). This problem seems known and solutions I found on forums is either to downgrade python or to replace my PyInstaller-3.3.1 by PyInstaller-3.4.dev0+7b3143612. But with PyInstaller-3.4.dev0+7b3143612 I get a ’’str’ object has no attribute ‘items’’ error (https://github.com/steph2016/profiles/blob/master/ErrorMessage2). I’m not sure pyinstaller is compatible with python 3.6…
with python 3.4, I got an error similar to the ‘str object’ one above. I’m not sure python3.4 is compatible with qt5…
I would be pleased by any solution with any version of whatever to windows-compile my code
I don't know if it is the issue but I didn't find PyQtGraph in Supported-Packages
I eventually applied the first solution proposed in No module named 'pandas._libs.tslibs.timedeltas' in PyInstaller in the original config (python 3.5, PyInstaller 3.3.1, pyqtgraph, pandas, windows 7,...) and it worked.
I don't know why adding def get_pandas_path ..... a.binaries) helps, so I can't justify. But just to be explicit even if it seems obvious: pyinstaller must be run on the spec file, not on the py one (for instance > pyinstaller toto.spec)
I am trying to solve a MILP problem set up in PYOMO whith SCIP as solver.
I run the problem from within PyDev using the python ANACONDA interpreter.
I can run and solve the problem with other solvers, namely CBC, GLPK, and IPOPT.
However, it does not work when using SCIP as solver. It seems like there is something wrong with the SCIP/AMPL interface... Anybody can help out?
Below are some details on the error prompt and system configuration.
I tried with 'scip' and 'scipampl'.
With 'scip'
opt = SolverFactory('scip')
instance = model.create_instance("test1.dat")
results = opt.solve(instance)
instance.display()
WARNING: "[base]/site-packages/pyomo/solvers/plugins/solvers/SCIPAMPL.py", 68, _default_executable
Could not locate the 'scipampl' executable, which is required for solver scip
Traceback (most recent call last):
File "/home/alessandro/Documents/Eclipse workspace/test1/src/test1.py", line 48, in
results = opt.solve(instance) # solves and updates instance
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 539, in solve
self.available(exception_flag=True)
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/solver/shellcmd.py", line 122, in available
raise ApplicationError(msg % self.name)
pyutilib.common._exceptions.ApplicationError: No executable found for solver 'scip'
With 'scipampl'
opt = SolverFactory('scipampl')
instance = model.create_instance("test1.dat")
results = opt.solve(instance)
instance.display()
WARNING: "[base]/site-packages/pyomo/opt/base/solvers.py", 202, solver_call
Failed to create solver with name 'scipampl':
Failed to set executable for solver asl. File with name=scipampl either does not exist or it is not executable. To skip this validation, call set_executable with validate=False.
Traceback (most recent call last):
File "/home/alessandro/Documents/Eclipse workspace/test1/src/test1.py", line 48, in
results = opt.solve(instance)
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 127, in solve
self._solver_error('solve')
File "/home/alessandro/anaconda3/lib/python3.6/site-packages/pyomo/opt/base/solvers.py", line 155, in _solver_error
+ "\n\toptions: %s" % ( self.options, ) )
RuntimeError: Attempting to use an unavailable solver.
The SolverFactory was unable to create the solver "scipampl"
and returned an UnknownSolver object. This error is raised at the point
where the UnknownSolver object was used as if it were valid (by calling
method "solve").
The original solver was created with the following parameters:
executable: scipampl
type: scipampl
_args: ()
options: {}
The Eclipse version is "Oxygen.1 (4.7.1)" and the PyDev version is "6.0.0".
The python, pyomo, and solvers versions are as follows:
~$ python
Python 3.6.2 |Anaconda custom (64-bit)| (default, Sep 30 2017, 18:42:57) [GCC 7.2.0] on linux
~$ pyomo --version
Pyomo 5.2 (CPython 3.6.2 on Linux 4.10.0-35-generic)
~$ cbc
Welcome to the CBC MILP Solver
Version: 2.9.9
Build Date: Jul 6 2017
~$ glpsol
GLPSOL: GLPK LP/MIP Solver, v4.63
~$ ipopt
No stub!
usage: ipopt [options] stub [-AMPL] [<assignment> ...]
~$ scip
SCIP version 4.0.1 [precision: 8 byte] [memory: block] [mode: optimized] [LP solver: SoPlex 3.0.1] [GitHash: 8a04b84]
Copyright (C) 2002-2017 Konrad-Zuse-Zentrum fuer Informationstechnik Berlin (ZIB)
External codes:
SoPlex 3.0.1 Linear Programming Solver developed at Zuse Institute Berlin (soplex.zib.de) [GitHash: 24cffa9]
CppAD 20160000.1 Algorithmic Differentiation of C++ algorithms developed by B. Bell (www.coin-or.org/CppAD)
ZLIB 1.2.8 General purpose compression library by J. Gailly and M. Adler (zlib.net)
GMP 6.1.0 GNU Multiple Precision Arithmetic Library developed by T. Granlund (gmplib.org)
ZIMPL 3.3.4 Zuse Institute Mathematical Programming Language developed by T. Koch (zimpl.zib.de)
Ipopt 3.12.8 Interior Point Optimizer developed by A. Waechter et.al. (www.coin-or.org/Ipopt)
user parameter file <scip.set> not found - using default parameters
SCIP> ^C
I installed the CBC, GLPK and IPOT packages as follows:
conda install -c conda-forge coincbc
conda install -c conda-forge glpk
conda install -c conda-forge ipopt
I installed the latest SCIPOPTSUITE version "4.0.1" with the Linux-Debian package "SCIPOptSuite-4.0.1-Linux.deb"
I also installed AMPL-MP SCIPOPTLIB and PYSCIPOPT as follows:
conda install -c conda-forge ampl-mp
conda install -c leethargo scipoptlib
conda install -c leethargo pyscipopt
EDIT:
follow these instructions: http://zverovich.net/2012/08/07/using-scip-with-ampl.html
Several things that might help:
the conda package at leethargo is not the official conda package (because there is none)
try installing and running PySCIPOpt via pip first
PySCIPOpt is not interfaced to PYOMO, so you most likely need to rely on AMPL for the SCIP support
does PYOMO even support SCIP? I couldn't figure that out from their documentation
Ah, look what I found after googling "pyomo scip":
https://groups.google.com/forum/#!topic/pyomo-forum/peBjIvkVwtQ
https://github.com/Pyomo/pyomo/issues/48
So, PYOMO only supports SCIP through the AMPL interface (ASL).