Changeset 3073


Ignore:
Timestamp:
Oct 4, 2010 9:35:24 PM (10 years ago)
Author:
jwatson
Message:

Complete set of changes to make PySP compatible with latest immutable parameters change.

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

Legend:

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

    r2573 r3073  
    369369            new_w_index = reference_variable._index # TBD - need to be careful with the shallow copy here
    370370            new_w_parameter_name = "PHWEIGHT_"+reference_variable.name
    371             new_w_parameter = Param(new_w_index,name=new_w_parameter_name)
     371            new_w_parameter = Param(new_w_index, name=new_w_parameter_name, mutable=True)
    372372            setattr(instance,new_w_parameter_name,new_w_parameter)
    373373
     
    381381            new_avg_index = reference_variable._index # TBD - need to be careful with the shallow copy here
    382382            new_avg_parameter_name = "PHAVG_"+reference_variable.name
    383             new_avg_parameter = Param(new_avg_index,name=new_avg_parameter_name)
     383            new_avg_parameter = Param(new_avg_index, name=new_avg_parameter_name, mutable=True)
    384384            setattr(instance,new_avg_parameter_name,new_avg_parameter)
    385385
     
    389389            new_rho_index = reference_variable._index # TBD - need to be careful with the shallow copy here
    390390            new_rho_parameter_name = "PHRHO_"+reference_variable.name
    391             new_rho_parameter = Param(new_rho_index,name=new_rho_parameter_name)
     391            new_rho_parameter = Param(new_rho_index, name=new_rho_parameter_name, mutable=True)
    392392            setattr(instance,new_rho_parameter_name,new_rho_parameter)
    393393
     
    426426                  new_min_index = reference_variable._index # TBD - need to be careful with the shallow copy here (and below)
    427427                  new_min_parameter_name = "NODEMIN_"+reference_variable.name
    428                   new_min_parameter = Param(new_min_index,name=new_min_parameter_name)
     428                  new_min_parameter = Param(new_min_index, name=new_min_parameter_name, mutable=True)
    429429                  for index in new_min_index:
    430430                     new_min_parameter[index] = 0.0
     
    433433                  new_avg_index = reference_variable._index
    434434                  new_avg_parameter_name = "NODEAVG_"+reference_variable.name
    435                   new_avg_parameter = Param(new_avg_index,name=new_avg_parameter_name)
     435                  new_avg_parameter = Param(new_avg_index, name=new_avg_parameter_name, mutable=True)
    436436                  for index in new_avg_index:
    437437                     new_avg_parameter[index] = 0.0
     
    440440                  new_max_index = reference_variable._index
    441441                  new_max_parameter_name = "NODEMAX_"+reference_variable.name
    442                   new_max_parameter = Param(new_max_index,name=new_max_parameter_name)
     442                  new_max_parameter = Param(new_max_index, name=new_max_parameter_name, mutable=True)
    443443                  for index in new_max_index:
    444444                     new_max_parameter[index] = 0.0
     
    619619                  for index in variable_indices:
    620620
    621                      tree_node_average = tree_node._averages[variable.name][index]()
     621                     tree_node_average = value(tree_node._averages[variable.name][index])
    622622
    623623                     for scenario in tree_node._scenarios:
     
    627627                        if getattr(instance,variable.name)[index].status != VarStatus.unused:
    628628
    629                            current_variable_weight = getattr(instance, weight_parameter_name)[index].value
     629                           current_variable_weight = value(getattr(instance, weight_parameter_name)[index])
    630630                           # if I'm maximizing, invert value prior to adding (hack to implement negatives)
    631631                           if self._is_minimizing is False:
     
    636636                           if self._is_minimizing is False:
    637637                              new_variable_weight = (-new_variable_weight)
    638                            getattr(instance, weight_parameter_name)[index].value = new_variable_weight
     638                           getattr(instance, weight_parameter_name)[index] = new_variable_weight
    639639
    640640      # we shouldn't have to re-simplify the expression, as we aren't adding any constant-variable terms - just modifying parameters.
     
    663663                  for index in variable_indices:
    664664
    665                      tree_node_average = tree_node._averages[variable.name][index]()
     665                     tree_node_average = value(tree_node._averages[variable.name][index])
    666666
    667667                     if getattr(instance,variable.name)[index].status != VarStatus.unused:
    668668
    669                         current_variable_weight = getattr(instance, weight_parameter_name)[index].value
     669                        current_variable_weight = value(getattr(instance, weight_parameter_name)[index])
    670670                        # if I'm maximizing, invert value prior to adding (hack to implement negatives)
    671671                        if self._is_minimizing is False:
     
    676676                        if self._is_minimizing is False:
    677677                           new_variable_weight = (-new_variable_weight)
    678                         getattr(instance, weight_parameter_name)[index].value = new_variable_weight
     678                        getattr(instance, weight_parameter_name)[index] = new_variable_weight
    679679
    680680      # we shouldn't have to re-simplify the expression, as we aren't adding any constant-variable terms - just modifying parameters.
     
    986986                        if is_used is True:
    987987
    988                               minimum_value = tree_node._minimums[variable_name][index]()
    989                               maximum_value = tree_node._maximums[variable_name][index]()
     988                              minimum_value = value(tree_node._minimums[variable_name][index])
     989                              maximum_value = value(tree_node._maximums[variable_name][index])
    990990
    991991                              num_outputs_this_stage = num_outputs_this_stage + 1                           
     
    10061006                           
    10071007                              if output_values is True:
    1008                                  average_value = tree_node._averages[variable_name][index]()
     1008                                 average_value = value(tree_node._averages[variable_name][index])
    10091009                                 print "\t\t\t\tValues: ",                       
    10101010                                 for scenario in tree_node._scenarios:
     
    10201020                                 for scenario in tree_node._scenarios:
    10211021                                    instance = self._instances[scenario._name]
    1022                                     print "%12.4f" % getattr(instance,weight_parameter_name)[index].value,
     1022                                    print "%12.4f" % value(getattr(instance,weight_parameter_name)[index])
    10231023                                    if scenario == tree_node._scenarios[-1]:
    10241024                                       print ""
    10251025                              if output_averages:
    1026                                  print "\t\t\t\tAverage: %12.4f" % (tree_node._averages[variable_name][index].value)
     1026                                 print "\t\t\t\tAverage: %12.4f" % (value(tree_node._averages[variable_name][index]))
    10271027
    10281028            if num_outputs_this_stage == 0:
  • coopr.pysp/trunk/coopr/pysp/convergence.py

    r3072 r3073  
    141141                           
    142142                           instance = instances[scenario._name]
    143                            this_value = value(getattr(instance, reference_variable_name)[index])
     143                           this_value = getattr(instance, reference_variable_name)[index].value
    144144                           term_diff += scenario._probability * fabs(this_value - value(node_variable_average[index]))
    145145
     
    185185
    186186                     # should think about nixing the magic constant below (not sure how to best pararamterize it).
    187                      if fabs(node_variable_average[index]()) > 0.0001:
     187                     if fabs(value(node_variable_average[index])) > 0.0001:
    188188                     
    189189                        is_used = True # until proven otherwise
     
    198198                        if is_used is True:
    199199
    200                            average_value = node_variable_average[index]()
     200                           average_value = value(node_variable_average[index])
    201201                         
    202202                           for scenario in tree_node._scenarios:
  • coopr.pysp/trunk/coopr/pysp/csvsolutionwriter.py

    r3048 r3073  
    4949             for var_name, var in tree_node._solutions.items():
    5050                for idx in var:
    51                    print >>output_file, stage_name, ",", tree_node_name, ",", var_name, ",", index_to_string(idx), ",", var[idx]()
     51                   print >>output_file, stage_name, ",", tree_node_name, ",", var_name, ",", index_to_string(idx), ",", var[idx].value
    5252
    5353       output_file.close()
  • coopr.pysp/trunk/coopr/pysp/ph.py

    r3072 r3073  
    706706               new_min_parameter = None
    707707               if (len(new_min_index) is 1) and (None in new_min_index):
    708                   new_min_parameter = Param(name=new_min_parameter_name)
     708                  new_min_parameter = Param(name=new_min_parameter_name, mutable=True)
    709709               else:
    710                   new_min_parameter = Param(new_min_index,name=new_min_parameter_name)
     710                  new_min_parameter = Param(new_min_index, name=new_min_parameter_name, mutable=True)
    711711               for index in new_min_index:
    712712                  new_min_parameter[index] = 0.0
     
    717717               new_avg_parameter = None
    718718               if (len(new_avg_index) is 1) and (None in new_avg_index):
    719                   new_avg_parameter = Param(name=new_avg_parameter_name)
     719                  new_avg_parameter = Param(name=new_avg_parameter_name, mutable=True)
    720720               else:
    721                   new_avg_parameter = Param(new_avg_index,name=new_avg_parameter_name)
     721                  new_avg_parameter = Param(new_avg_index, name=new_avg_parameter_name, mutable=True)
    722722               for index in new_avg_index:
    723723                  new_avg_parameter[index] = 0.0
     
    728728               new_max_parameter = None
    729729               if (len(new_max_index) is 1) and (None in new_max_index):
    730                   new_max_parameter = Param(name=new_max_parameter_name)
     730                  new_max_parameter = Param(name=new_max_parameter_name, mutable=True)
    731731               else:
    732                   new_max_parameter = Param(new_max_index,name=new_max_parameter_name)
     732                  new_max_parameter = Param(new_max_index, name=new_max_parameter_name, mutable=True)
    733733               for index in new_max_index:
    734734                  new_max_parameter[index] = 0.0
     
    14171417                              maximum_value = tree_node._maximums[variable_name]
    14181418                           else:
    1419                               minimum_value = tree_node._minimums[variable_name][index]()
    1420                               maximum_value = tree_node._maximums[variable_name][index]()
     1419                              minimum_value = value(tree_node._minimums[variable_name][index])
     1420                              maximum_value = value(tree_node._maximums[variable_name][index])
    14211421
    14221422                           # there really isn't a need to output variables whose
     
    14481448
    14491449                              if output_values is True:
    1450                                  average_value = tree_node._averages[variable_name][index]()
     1450                                 average_value = value(tree_node._averages[variable_name][index])
    14511451                                 if output_only_statistics is False:
    14521452                                    print "\t\t\t\tValues: ",
     
    14721472                                 for scenario in tree_node._scenarios:
    14731473                                    instance = self._instances[scenario._name]
    1474                                     print "%12.4f" % getattr(instance,weight_parameter_name)[index].value,
     1474                                    print "%12.4f" % value(getattr(instance,weight_parameter_name)[index]),
    14751475                                    if scenario == tree_node._scenarios[-1]:
    14761476                                       print ""
  • coopr.pysp/trunk/coopr/pysp/phobjective.py

    r2818 r3073  
    196196def create_piecewise_constraint_expression(lb, ub, instance_variable, variable_average, quad_variable, tolerance):
    197197
    198    penalty_at_lb = (lb - variable_average()) * (lb - variable_average())
    199    penalty_at_ub = (ub - variable_average()) * (ub - variable_average())
     198   penalty_at_lb = (lb - value(variable_average)) * (lb - value(variable_average))
     199   penalty_at_ub = (ub - value(variable_average)) * (ub - value(variable_average))
    200200   slope = None
    201201   if fabs(ub-lb) > tolerance:
     
    339339                        ub = x.ub()
    340340
    341                         node_min = node_min_parameter[index]()
    342                         node_max = node_max_parameter[index]()
     341                        node_min = value(node_min_parameter[index])
     342                        node_max = value(node_max_parameter[index])
    343343
    344344                        # compute the breakpoint sequence according to the specified strategy.
     
    350350                              compute_exponential_from_mean_breakpoints,
    351351                            )[ breakpoint_strategy ]
    352                             args = ( lb, node_min, xavg(), node_max, ub, \
     352                            args = ( lb, node_min, value(xavg), node_max, ub, \
    353353                                linearize_nonbinary_penalty_terms, tolerance )
    354354                            breakpoints = strategy( *args )
  • coopr.pysp/trunk/coopr/pysp/phserver.py

    r2772 r3073  
    142142
    143143         for index in weight_index:
    144             target_weight_parameter[index] = weight_update[index]()
     144            target_weight_parameter[index] = value(weight_update[index])
    145145
    146146      for average_update in new_averages:
     
    151151
    152152         for index in average_index:
    153             target_average_parameter[index] = average_update[index]()
     153            target_average_parameter[index] = value(average_update[index])
    154154
    155155   def update_rhos(self, scenario_name, new_rhos):
     
    169169
    170170         for index in rho_index:
    171             target_rho_parameter[index] = rho_update[index]() # the value operator is crucial!
     171            target_rho_parameter[index] = value(rho_update[index])
    172172
    173173   def update_tree_node_statistics(self, scenario_name, new_node_minimums, new_node_maximums):
  • coopr.pysp/trunk/coopr/pysp/phutils.py

    r3014 r3073  
    270270      new_w_parameter = None
    271271      if (len(new_w_index) is 1) and (None in new_w_index):
    272          new_w_parameter = Param(name=new_w_parameter_name)
    273       else:
    274          new_w_parameter = Param(new_w_index,name=new_w_parameter_name)
     272         new_w_parameter = Param(name=new_w_parameter_name, mutable=True)
     273      else:
     274         new_w_parameter = Param(new_w_index, name=new_w_parameter_name, mutable=True)
    275275      setattr(instance,new_w_parameter_name,new_w_parameter)
    276276
     
    288288      new_avg_parameter = None
    289289      if (len(new_avg_index) is 1) and (None in new_avg_index):
    290          new_avg_parameter = Param(name=new_avg_parameter_name)
    291       else:
    292          new_avg_parameter = Param(new_avg_index,name=new_avg_parameter_name)
     290         new_avg_parameter = Param(name=new_avg_parameter_name, mutable=True)
     291      else:
     292         new_avg_parameter = Param(new_avg_index, name=new_avg_parameter_name, mutable=True)
    293293      setattr(instance,new_avg_parameter_name,new_avg_parameter)
    294294
     
    302302      new_rho_parameter = None
    303303      if (len(new_avg_index) is 1) and (None in new_avg_index):
    304          new_rho_parameter = Param(name=new_rho_parameter_name)
    305       else:
    306          new_rho_parameter = Param(new_rho_index,name=new_rho_parameter_name)
     304         new_rho_parameter = Param(name=new_rho_parameter_name, mutable=True)
     305      else:
     306         new_rho_parameter = Param(new_rho_index, name=new_rho_parameter_name, mutable=True)
    307307      setattr(instance,new_rho_parameter_name,new_rho_parameter)
    308308
     
    334334      new_blend_parameter = None
    335335      if (len(new_avg_index) is 1) and (None in new_avg_index):
    336          new_blend_parameter = Param(name=new_blend_parameter_name, within=Binary)
    337       else:
    338          new_blend_parameter = Param(new_blend_index, name=new_blend_parameter_name, within=Binary)
     336         new_blend_parameter = Param(name=new_blend_parameter_name, within=Binary, mutable=True)
     337      else:
     338         new_blend_parameter = Param(new_blend_index, name=new_blend_parameter_name, within=Binary, mutable=True)
    339339      setattr(instance,new_blend_parameter_name,new_blend_parameter)
    340340
  • coopr.pysp/trunk/coopr/pysp/scenariotree.py

    r3072 r3073  
    135135         for index in variable._index:
    136136            if variable[index].active is True:
    137                variable[index] = average_parameter[index]()
     137               variable[index] = value(average_parameter[index])
    138138
    139139   #
     
    172172      # IMPT: This implicitly assumes convergence across the scenarios - if not, garbage results.
    173173      instance = scenario_instance_map[self._scenarios[0]._name]
    174       my_cost = instance.active_components(Var)[self._stage._cost_variable[0].name][self._stage._cost_variable[1]]()
     174      my_cost = instance.active_components(Var)[self._stage._cost_variable[0].name][self._stage._cost_variable[1]].value
    175175      child_cost = 0.0
    176176      for child in self._children:
     
    529529      aggregate_cost = 0.0
    530530      for stage in self._stages:
    531          instance_cost_variable = instance.active_components(Var)[stage._cost_variable[0].name][stage._cost_variable[1]]()
     531         instance_cost_variable = instance.active_components(Var)[stage._cost_variable[0].name][stage._cost_variable[1]].value
    532532         aggregate_cost += instance_cost_variable
    533533      return aggregate_cost
     
    811811               # if this is a singleton variable, then it should necessarily be active -
    812812               # otherwise, it wouldn't be referenced in the stage!!!
    813                value = solution_variable[None]()
     813               value = solution_variable[None].value
    814814               if fabs(value) > epsilon:
    815815                  print "\t\t"+variable.name+"="+str(value)
     
    817817               for index in indices:
    818818                  if (solution_variable[index].active is True) and (index in solution_variable):
    819                      value = solution_variable[index]()
     819                     value = solution_variable[index].value
    820820                     if (value is not None) and (fabs(value) > epsilon):
    821821                        print "\t\t"+variable.name+indexToString(index)+"="+str(value)
     
    890890         aggregate_cost = 0.0
    891891         for stage in self._stages:
    892             instance_cost_variable = instance.active_components(Var)[stage._cost_variable[0].name][stage._cost_variable[1]]()
     892            instance_cost_variable = instance.active_components(Var)[stage._cost_variable[0].name][stage._cost_variable[1]].value
    893893            print "\tStage=%20s     Cost=%10.4f" % (stage._name, instance_cost_variable)
    894894            aggregate_cost += instance_cost_variable
  • coopr.pysp/trunk/coopr/pysp/wwphextension.py

    r2587 r3073  
    281281                  # is a singleton. this case be cleaned up when the source issue in Pyomo is fixed.                     
    282282                  if (len(new_stat_index) is 1) and (None in new_stat_index):
    283                      new_stat_parameter = Param(name=new_stat_parameter_name)
     283                     new_stat_parameter = Param(name=new_stat_parameter_name, mutable=True)
    284284                  else:
    285                      new_stat_parameter = Param(new_stat_index,name=new_stat_parameter_name)
     285                     new_stat_parameter = Param(new_stat_index, name=new_stat_parameter_name, mutable=True)
    286286                  for newindex in new_stat_index:
    287287                     new_stat_parameter[newindex] = 0
     
    293293                  new_conv_parameter = None
    294294                  if (len(new_conv_index) is 1) and (None in new_conv_index):
    295                      new_conv_parameter = Param(name=new_conv_parameter_name)
     295                     new_conv_parameter = Param(name=new_conv_parameter_name, mutable=True)
    296296                  else:
    297                      new_conv_parameter = Param(new_conv_index,name=new_conv_parameter_name)
     297                     new_conv_parameter = Param(new_conv_index, name=new_conv_parameter_name, mutable=True)
    298298                  for newindex in new_conv_index:
    299299                     new_conv_parameter[newindex] = 0.5 # not an int, so harmless
     
    305305                  new_fix_parameter = None
    306306                  if (len(new_fix_index) is 1) and (None in new_fix_index):
    307                      new_fix_parameter = Param(name=new_fix_parameter_name)
     307                     new_fix_parameter = Param(name=new_fix_parameter_name, mutable=True)
    308308                  else:
    309                      new_fix_parameter = Param(new_fix_index,name=new_fix_parameter_name)
     309                     new_fix_parameter = Param(new_fix_index, name=new_fix_parameter_name, mutable=True)
    310310                  for newindex in new_fix_index:
    311311                     new_fix_parameter[newindex] = False
     
    317317                  new_hash_parameter = None
    318318                  if (len(new_hash_index) is 1) and (None in new_hash_index):
    319                      new_hash_parameter = Param(ph._iteration_index_set, name=new_hash_parameter_name)
     319                     new_hash_parameter = Param(ph._iteration_index_set, name=new_hash_parameter_name, mutable=True)
    320320                  else:
    321                      new_hash_parameter = Param(new_hash_index, ph._iteration_index_set, name=new_hash_parameter_name)
     321                     new_hash_parameter = Param(new_hash_index, ph._iteration_index_set, name=new_hash_parameter_name, mutable=True)
    322322                  for newindex in new_hash_index:
    323323                     for i in range(0, ph._max_iterations+1):
     
    400400
    401401                           if isinstance(variable_type, IntegerSet) or isinstance(variable_type, BooleanSet):                           
    402                               node_min = self.Int_If_Close_Enough(ph, tree_node._minimums[variable_name][index]())
    403                               node_max = self.Int_If_Close_Enough(ph, tree_node._maximums[variable_name][index]())
     402                              node_min = self.Int_If_Close_Enough(ph, value(tree_node._minimums[variable_name][index]))
     403                              node_max = self.Int_If_Close_Enough(ph, value(tree_node._maximums[variable_name][index]))
    404404
    405405                              # update convergence prior to checking for fixing.
     
    425425                           else:
    426426                             
    427                               node_min = tree_node._minimums[variable_name][index]()
    428                               node_max = tree_node._maximums[variable_name][index]()
     427                              node_min = value(tree_node._minimums[variable_name][index])
     428                              node_max = value(tree_node._maximums[variable_name][index])
    429429                             
    430430                              self._continuous_convergence_tracking(ph, tree_node, variable_name, index, node_min, node_max)
     
    492492
    493493                           if isinstance(variable_type, IntegerSet) or isinstance(variable_type, BooleanSet):                           
    494                               node_min = self.Int_If_Close_Enough(ph, tree_node._minimums[variable_name][index]())
    495                               node_max = self.Int_If_Close_Enough(ph, tree_node._maximums[variable_name][index]())
     494                              node_min = self.Int_If_Close_Enough(ph, value(tree_node._minimums[variable_name][index]))
     495                              node_max = self.Int_If_Close_Enough(ph, value(tree_node._maximums[variable_name][index]))
    496496
    497497                              # update convergence prior to checking for fixing.
     
    553553
    554554                              # obviously don't round in the continuous case.
    555                               node_min = tree_node._minimums[variable_name][index]()
    556                               node_max = tree_node._maximums[variable_name][index]()
     555                              node_min = value(tree_node._minimums[variable_name][index])
     556                              node_max = value(tree_node._maximums[variable_name][index])
    557557
    558558                              # update convergence prior to checking for fixing.
     
    614614       # keep track of cumulative iters of convergence to the same int
    615615       if (node_min == node_max) and (type(node_min) is types.IntType):
    616           if node_min == tree_node._last_converged_val[variable_name][index]():
    617              tree_node._num_iters_converged[variable_name][index].value = tree_node._num_iters_converged[variable_name][index].value + 1
     616          if node_min == value(tree_node._last_converged_val[variable_name][index]):
     617             tree_node._num_iters_converged[variable_name][index] = value(tree_node._num_iters_converged[variable_name][index]) + 1
    618618          else:
    619              tree_node._num_iters_converged[variable_name][index].value = 1
     619             tree_node._num_iters_converged[variable_name][index] = 1
    620620             tree_node._last_converged_val[variable_name][index] = node_min
    621621       else:
    622           tree_node._num_iters_converged[variable_name][index].value = 0
    623           tree_node._last_converged_val[variable_name][index].value = 0.5 
     622          tree_node._num_iters_converged[variable_name][index] = 0
     623          tree_node._last_converged_val[variable_name][index] = 0.5 
    624624
    625625#=========================   
     
    627627       # keep track of cumulative iters of convergence to the same value within tolerance.
    628628       if abs(node_max - node_min) <= ph._integer_tolerance:
    629           if abs(node_min - tree_node._last_converged_val[variable_name][index]()) <= ph._integer_tolerance:
    630              tree_node._num_iters_converged[variable_name][index].value  = tree_node._num_iters_converged[variable_name][index].value + 1
     629          if abs(node_min - value(tree_node._last_converged_val[variable_name][index])) <= ph._integer_tolerance:
     630             tree_node._num_iters_converged[variable_name][index] = value(tree_node._num_iters_converged[variable_name][index]) + 1
    631631          else:
    632              tree_node._num_iters_converged[variable_name][index].value = 1
     632             tree_node._num_iters_converged[variable_name][index] = 1
    633633             tree_node._last_converged_val[variable_name][index] = node_min
    634634       else:
    635           tree_node._num_iters_converged[variable_name][index].value = 0
     635          tree_node._num_iters_converged[variable_name][index] = 0
    636636          tree_node._last_converged_val[variable_name][index] = 0.2342343243223423 # TBD - avoid the magic constant!
    637637
     
    645645         weight_parameter_name = "PHWEIGHT_"+variable_name
    646646         if index is None:
    647             tree_node._w_hash[variable_name][ph._current_iteration].value += getattr(instance,weight_parameter_name)[index].value * self.W_hash_rand_val
     647            tree_node._w_hash[variable_name][ph._current_iteration] += value(getattr(instance,weight_parameter_name)[index]) * self.W_hash_rand_val
    648648         else:
    649             tree_node._w_hash[variable_name][index,ph._current_iteration].value += getattr(instance,weight_parameter_name)[index].value * self.W_hash_rand_val
     649            tree_node._w_hash[variable_name][index,ph._current_iteration] += value(getattr(instance,weight_parameter_name)[index]) * self.W_hash_rand_val
    650650         self.W_hash_rand_val = (self.W_hash_b + self.W_hash_a * self.W_hash_rand_val) % self.W_hash_c
    651651
     
    664664             for index in variable_index:
    665665                if index is None:
    666                    print "%4d        %50ls %20.5f" % (ph._current_iteration, tree_node._w_hash[variable_name][ph._current_iteration], tree_node._w_hash[variable_name][ph._current_iteration]())
     666                   print "%4d        %50ls %20.5f" % (ph._current_iteration, tree_node._w_hash[variable_name][ph._current_iteration], value(tree_node._w_hash[variable_name][ph._current_iteration]))
    667667                else:
    668                    print "%4d        %50ls %20.5f" % (ph._current_iteration, tree_node._w_hash[variable_name][index,ph._current_iteration], tree_node._w_hash[variable_name][index,ph._current_iteration]())
     668                   print "%4d        %50ls %20.5f" % (ph._current_iteration, tree_node._w_hash[variable_name][index,ph._current_iteration], value(tree_node._w_hash[variable_name][index,ph._current_iteration]))
    669669                                                                                                                           
    670670#=========================
     
    674674      # if the values are converged, then don't report a cycle - often, the weights at convergence are 0s, and even
    675675      # if they aren't, they won't move if the values are uniform.
    676       if (tree_node._num_iters_converged[variable_name][index].value == 0) and (tree_node._fixed_var_flag[variable_name][index].value is False):
     676      if (value(tree_node._num_iters_converged[variable_name][index]) == 0) and (value(tree_node._fixed_var_flag[variable_name][index]) is False):
    677677         current_hash_value = None
    678678         if index is None:
    679             current_hash_value = tree_node._w_hash[variable_name][ph._current_iteration]()
     679            current_hash_value = value(tree_node._w_hash[variable_name][ph._current_iteration])
    680680         else:
    681             current_hash_value = tree_node._w_hash[variable_name][index,ph._current_iteration]()
     681            current_hash_value = value(tree_node._w_hash[variable_name][index,ph._current_iteration])
    682682         # scan starting from the farthest point back in history to the closest - this is required to
    683683         # identify the longest possible cycles, which is what we want.
     
    685685             this_hash_value = None
    686686             if index is None:
    687                 this_hash_value = tree_node._w_hash[variable_name][i]()
     687                this_hash_value = value(tree_node._w_hash[variable_name][i])
    688688             else:
    689                 this_hash_value = tree_node._w_hash[variable_name][index,i]()
     689                this_hash_value = value(tree_node._w_hash[variable_name][index,i])
    690690             if abs(this_hash_value - current_hash_value) <= ph._integer_tolerance:
    691691                if report_possible_cycles is True:
     
    719719          getattr(instance,variable.name)[index].fixed = True
    720720          getattr(instance,variable.name)[index].value = fix_value
    721           tree_node._fixed_var_flag[variable.name][index].value = True
     721          tree_node._fixed_var_flag[variable.name][index] = True
    722722
    723723          variable_type = variable.domain         
     
    726726             # pretty-print the index, string the trailing spaces from the strings.
    727727             if index is None:
    728                 print "Fixing variable="+variable.name+" at tree node="+tree_node._name+" to value="+str(fix_value)+"; converged for "+str(tree_node._num_iters_converged[variable.name][index]())+" iterations"
     728                print "Fixing variable="+variable.name+" at tree node="+tree_node._name+" to value="+str(fix_value)+"; converged for "+str(value(tree_node._num_iters_converged[variable.name][index]))+" iterations"
    729729             else:
    730                 print "Fixing variable="+variable.name+indexToString(index)+" at tree node="+tree_node._name+" to value="+str(fix_value)+"; converged for "+str(tree_node._num_iters_converged[variable.name][index]())+" iterations"               
     730                print "Fixing variable="+variable.name+indexToString(index)+" at tree node="+tree_node._name+" to value="+str(fix_value)+"; converged for "+str(value(tree_node._num_iters_converged[variable.name][index]))+" iterations"               
    731731             fixing_reported = True
    732732             if isinstance(variable_type, IntegerSet) or isinstance(variable_type, BooleanSet):
     
    744744      # jpw: i don't think this logic is correct - shouldn't "non-bound" be moved after the lb/ub checks - this doesn't check a bound!
    745745      # dlw reply: i meant it to mean "without regard to bound" so i have updated the document
    746       if nb_iters > 0 and tree_node._num_iters_converged[variable_name][index]() >= nb_iters:
     746      if nb_iters > 0 and value(tree_node._num_iters_converged[variable_name][index]) >= nb_iters:
    747747            return True
    748748      else:
     
    756756         if variable[index].ub is not None:
    757757            ub = variable[index].ub()
    758          conval = tree_node._last_converged_val[variable_name][index]()
     758         conval = value(tree_node._last_converged_val[variable_name][index])
    759759         # note: if they are converged node_max == node_min
    760          if (lb is not None) and (lb_iters > 0) and (tree_node._num_iters_converged[variable_name][index]() >= lb_iters) and (conval == lb):
     760         if (lb is not None) and (lb_iters > 0) and (value(tree_node._num_iters_converged[variable_name][index]) >= lb_iters) and (conval == lb):
    761761            return True
    762          elif (ub is not None) and (ub_iters > 0) and (tree_node._num_iters_converged[variable_name][index]() >= ub_iters) and (conval == ub):
     762         elif (ub is not None) and (ub_iters > 0) and (value(tree_node._num_iters_converged[variable_name][index]) >= ub_iters) and (conval == ub):
    763763            return True
    764764      # if we are still here, nothing triggered fixing
     
    769769
    770770      if self.fix_continuous_variables is True:
    771          if self.FixWhenItersConvergedContinuous > 0 and tree_node._num_iters_converged[variable.name][index]() >= self.FixWhenItersConvergedContinuous:
     771         if self.FixWhenItersConvergedContinuous > 0 and value(tree_node._num_iters_converged[variable.name][index]) >= self.FixWhenItersConvergedContinuous:
    772772               return True
    773773
     
    788788      variable_name = variable.name
    789789      if isinstance(variable_type, IntegerSet) or isinstance(variable_type, BooleanSet):
    790          node_min = self.Int_If_Close_Enough(ph, tree_node._minimums[variable_name][index]())
    791          node_max = self.Int_If_Close_Enough(ph, tree_node._maximums[variable_name][index]())
    792          anywhere = round(tree_node._averages[variable.name][index].value)
     790         node_min = self.Int_If_Close_Enough(ph, value(tree_node._minimums[variable_name][index]))
     791         node_max = self.Int_If_Close_Enough(ph, value(tree_node._maximums[variable_name][index]))
     792         anywhere = round(value(tree_node._averages[variable.name][index]))
    793793      else:   
    794          node_min = tree_node._minimums[variable_name][index]()
    795          node_max = tree_node._maximums[variable_name][index]()
    796          anywhere = tree_node._averages[variable.name][index].value
     794         node_min = value(tree_node._minimums[variable_name][index])
     795         node_max = value(tree_node._maximums[variable_name][index])
     796         anywhere = value(tree_node._averages[variable.name][index])
    797797
    798798      slam_basis_string = ""
     
    856856            for tree_node in variable[full_index]._stage._tree_nodes:
    857857               # determine if the variable is already fixed (the trusting version...).
    858                if tree_node._fixed_var_flag[variable_name][full_index].value is False:
     858               if value(tree_node._fixed_var_flag[variable_name][full_index]) is False:
    859859                  didone = self._slam(ph, tree_node, variable, full_index)
    860860            if didone:
     
    908908
    909909                        if isinstance(variable_type, IntegerSet) or isinstance(variable_type, BooleanSet):                           
    910                            node_min = self.Int_If_Close_Enough(ph, tree_node._minimums[variable_name][index]())
    911                            node_max = self.Int_If_Close_Enough(ph, tree_node._maximums[variable_name][index]())
     910                           node_min = self.Int_If_Close_Enough(ph, value(tree_node._minimums[variable_name][index]))
     911                           node_max = self.Int_If_Close_Enough(ph, value(tree_node._maximums[variable_name][index]))
    912912
    913913                           if node_min == node_max:
Note: See TracChangeset for help on using the changeset viewer.