1

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.

Shen
  • 164
  • 1
  • 1
  • 7
  • I figured it out in the last few minutes. I deleted the ipopt which I downloaded from the zip and instead I setted the path to point to the ipopt which is in my build directory (the one I used `coinbrew` to install). It now works perfectly fine: $ python3 exampleoptimize.py Flowrate at maximum CB = 8.944271964904416 liters per minute. Maximum CB = 0.954915028125263 moles per liter. Productivity = 8.541019714926701 moles per minute. – Shen Mar 13 '22 at 06:54

1 Answers1

0

Hey I also faced this problem. I was running my script in remote HPC with Linux system. However, when I use command to execute the file, it works and solve the model very well. When I use pycharm run the script, it doesn't work, showing that the solver can not be located. Thats super strange

SrR
  • 9
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 18 '22 at 14:41
  • Did you figure it out? – Shen May 17 '23 at 03:45