SolverFactory is unable to find any solvers

2,617 views
Skip to first unread message

Roland Vincze

unread,
Mar 30, 2016, 6:42:17 PM3/30/16
to Pyomo Forum
Hello!

I am running Windows 7 x64, Anaconda 2 with Python 2.7.
I have the pyomo and the gurobipy packages installed. I have the GUROBI_PATH variable, and the gurobi folder in the path. In the python files, all the includes are working.
However, I cannot make SolverFactory to find Gurobi. I tried it from a console without PyDev, too, I always get the following error:
RuntimeError: Attempting to use an unavailable solver.


The SolverFactory was unable to create the solver "gurobi"
and returned an UnknownSolver object. etc etc

I tried specifying the path manually, with no success. This is my code:

from pyomo.core.base.PyomoModel import AbstractModel
from pyomo.opt import SolverFactory

model
= AbstractModel()
opt
= SolverFactory("gurobi", executable='c:/Programs/gurobi650/win64/bin/gurobi_cl.exe')

I have pyomo.extras and openopt packages installed, but the error is the exact same with "nlp", "nlpopt" or any other solvers. Strangely, if and only if I put "ipopt", I get the following error message:

RuntimeError: The asl solver plugin was not registered as a valid solver plugin - cannot construct solver plugin with IO mode=nl

Am I doing something completely wrong? How should I give the exact address to the .exe file to make it work? Should the SolverFactory always give UnknownSolver objects?

Thank you very much for any help, I am stuck here for 2 days now.

Gabriel Hackebeil

unread,
Mar 30, 2016, 6:55:54 PM3/30/16
to pyomo...@googlegroups.com
Always have “import pyomo.environ” or “from pyomo.environ import *” at the top of your script to avoid seeing errors about plugins not being registered.

Assuming the directory "c:/Programs/gurobi650/win64/bin” exists, you can skip specifying a full path to the solver executable with SolverFactory by adding this directory to your PATH environment variable.

It could also be that the “executable” keyword is broken in your version of Pyomo. Can you verify whether this is true on Pyomo trunk?

This blog post discuss both how to install Pyomo trunk as well as update your PATH on Windows.

Gabe

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Roland Vincze

unread,
Apr 3, 2016, 2:36:44 PM4/3/16
to Pyomo Forum
Thank you very much! It worked!

I got stuck once again, though. I solve my problem, and I am even able to get the solver status and termination conditions. But how do I get the value of the variables in the solution? My code is something like

model = AbstractModel()
...
model
.construct()
opt
= SolverFactory("gurobi")
results
= opt.solve(model)

but then result.solution only says "number of solutions: 0". I also tried 

model.solutions.load_from(results)

but then I can only pprint() it, but cannot get the values of the variables themselves. Also is there any object obtainable at the end, which contains the values of the variables AND the solver status, too?

Reply all
Reply to author
Forward
0 new messages