Changeset 2257


Ignore:
Timestamp:
Feb 4, 2010 12:45:40 AM (10 years ago)
Author:
wehart
Message:

Augmenting the SolverResults? logic to support default values. This
capability is currently disabled, but I'm leaving it in in case we
want to use this in the future.

Misc fix to the activation logic.

Location:
coopr.opt/trunk/coopr/opt/results
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.opt/trunk/coopr/opt/results/container.py

    r2109 r2257  
    3333        self._required=required
    3434
    35     def _repn_(self, option):
    36         if not option.schema and not self._required and self.value is undefined:
    37             return ignore
    38         if option.ignore_time and str(self.scalar_type) == str(ScalarType.time):
    39             return ignore
     35    def get_value(self):
    4036        if type(self.value) is EnumValue:
    4137            value = str(self.value)
     
    4440        else:
    4541            value = self.value
     42        return value
     43
     44    def _repn_(self, option):
     45        if not option.schema and not self._required and self.value is undefined:
     46            return ignore
     47        if option.ignore_time and str(self.scalar_type) == str(ScalarType.time):
     48            return ignore
     49        value = self.get_value()
     50        #
     51        # Disabled logic for managing default values, and the
     52        # ignore_defaults option
     53        #
     54        #if option.ignore_defaults:
     55        #    try:
     56        #        if self._default == value:
     57        #            return ignore
     58        #    except AttributeError:
     59        #        pass
    4660        if option.schema:
    4761            tmp = {'value':value}
     
    6983        if option.ignore_time and str(self.scalar_type) == str(ScalarType.time):
    7084            return ignore
    71         if type(self.value) is EnumValue:
    72             value = self.yaml_fix(str(self.value))
    73         elif type(self.value) is UndefinedData:
    74             value = '<undefined>'
    75         else:
    76             value = self.yaml_fix(self.value)
     85        value = self.yaml_fix(self.get_value())
    7786        if not option.schema and self.description is None and self.units is None:
    7887            print >>ostream, value
     
    278287            if 'required' in kwds and kwds['required'] is True:
    279288                data._required = True
     289            #
     290            # This logic would setup a '_default' value, which copies the
     291            # initial value of an attribute.  I don't think we need this,
     292            # but for now I'm going to leave this logic in the code.
     293            #
     294            #if 'value' in kwds:
     295            #    data._default = kwds['value']
    280296            dict.__setitem__(self, tmp, data)
    281297
     
    335351                self.declare(tmp)
    336352            item = dict.__getitem__(self,tmp)
     353            item._active=True
    337354            item.load(repn[key])
    338355
  • coopr.opt/trunk/coopr/opt/results/solution.py

    r2109 r2257  
    1616from pyutilib.math import as_number
    1717
    18 default_print_options = Bunch(schema=False, sparse=True, num_solutions=None, ignore_time=False)
     18default_print_options = Bunch(schema=False, sparse=True, num_solutions=None, ignore_time=False, ignore_defaults=False)
    1919
    2020SolutionStatus = Enum('globallyOptimal', 'locallyOptimal',
     
    177177
    178178    def load(self, repn):
    179         if isinstance(repn, basestring):
     179        if isinstance(repn, basestring) or repn is None:
    180180            return
    181181        index = {}
  • coopr.opt/trunk/coopr/opt/results/solver.py

    r2251 r2257  
    7878    def __init__(self):
    7979        MapContainer.__init__(self)
    80         self.declare('solver_ID')
     80        self.declare('name')
    8181        self.declare('status', value=SolverStatus.ok)
    8282        self.declare('return_code')
     
    8484        self.declare('user_time', type=ScalarType.time)
    8585        self.declare('system_time', type=ScalarType.time)
     86        self.declare('wallclock_time', type=ScalarType.time)
    8687        self.declare('termination_condition', value=TerminationCondition.unknown)
    8788        self.declare('termination_message')
Note: See TracChangeset for help on using the changeset viewer.