Changeset 2264


Ignore:
Timestamp:
Feb 5, 2010 10:20:30 AM (10 years ago)
Author:
wehart
Message:

Misc rework of the scripting modules. These changes allow this
functionality to be used more effectively within other Python scripts.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/__init__.py

    r2227 r2264  
    2323import coopr.opt
    2424import transform
     25import scripting
    2526
    2627pyutilib.component.core.PluginGlobals.pop_env()
  • coopr.pyomo/trunk/coopr/pyomo/scripting/__init__.py

    r2146 r2264  
    88#  _________________________________________________________________________
    99
    10 
     10from convert import *
  • coopr.pyomo/trunk/coopr/pyomo/scripting/convert.py

    r2160 r2264  
    121121    if not util.apply_preprocessing(options, parser, args):
    122122        return
    123     instance = util.create_model(options, args)
     123    model = util.create_model(options, args)
     124    return model
    124125
    125126def pyomo2lp(args=None):
  • coopr.pyomo/trunk/coopr/pyomo/scripting/pyomo.py

    r2170 r2264  
    199199    if not util.apply_preprocessing(options, parser, args):
    200200        return Container()                                   #pragma:nocover
    201     instance = util.create_model(options, args)
     201    model = util.create_model(options, args)
    202202    if options.save_model or options.only_instance:
    203         return Container(instance=instance)
    204     results, opt = util.apply_optimizer(options, instance)
    205     if not util.process_results(options, instance, results, opt):
    206         return Container(instance=instance, results=results) #pragma:nocover
    207     util.apply_postprocessing(options, instance, results)
    208     return Container(instance=instance, results=results)
     203        return Container(instance=model.instance)
     204    results, opt = util.apply_optimizer(options, model.instance)
     205    if not util.process_results(options, model.instance, results, opt):
     206        return Container(instance=model.instance, results=results) #pragma:nocover
     207    util.apply_postprocessing(options, model.instance, results)
     208    return Container(instance=model.instance, results=results)
    209209
    210210
  • coopr.pyomo/trunk/coopr/pyomo/scripting/util.py

    r2218 r2264  
    199199       print ""
    200200
     201    fname=None
     202    symbol_map=None
    201203    if not options.save_model is None:
    202204        if options.save_model == True:
     
    209211            fname = options.save_model
    210212            format=None
    211         instance.write(filename=fname, format=format)
     213        [fname, symbol_map] = instance.write(filename=fname, format=format)
    212214        if not os.path.exists(fname):
    213215            print "ERROR: file "+fname+" has not been created!"
     
    215217            print "Model written to file '"+str(fname)+"'"
    216218
    217     return instance
     219    return pyutilib.misc.Container(instance=instance, symbol_map=symbol_map, filename=fname)
    218220
    219221#
Note: See TracChangeset for help on using the changeset viewer.