相关文章推荐
直爽的牛肉面  ·  python/openpyxl/DataVa ...·  2 周前    · 
勤奋的鸭蛋  ·  python - Set up of ...·  5 天前    · 
大力的长颈鹿  ·  python - Conda env ...·  5 天前    · 
风流的板凳  ·  SpringBoot 集成 Spring ...·  2 年前    · 
玩命的企鹅  ·  C# ...·  2 年前    · 
聪明伶俐的扁豆  ·  Windows Scheduled ...·  2 年前    · 
精明的台灯  ·  Minio Hadoop-3.3.0 ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Using Pyomo, instead of creating a file that is to be sent to the solver, I want to start using the Python interface of solvers that are compatible (i.e. CPLEX or GUROBI). What is the default solver interface when not specified, and how can someone specify the wanted solver interface within this code?:

opt = SolverFactory('gurobi')
results = opt.solve(model, options= solverOptions)

You can either create the direct solver explicitly:

from pyomo.environ import SolverFactory
solver = SolverFactory('gurobi_direct')

or with using the "python" IO option to the Gurobi "metasolver":

solver = SolverFactory('gurobi', solver_io='python')
                Yes. Both routes return a pyomo.solvers.plugins.solvers.gurobi_direct.GurobiDirect object.
– jsiirola
                May 8, 2018 at 18:46
                Sorry, I get the following message while trying with gurobi. RuntimeError: Attempting to use an unavailable solver.  The SolverFactory was unable to create the solver "gurobi" and returned an UnknownSolver object.  This error is raised at the point where the UnknownSolver object was used as if it were valid (by calling method "solve").  The original solver was created with the following parameters: 	solver_io: direct 	type: gurobi 	_args: () 	options: {} 
– V. Brunelle
                May 3, 2018 at 21:14
                Are the gurobi python bindings installed for the python environment that you're using with Pyomo? How did you install Pyomo?
– Qi Chen
                May 4, 2018 at 15:40
                Gurobi is installed. I installed Pyomo using Anaconda packages. Then, I ran command line conda config --add channels http://conda.anaconda.org/gurobi and conda install gurobi on my Windows environnement cmd (following the indications of gurobi.com/downloads/get-anaconda). Are you suggesting that my Python Gurobi installation might be incomplete?
– V. Brunelle
                May 4, 2018 at 15:48
                I think that for some reason, Pyomo is not able to find your Gurobi installation. There might be a linking missing. What happens when you open a python terminal and try to import gurobipy?
– Qi Chen
                May 4, 2018 at 19:53
                After pressing enter, it doesn't give me any error, but it doesn't tell me anything. I can input an other line. However, I still have the same issue while solving the problem. Can it be because another solver name must be provided (ex: "PythonGurobi")? I also suspect my own installation of Python Gurobi. Let me try to find if it is really installed.
– V. Brunelle
                May 4, 2018 at 20:14
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.