Changeset 3042


Ignore:
Timestamp:
Sep 23, 2010 11:44:21 PM (11 years ago)
Author:
wehart
Message:

Bug fix in parameter initialization with rules.

Creating test case where set/param/obj/con data is
initialized with rules.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
1 added
2 edited

Legend:

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

    r3041 r3042  
    7171        IndexedComponent.__init__(self, *args, **tkwd)
    7272
    73         self._initialize = kwd.pop('initialize', {} )
     73        self._initialize = kwd.pop('initialize', None )
    7474        self._initialize = kwd.pop('rule', self._initialize )
    7575        self._validate   = kwd.pop('validate', None )
     
    212212
    213213        if self._initialize is None:
    214             self._initialize = getattr(self,'rule',None)
    215 
     214            self._initialize = getattr(self,'rule',{})
    216215        #
    217216        # Construct using the initial data or the data loaded from an
  • coopr.pyomo/trunk/coopr/pyomo/tests/examples/test_pyomo.py

    r2611 r3042  
    4545        self.pyomo('pmedian.py pmedian.dat', file=currdir+'test1.out')
    4646        self.failUnlessFileEqualsBaseline(currdir+"test1.out", currdir+"test1.txt")
     47
     48    def test1a(self):
     49        """Simple execution of 'pyomo' with implicit rules"""
     50        self.pyomo('pmedian3.py pmedian.dat', file=currdir+'test1a.out')
     51        self.failUnlessFileEqualsBaseline(currdir+"test1a.out", currdir+"test1.txt")
    4752
    4853    def test2(self):
Note: See TracChangeset for help on using the changeset viewer.