I'm using Kali Linux and I needed to install ipopt to use with pyomo in Python which I'm currently learning. I have tried several things and none of them have worked with trying to run ipopt in pyomo. First, following their official website's instructions did not work (https://coin-or.github.io/Ipopt/INSTALL.html) for pyomo even though everything seemed to install:
sudo apt-get install gcc g++ gfortran git patch wget pkg-config liblapack-dev libmetis-dev
Next, I attempted to use coinbrew
following coin-or repo's suggestion:
/path/to/coinbrew fetch Ipopt --no-prompt
/path/to/coinbrew build Ipopt --prefix=/dir/to/install --test --no-prompt --verbosity=3
/path/to/coinbrew install Ipopt --no-prompt
It took a long time to build from the source and I am not sure if this did anything.
My third attempt was installing cyipopt (https://github.com/mechmotum/cyipopt) with pip and running one of the examples there in their repo. That worked perfectly fine with using cyipot but not pyomo which still could not find the solver when I tried to run it. On my fourth attempt, I went ahead and downloaded the ipopt linux64 directly from https://ampl.com/dl/open/ipopt/. I then unzipped the file and copied the executable ipopt into my /usr/bin and then added +x permission to it. I tested out the executable by ./ipopt and it appears to work properly there:
$ ipopt
No stub!
usage: ipopt [options] stub [-AMPL] [<assignment> ...]
Options:
-- {end of options}
-= {show name= possibilities}
-? {show usage}
-bf {read boundsfile f}
-e {suppress echoing of assignments}
-of {write .sol file to file f}
-s {write .sol file (without -AMPL)}
-v {just show version}
I went ahead and ran it on an example file:
from pyomo.environ import *
V = 40 # liters
kA = 0.5 # 1/min
kB = 0.1 # l/min
CAf = 2.0 # moles/liter
# create a model instance
m = ConcreteModel()
# create the decision variable
m.q = Var(domain=NonNegativeReals)
# create the objective
m.CBmax = Objective(expr=m.q*V*kA*CAf/(m.q + V*kB)/(m.q + V*kA), sense=maximize)
# solve using the nonlinear solver ipopt
SolverFactory('ipopt').solve(m)
# print solution
print('Flowrate at maximum CB = ', m.q(), 'liters per minute.')
print('Maximum CB =', m.CBmax(), 'moles per liter.')
print('Productivity = ', m.q()*m.CBmax(), 'moles per minute.')
The error is:
WARNING: Could not locate the 'ipopt' executable, which is required for solver
ipopt
Traceback (most recent call last):
File "/media/sf_SharedFiles/Code/optimization/examplescalaroptimize.py", line 20, in <module>
SolverFactory('ipopt').solve(m)
File "/home/kali/.local/lib/python3.9/site-packages/pyomo/opt/base/solvers.py", line 512, in solve
self.available(exception_flag=True)
File "/home/kali/.local/lib/python3.9/site-packages/pyomo/opt/solver/shellcmd.py", line 128, in available
raise ApplicationError(msg % self.name)
pyomo.common.errors.ApplicationError: No executable found for solver 'ipopt'
I have spent several hours looking into this and nothing has worked.