Changeset 3072


Ignore:
Timestamp:
Oct 4, 2010 12:14:32 PM (11 years ago)
Author:
wehart
Message:

Fixes due to mutability change in coopr.pyomo.

Location:
coopr.pysp/trunk/coopr/pysp
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/convergence.py

    r1768 r3072  
    141141                           
    142142                           instance = instances[scenario._name]
    143                            this_value = getattr(instance, reference_variable_name)[index].value
    144                            term_diff += scenario._probability * fabs(this_value - node_variable_average[index]())
     143                           this_value = value(getattr(instance, reference_variable_name)[index])
     144                           term_diff += scenario._probability * fabs(this_value - value(node_variable_average[index]))
    145145
    146146      return term_diff
  • coopr.pysp/trunk/coopr/pysp/ph.py

    r2990 r3072  
    962962               for index in variable_indices:
    963963
    964                   tree_node_average = tree_node._averages[variable.name][index]()
     964                  tree_node_average = value(tree_node._averages[variable.name][index])
    965965
    966966                  for scenario in tree_node._scenarios:
     
    974974                        # the variable toward the mean, the weights will blow up and be huge by the
    975975                        # time that blending is activated.
    976                         variable_blend_indicator = getattr(instance, blend_parameter_name)[index]()
     976                        variable_blend_indicator = value(getattr(instance, blend_parameter_name)[index])
    977977
    978978                        # get the weight and rho parameters for this variable/index combination.
    979                         rho_value = getattr(instance, rho_parameter_name)[index]()
    980                         current_variable_weight = getattr(instance, weight_parameter_name)[index]()
     979                        rho_value = value(getattr(instance, rho_parameter_name)[index])
     980                        current_variable_weight = value(getattr(instance, weight_parameter_name)[index])
    981981
    982982                        # if I'm maximizing, invert value prior to adding (hack to implement negatives).
     
    984984                        if self._is_minimizing is False:
    985985                           current_variable_weight = (-current_variable_weight)
    986                         current_variable_value = getattr(instance,variable.name)[index]()
     986                        current_variable_value = value(getattr(instance,variable.name)[index])
    987987                        new_variable_weight = current_variable_weight + variable_blend_indicator * rho_value * (current_variable_value - tree_node_average)
    988988                        # I have the correct updated value, so now invert if maximizing.
    989989                        if self._is_minimizing is False:
    990990                           new_variable_weight = (-new_variable_weight)
    991                         getattr(instance, weight_parameter_name)[index].value = new_variable_weight
     991                        getattr(instance, weight_parameter_name)[index] = new_variable_weight
    992992
    993993      # we shouldn't have to re-simplify the expression, as we aren't adding any constant-variable terms - just modifying parameters.
  • coopr.pysp/trunk/coopr/pysp/scenariotree.py

    r3038 r3072  
    159159                  if index in scenario_variable:
    160160                     num_scenarios_with_index = num_scenarios_with_index + 1
    161                      var_value = getattr(scenario_instance, variable.name)[index].value
     161                     var_value = value(getattr(scenario_instance, variable.name)[index])
    162162                     avg += (scenario._probability * var_value)
    163163               if num_scenarios_with_index > 0:
    164                   variable[index].value = avg / node_probability
     164                  variable[index] = avg / node_probability
    165165
    166166   #
     
    296296         stage = self._stage_map[stage_id]
    297297
    298          cost_variable_string = stage_cost_variable_ids[stage_id].value # de-reference is required to access the parameter value
     298         cost_variable_string = value(stage_cost_variable_ids[stage_id]) # de-reference is required to access the parameter value
    299299
    300300         # to be extracted from the string.
     
    427427            raise ValueError, "No stage is assigned to tree node=" + tree_node._name
    428428
    429          stage_name = node_stage_ids[tree_node_name].value
     429         stage_name = value(node_stage_ids[tree_node_name])
    430430         if stage_name not in self._stage_map.keys():
    431431            raise ValueError, "Unknown stage=" + stage_name + " assigned to tree node=" + tree_node._name
    432432
    433433         new_tree_node = ScenarioTreeNode(tree_node_name,
    434                                           node_probability_map[tree_node_name].value,
     434                                          value(node_probability_map[tree_node_name]),
    435435                                          self._stage_map[stage_name],
    436436                                          self._reference_instance)
     
    475475            raise ValueError, "No leaf tree node specified for scenario=" + scenario_name
    476476         else:
    477             scenario_leaf_node_name = scenario_leaf_ids[scenario_name].value
     477            scenario_leaf_node_name = value(scenario_leaf_ids[scenario_name])
    478478            if scenario_leaf_node_name not in self._tree_node_map.keys():
    479479               raise ValueError, "Uknown tree node=" + scenario_leaf_node_name + " specified as leaf of scenario=" + scenario_name
Note: See TracChangeset for help on using the changeset viewer.