【问题标题】:When using Gurobi solver, are solver_io=direct or python options supported with python 3.6?使用 Gurobi 求解器时,python 3.6 是否支持 solver_io=direct 或 python 选项?
【发布时间】:2019-08-07 02:11:59
【问题描述】:

这是我正在玩的玩具代码:

from __future__ import division
from pyomo.environ import *
from pyomo.opt import SolverStatus, TerminationCondition
import sys

sys.path.append('/Library/gurobi810/mac64/lib/gurobipy')

model = ConcreteModel()
model.x = Var([1,2], domain=NonNegativeReals)
model.obj = Objective(expr = 2*model.x[1] + 3*model.x[2])
model.constraint1 = Constraint(expr = 3*model.x[1] + 4*model.x[2] >= 1)

opt = SolverFactory('gurobi_direct')
#opt = SolverFactory('gurobi')
#opt = SolverFactory('gurobi', solver_io='python')

rr = opt.solve(model)

上面的代码在使用solver_io='python' 或'gurobi_direct' 只能在Python 2.7 虚拟环境中正常工作。当我在 Python 3.6 虚拟环境中工作时,出现以下错误:

pyutilib.common._exceptions.ApplicationError: No Python bindings available for <class 'pyomo.solvers.plugins.solvers.gurobi_direct.GurobiDirect'> solver plugin

这是否意味着 Pyomo 不支持 Python 3.6 的这些选项?有什么解决办法吗?

【问题讨论】:

    标签: python-3.x gurobi pyomo


    【解决方案1】:

    您还需要在您的 python 3.6 虚拟环境中安装 Gurobi 的 Python 绑定(在 Gurobi 绑定中使用 python setup.py install)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-07-29
      • 2013-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多