def finalize(data, model=None, instance=None, results=None):
"""
Perform final actions to finish the execution of the pyomo script.
This function prints statistics related to the execution of the pyomo script.
Additionally, this function will drop into the python interpreter if the `interactive`
option is `True`.
Required:
model: A pyomo model object.
Optional:
instance: A problem instance derived from the model object.
results: Optimization results object.
"""
#
# Deactivate and delete plugins
#
##import gc
##print "HERE - usermodel_plugins"
##_tmp = data.options._usermodel_plugins[0]
cleanup()
# NOTE: This function gets called for cleanup during exceptions
# to prevent memory leaks. Don't reconfigure the loggers
# here or we will lose the exception information.
#configure_loggers(reset=True)
data.local._usermodel_plugins = []
##gc.collect()
##print gc.get_referrers(_tmp)
##import pyomo.core.base.plugin
##print pyomo.util.plugin.interface_services[pyomo.core.base.plugin.IPyomoScriptSaveResults]
##print "HERE - usermodel_plugins"
##
if not data.options.runtime.logging == 'quiet':
sys.stdout.write('[%8.2f] Pyomo Finished\n' % (time.time()-start_time))
if (pympler_available is True) and (data.options.runtime.profile_memory >= 1):
sys.stdout.write('Maximum memory used = %d bytes\n' % data.local.max_memory)
sys.stdout.flush()
#
model=model
instance=instance
results=results
#
if data.options.runtime.interactive:
if IPython_available:
ipshell()
else:
import code
shell = code.InteractiveConsole(locals())
print('\n# Dropping into Python interpreter')
shell.interact()
print('\n# Leaving Interpreter, back to Pyomo\n')
评论列表
文章目录