本文整理汇总了Python中pyomo.opt.SolverFactory.version方法的典型用法代码示例。如果您正苦于以下问题:Python SolverFactory.version方法的具体用法?Python SolverFactory.version怎么用?Python SolverFactory.version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyomo.opt.SolverFactory
的用法示例。
在下文中一共展示了SolverFactory.version方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
# 需要导入模块: from pyomo.opt import SolverFactory [as 别名]
# 或者: from pyomo.opt.SolverFactory import version [as 别名]
def initialize(**kwds):
obj = Options(**kwds)
#
# Set obj.available
#
opt = None
try:
opt = SolverFactory(obj.name, solver_io=obj.io)
except:
pass
if opt is None or isinstance(opt, UnknownSolver):
obj.available = False
elif (obj.name == "gurobi") and (not GUROBISHELL.license_is_valid()):
obj.available = False
elif (obj.name == "baron") and (not BARONSHELL.license_is_valid()):
obj.available = False
else:
obj.available = (opt.available(exception_flag=False)) and (
(not hasattr(opt, "executable")) or (opt.executable() is not None)
)
#
# Check capabilities
#
if obj.available:
for _c in obj.capabilities:
if not _c in opt._capabilities:
raise ValueError("Solver %s does not support capability %s!" % (obj.name, _c))
#
# Get version
#
obj.version = opt.version()
return obj