本文整理匯總了Python中pyutilib.misc.Options.version方法的典型用法代碼示例。如果您正苦於以下問題:Python Options.version方法的具體用法?Python Options.version怎麽用?Python Options.version使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pyutilib.misc.Options
的用法示例。
在下文中一共展示了Options.version方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: initialize
# 需要導入模塊: from pyutilib.misc import Options [as 別名]
# 或者: from pyutilib.misc.Options 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