Changeset 2156


Ignore:
Timestamp:
Jan 12, 2010 10:46:49 PM (11 years ago)
Author:
jwatson
Message:

More cleanup of SIZES pysp example, and output clarification in the WW PH extension.

Location:
coopr.pysp/trunk
Files:
4 edited

Legend:

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

    r2153 r2156  
    498498                                    if (computed_cycle_length >= self.CycleLengthSlamThreshold) and ((ph._current_iteration - self._last_slam_iter) > self.PH_Iters_Between_Cycle_Slams):
    499499                                       # TBD: we may not want to slam immediately - it may disappear on it's own after a few iterations, depending on what other variables do.
    500                                        # note: i am not slamming the offending variable, but a selected variable
    501                                        print "Cycle length exceeds slam threshold="+str(self.CycleLengthSlamThreshold)+"; choosing variable to slam"
     500                                       # note: we are *not* slamming the offending variable, but a selected variable
     501                                       if index is None:
     502                                          print "Cycle issue detected with variable="+variable_name
     503                                       else:
     504                                          print "Cycle issue detected with variable="+variable_name+"["+str(index)+"]"
     505                                       print msg
     506                                       print "Cycle length exceeds iteration slamming threshold="+str(self.CycleLengthSlamThreshold)+"; choosing a variable to slam"
    502507                                       self._pick_one_and_slam_it(ph)
    503508                                    elif (computed_cycle_length > 1) and (computed_cycle_length < self.CycleLengthSlamThreshold):
    504509                                       # there was a (potential) cycle, but the slam threshold wasn't reached.
    505510                                       if self.ReportPotentialCycles is True:
     511                                          if index is None:
     512                                             print "Cycle issue detected with variable="+variable_name
     513                                          else:                                         
     514                                             print "Cycle issue detected with variable="+variable_name+"["+str(index)+"]"                                         
    506515                                          print msg
    507516                                          print "Taking no action to break cycle - length="+str(computed_cycle_length)+" does not exceed slam threshold="+str(self.CycleLengthSlamThreshold)
    508517                                    elif (computed_cycle_length >= self.CycleLengthSlamThreshold) and ((ph._current_iteration - self._last_slam_iter) > self.PH_Iters_Between_Cycle_Slams):
    509                                        # we could have slammed, but we recently did and are taking a break to see if things settle down on their own.
     518                                       # we could have slammed, but we recently did and are taking a break to see if things settle down on their own.
     519                                       if index is None:
     520                                          print "Cycle issue detected with variable="+variable_name
     521                                       else:                                         
     522                                          print "Cycle issue detected with variable="+variable_name+"["+str(index)+"]"                                         
     523                                       print msg
    510524                                       print "Taking no action to break cycle - length="+str(computed_cycle_length)+" does exceed slam threshold="+str(self.CycleLengthSlamThreshold)+ \
    511525                                             ", but another variable was slammed within the past "+str(self.PH_Iters_Between_Cycle_Slams)+" iterations"
     
    524538                                 # note: we currently don't clam continuous variables!
    525539
    526       # TBD: the 1 might need to be parameterized
    527       if (ph._current_iteration > self.SlamAfterIter) and ((ph._current_iteration - self._last_slam_iter) > 1) and (ph._converger.isImproving(1)):
     540      # TBD: the 1 might need to be parameterized - TBD - the 1 should be the PH ITERATIONS BETWEEN CYCLE SLAMS
     541      if (ph._current_iteration > self.SlamAfterIter) and \
     542         ((ph._current_iteration - self._last_slam_iter) > self.PH_Iters_Between_Cycle_Slams) and \
     543         (ph._converger.isImproving(self.PH_Iters_Between_Cycle_Slams)):
     544         print "Slamming criteria are satisifed - accelerating convergence"
    528545         self._pick_one_and_slam_it(ph)
    529546         self._just_slammed_ = True
     
    739756         anywhere = tree_node._averages[variable.name][index].value
    740757
    741       if self.CanSlamToLB is True: fix_value = variable[index].lb()
    742       if self.CanSlamToMin is True: fix_value = node_min
    743       if self.CanSlamToUB is True: fix_value = variable[index].ub()
    744       if self.CanSlamToMax is True: fix_value = node_max
    745       if self.CanSlamToAnywhere is True: fix_value = anywhere
     758      slam_basis_string = ""
     759      if self.CanSlamToLB is True:
     760         fix_value = variable[index].lb()
     761         slam_basis_string = "lower bound"
     762      if self.CanSlamToMin is True:
     763         fix_value = node_min
     764         slam_basis_string = "node minimum"
     765      if self.CanSlamToUB is True:
     766         fix_value = variable[index].ub()
     767         slam_basis_string = "upper bound"
     768      if self.CanSlamToMax is True:
     769         fix_value = node_max
     770         slam_basis_string = "node maximum"
     771      if self.CanSlamToAnywhere is True:
     772         fix_value = anywhere
     773         slam_basis_string = "node average (anywhere)"
    746774      if fix_value is False:
    747775         print "Warning: Not allowed to slam variable="+variable.name+str(index)+" at tree node="+tree_node._name
     
    749777      else:
    750778         if index is None:
    751             print "Slamming variable="+variable.name+" at tree node="+tree_node._name+" to value="+str(fix_value)
     779            print "Slamming variable="+variable.name+" at tree node="+tree_node._name+" to value="+str(fix_value)+"; value="+slam_basis_string
    752780         else:
    753             print "Slamming variable="+variable.name+indexToString(index)+" at tree node="+tree_node._name+" to value="+str(fix_value)
     781            print "Slamming variable="+variable.name+indexToString(index)+" at tree node="+tree_node._name+" to value="+str(fix_value)+"; value="+slam_basis_string
    754782         self._fix_var(ph, tree_node, variable, index, fix_value)
    755783         return True
  • coopr.pysp/trunk/examples/pysp/sizes/README.txt

    r2153 r2156  
    99SIZES10: Objective value with gap=0.12%: 224406.64  Achieved after 10+ minutes and 2.5M branch-and-bound nodes.
    1010
    11 SIZES3 EF SOLUTION (non-zero elements):
     11SIZES3 EF (OPTIMAL) SOLUTION (non-zero elements):
    1212
    1313ProduceSizeFirstStage(3)                  1.000000
     
    3434NumUnitsCutFirstStage(8,8)            12500.000000
    3535
    36 SIZES10 EF SOLUTION (non-zero elements):
     36SIZES10 EF (SUB-OPTIMAL) SOLUTION (non-zero elements):
    3737
    3838ProduceSizeFirstStage(3)                  1.000000
     
    7979
    8080The SIZES example is a great example of where fixing is needed - PH gets close to a high-quality solution quickly, but takes a long
    81 time to "polish" the solution to complete agreement.
     81time to "polish" the solution to complete agreement. Thus, acceleration can be achieved by using variable fixing and slamming; both
     82techniques are described in the PySP documentation. To use these techniques, simply add the following command-line arguments to the
     83runph invocation:
    8284
     85--enable-ww-extensions --ww-extension-cfgfile=config/wwph.cfg --ww-extension-suffixfile=config/wwph.suffixes
     86
     87With these techniques, runph yields the following performance:
     88
     89SIZES3:  Converges in 113 iterations with an objective value=224553.5936
     90SIZES10: Converges in 125 iterations with an objective value=224702.6184
     91
     92In the case of SIZES3, the acceleration comes at a slight increase in solution cost. For SIZES10, it makes convergence possible.
     93In both cases, the solutions are very high-quality relative to the EF objective function values.
  • coopr.pysp/trunk/examples/pysp/sizes/config/wwph.cfg

    r2153 r2156  
    1616# broken by variable slamming.
    1717self.CycleLengthSlamThreshold = 50
    18 
    1918     
    2019# "default" slamming parms
    21 # True and False are the options (case sensitive)
    22 #self.CanSlamToLB = False
    23 #self.CanSlamToMin = False
    24 #self.CanSlamToAnywhere = False
    25 #self.CanSlamToMax = True
    26 #self.CanSlamToUB = False
    27 #self.PH_Iters_Between_Cycle_Slams = 5
     20self.CanSlamToLB = False
     21self.CanSlamToMin = False
     22self.CanSlamToAnywhere = False
     23self.CanSlamToMax = True
     24self.CanSlamToUB = False
    2825
    2926# the next line will try to force at least one variable to be
    30 # fixed every other iteration after iteration 50
    31 # if anything can be slammed
    32 self.SlamAfterIter = 50
     27# fixed every other iteration after iteration 100 if anything
     28# can be slammed. this is a "last-resort" behavior.
     29self.SlamAfterIter = 100
    3330
     31self.PH_Iters_Between_Cycle_Slams = 5
     32
  • coopr.pysp/trunk/examples/pysp/sizes/config/wwph.suffixes

    r2153 r2156  
    1515
    1616# if the production quantities have been stable a long time, fix them.
     17NumProducedFirstStage[*] FixWhenItersConvergedAtLB 30
    1718NumProducedFirstStage[*] FixWhenItersConvergedAtNB 30
    1819
    19 #ProduceSizeFirstStage[1] SlammingPriority 1
    20 #ProduceSizeFirstStage[2] SlammingPriority 2
    21 #ProduceSizeFirstStage[3] SlammingPriority 3
    22 #ProduceSizeFirstStage[4] SlammingPriority 4
    23 #ProduceSizeFirstStage[5] SlammingPriority 5
    24 #ProduceSizeFirstStage[6] SlammingPriority 6
    25 #ProduceSizeFirstStage[7] SlammingPriority 7
    26 #ProduceSizeFirstStage[8] SlammingPriority 8
    27 #ProduceSizeFirstStage[9] SlammingPriority 9
    28 #ProduceSizeFirstStage[10] SlammingPriority 10
     20# if the number of units to cut has been frozen for a while, fix them.
     21NumUnitsCutFirstStage[*,*] FixWhenItersConvergedAtLB 30
     22NumUnitsCutFirstStage[*,*] FixWhenItersConvergedAtNB 30
     23
     24# the num produced variables are problematic to converge,
     25# so slam them to force early convergence.
     26NumProducedFirstStage[1]  SlammingPriority 1
     27NumProducedFirstStage[2]  SlammingPriority 2
     28NumProducedFirstStage[3]  SlammingPriority 3
     29NumProducedFirstStage[4]  SlammingPriority 4
     30NumProducedFirstStage[5]  SlammingPriority 5
     31NumProducedFirstStage[6]  SlammingPriority 6
     32NumProducedFirstStage[7]  SlammingPriority 7
     33NumProducedFirstStage[8]  SlammingPriority 8
     34NumProducedFirstStage[9]  SlammingPriority 9
     35NumProducedFirstStage[10] SlammingPriority 10
     36
     37NumProducedFirstStage[*] CanSlamToMax True
Note: See TracChangeset for help on using the changeset viewer.