Reputation: 1
Having conda installed Pyomo, I tried to also conda install the glpk and ipopt solvers using the code given in the Pyomo documentation:
conda install -c conda-forge ipopt glpk
As far as I could see there were no problems with the installation. If I run the following code:
import pyomo.environ as pyo
model = pyo.ConcreteModel()
model.x = pyo.Var([1,2], domain = pyo.NonNegativeReals)
model.OBJ = pyo.Objective(expr = 2 * model.x[1] + 3 * model.x[2])
model.Constraint1 = pyo.Constraint(expr = 3 * model.x[1] + 4 * model.x[2] >= 1)
opt = pyo.SolverFactory('glpk')
opt.solve(model)
It solves it with no issues whatsoever. However, if I change the solver on the second last line to ipopt, I am met with the following message:
ApplicationError: No executable found for solver 'ipopt'
I am met with similar messages any time I try to use the ipopt solver in any way, even if I write up a nonlinear model. However, glpk works absolutely fine. I am using Spyder 5.4.3 as my IDE. Any ideas on how I can get the ipopt solver working?
I have tried uninstalling and reinstalling both Pyomo and the solvers, but the problem persists. According to Pyomo's documentation, I should be able to use the ipopt solver in the same manner as glpk, just for different models.
Upvotes: 0
Views: 375
Reputation: 8277
Do you know the complete path to the ipopt solver? If so use it:
pyo.SolverFactory('/opt/homebrew/bin/ipopt')
works on my machine with brew installed ipopt. See https://pyomo.readthedocs.io/en/stable/working_models.html#specifying-the-path-to-a-solver for more information.
Upvotes: 0