Changeset 9504


Ignore:
Timestamp:
Dec 19, 2014 4:27:36 PM (4 years ago)
Author:
jdsiiro
Message:

Adding the "inplace" option to the BigM / CHull relaxations.

Location:
pyomo/trunk/pyomo/gdp/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pyomo/trunk/pyomo/gdp/plugins/bigm.py

    r9450 r9504  
    4040    def apply(self, instance, **kwds):
    4141        options = kwds.pop('options', {})
     42
     43        inplace = kwds.pop('inplace', None)
     44        if 'inplace' in options:
     45            if bool(options['inplace']) != inplace and inplace is not None:
     46                raise RuntimeError(
     47                    "conflicting inplace options: apply(inplace=%s) with "
     48                    "options['inplace']==%s" % (inplace, options['inplace']) )
     49            inplace = options['inplace']
     50        elif inplace is None:
     51            inplace = True
     52
     53        if not inplace:
     54            instance = instance.clone()
    4255
    4356        targets = kwds.pop('targets', None)
  • pyomo/trunk/pyomo/gdp/plugins/chull.py

    r9268 r9504  
    4141    def apply(self, instance, **kwds):
    4242        options = kwds.pop('options', {})
     43
     44        inplace = kwds.pop('inplace', None)
     45        if 'inplace' in options:
     46            if bool(options['inplace']) != inplace and inplace is not None:
     47                raise RuntimeError(
     48                    "conflicting inplace options: apply(inplace=%s) with "
     49                    "options['inplace']==%s" % (inplace, options['inplace']) )
     50            inplace = options['inplace']
     51        elif inplace is None:
     52            inplace = True
     53
     54        if not inplace:
     55            instance = instance.clone()
    4356
    4457        targets = kwds.pop('targets', None)
Note: See TracChangeset for help on using the changeset viewer.