Ignore:
Timestamp:
01/28/11 16:43:43 (3 years ago)
Author:
jdsiiro
Message:

Removing Expression.simplify()

  • all simplification functions occur within generate_expression()
  • expression trees are actually slightly "more simplified" than before
  • the new simplification routine is measurably faster than the old recursive simplify() methods.

It is an open question as to if we want to preserve expression
simplification. Currently, generating simplified expression trees is
slightly slower (5% - 15%) than generating raw, unsimplified expression
trees. However, the simplified trees are smaller and more readable. As
is indicated in #4176, it is still debatable if we should perform basic
expression simplification at all.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/base/PyomoModel.py

    r3526 r3554  
    146146        return [ProblemFormat.pyomo] 
    147147 
    148     def create(self, filename=None, name=None, namespace=None, namespaces=None, preprocess=True, simplify=True, profile_memory=0): 
     148    def create(self, filename=None, name=None, namespace=None, namespaces=None, preprocess=True, simplify=None, profile_memory=0): 
    149149        """ 
    150150        Create a concrete instance of this Model, possibly using data 
     
    152152        """ 
    153153 
     154        if simplify is not None: 
     155           print """ 
     156WARNING: The 'simplify' argument to PyomoModel.create() has been deprecated. 
     157     Please remove references from your code. 
     158""" 
    154159        if self._defer_construction: 
    155160            instance = self.clone() 
    156161 
    157162            if namespaces is None: 
    158                 instance.load(filename, namespaces=[namespace], simplify=simplify, profile_memory=profile_memory) 
     163                instance.load(filename, namespaces=[namespace], profile_memory=profile_memory) 
    159164            else: 
    160                 instance.load(filename, namespaces=namespaces, simplify=simplify, profile_memory=profile_memory) 
     165                instance.load(filename, namespaces=namespaces, profile_memory=profile_memory) 
    161166        else: 
    162167            instance = self 
     
    209214        return soln 
    210215 
    211     def load(self, arg, namespaces=[None], simplify=True, profile_memory=0): 
     216    def load(self, arg, namespaces=[None], simplify=None, profile_memory=0): 
    212217        """ Load the model with data from a file or a Solution object """ 
    213218 
     219        if simplify is not None: 
     220           print """ 
     221WARNING: The 'simplify' argument to PyomoModel.load() has been deprecated. 
     222     Please remove references from your code. 
     223""" 
     224 
    214225        if arg is None or type(arg) is str: 
    215            self._load_model_data(ModelData(filename=arg,model=self), namespaces, simplify=simplify, profile_memory=profile_memory) 
     226           self._load_model_data(ModelData(filename=arg,model=self), namespaces, profile_memory=profile_memory) 
    216227           return True 
    217228        elif type(arg) is ModelData: 
     
    328339            try: 
    329340                if isinstance(declaration, coopr.pyomo.base.constraint.Constraint) or isinstance(declaration, coopr.pyomo.base.objective.Objective): 
    330                    declaration.construct(data, simplify=kwds.get('simplify', True)) 
     341                   declaration.construct(data) 
    331342                else: 
    332343                   declaration.construct(data) 
Note: See TracChangeset for help on using the changeset viewer.