本文整理汇总了Python中pyutilib.misc.Options.model_file方法的典型用法代码示例。如果您正苦于以下问题:Python Options.model_file方法的具体用法?Python Options.model_file怎么用?Python Options.model_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyutilib.misc.Options
的用法示例。
在下文中一共展示了Options.model_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Options
# 需要导入模块: from pyutilib.misc import Options [as 别名]
# 或者: from pyutilib.misc.Options import model_file [as 别名]
# Mimic the pyomo script
from pyomo.environ import *
from pyutilib.misc import Options
# set high level options that mimic pyomo comand line
options = Options()
options.model_file = 'DiseaseEstimation.py'
options.data_files = ['DiseaseEstimation.dat']
options.solver = 'ipopt'
options.solver_io = 'nl'
#options.keepfiles = True
#options.tee = True
# mimic the set of function calls done by pyomo command line
scripting.util.setup_environment(options)
# the following imports the model found in options.model_file,
# sets this to options.usermodel, and executes preprocessors
scripting.util.apply_preprocessing(options, parser=None)
# create the wrapper for the model, the data, the instance, and the options
model_data = scripting.util.create_model(options)
instance = model_data.instance
# solve
results, opt = scripting.util.apply_optimizer(options, instance)
# the following simply outputs the final time elapsed
scripting.util.finalize(options)
# load results into instance and print