Reputation: 41
I am using Pyomo 5.6.8 and trying to resolve a non linear optimization problem using MindtPySolver
.
I have no issue on my local machine, simply calling the solve
method with these arguments:
SolverFactory('mindtpy').solve(model, mip_solver='cbc', nlp_solver='ipopt')
However, when I go cloud on Azure, Pyomo doesn't get the path to the CBC and IPOPT solvers. When needing to resolve a problem that is linear, I can bypass the issue using the following command, by adding executable
argument when creating SolverFactory
instance with a LP solver:
SolverFactory("cbc", executable="/path/to/my/virtual/env/bin/cbc")
In my non-linear programming case, MindtpySolver
doesn't accept additional argument. I looked at the doc & source code and couldn't find option to specify solver path, that is unfortunately not recognized by default on my Azure environment.
I tried to pass options using the "solver_args" options found on source code like this:
SolverFactory('mindtpy').solve(
model,
nlp_solver_args={
"executable": "/path/to/my/virtual/env/bin/ipopt"
},
mip_solver_args={
"executable": "/path/to/my/virtual/env/bin/cbc"
},
mip_solver='cbc', nlp_solver='ipopt',
)
But I'm still getting "WARNING: Could not locate the 'ipopt' executable, which is required for solver" like errors. I insist on the fact that all solvers (here cbc and ipopt) can be found in my virtual environment.
Is there a way to specify solvers path using MindtPySolver
?
Upvotes: 2
Views: 1194
Reputation: 29
I may have same issue too, My optimize problem is Mixed-Integer Nonlinear Programs, and it have to using SolverFactory('mindtpy').solve(model, mip_solver='glpk', nlp_solver='ipopt')
And the solver is in Django Framework with Apache2 WSGI Service which WSGIDaemonProcess : Conda Env.
When call api via Web Browser. It will rise error like cannot find "ipopt" solver. and "glpk" solver too. and SolverFactory allow us set only one Executable.
BTW, Already find out how to fix it.
After you install ipopt and plugin solver via Conda install.
Just going deep in python package and edit raw file.
My path are below:
/home/user/miniconda3/envs/py385/lib/python3.8/site-packages/pyomo/solvers/plugins/solvers/GLPK.py
/home/user/miniconda3/envs/py385/lib/python3.8/site-packages/pyomo/solvers/plugins/solvers/IPOPT.py
Find function below and change it.
def _default_executable(self):
executable = Executable('/home/user/miniconda3/envs/py385/bin/glpsol')
def _default_executable(self):
executable = Executable("/home/user/miniconda3/envs/py385/bin/ipopt")
You can find where is plugin solver located by type in terminal command
which ipopt
, which glpsol
Upvotes: 2