Changeset 9483


Ignore:
Timestamp:
Dec 14, 2014 3:33:34 PM (4 years ago)
Author:
wehart
Message:

Adding the '--transform' option, which applies a model
transformation before optimization

Location:
pyomo/trunk/pyomo/scripting
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pyomo/trunk/pyomo/scripting/pyomo_command.py

    r9410 r9483  
    3939        action='append',
    4040        dest='preprocess',
     41        default=[])
     42    group.add_argument('--transform',
     43        help='Specify a list of transformations that are applied before the model '\
     44             'is optimized.',
     45        action='append',
     46        dest='transformations',
    4147        default=[])
    4248    group.add_argument('--model-name',
  • pyomo/trunk/pyomo/scripting/util.py

    r9401 r9483  
    320320        data.options.max_memory = mem_used
    321321        print("   Total memory = %d bytes prior to model construction" % mem_used)
    322 
    323322    #
    324323    # Create Model
     
    356355    for ep in ExtensionPoint(IPyomoScriptPrintModel):
    357356        ep.apply( options=data.options, model=model )
    358 
    359     #
    360     # Disable canonical repn for ASL solvers, and if the user has specified as such (in which case, we assume they know what they are doing!).
     357    #
     358    # Disable canonical repn for ASL solvers, and if the user has specified
     359    # as such (in which case, we assume they know what they are doing!).
    361360    #
    362361    # Likely we need to change the framework so that canonical repn
     
    367366    elif data.options.skip_canonical_repn is True:
    368367        model.skip_canonical_repn = True
    369 
    370368    #
    371369    # Create Problem Instance
     
    466464            print("      %6.2f seconds to apply %s" % (time.time() - tick, type(ep)))
    467465            tick = time.time()
     466    #
     467    for transformation in data.options.transformations:
     468        instance = instance.transform(transformation)
     469        if instance is None:
     470            raise SystemExit("Unexpected error while applying transformation '%s'" % transformation)
    468471    #
    469472    if data.options.report_timing is True:
Note: See TracChangeset for help on using the changeset viewer.