Changeset 2366


Ignore:
Timestamp:
Feb 17, 2010 1:44:23 PM (10 years ago)
Author:
wehart
Message:

Merged revisions 2361-2365 via svnmerge from
https://software.sandia.gov/svn/public/coopr/coopr.pysp/trunk

........

r2362 | wehart | 2010-02-17 10:19:40 -0700 (Wed, 17 Feb 2010) | 2 lines


Fix to run with glpk but not cplex.

........

r2363 | wehart | 2010-02-17 11:00:34 -0700 (Wed, 17 Feb 2010) | 4 lines


Updating baselines, which now used sorted output.


Added sorting option to the sorted() function.

........

r2364 | wehart | 2010-02-17 11:27:18 -0700 (Wed, 17 Feb 2010) | 2 lines


Bug fix when using glpk but not cplex.

........

r2365 | jwatson | 2010-02-17 11:38:59 -0700 (Wed, 17 Feb 2010) | 3 lines


More output sorting to ensure that tests pass!

........

Location:
coopr.pysp/stable/2.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/stable/2.3

  • coopr.pysp/stable/2.3/coopr/pysp/ph.py

    r2361 r2366  
    409409
    410410         # if you don't pre-solve, the name collections won't be updated.
    411          instance.presolve()
     411         instance.preprocess()
    412412
    413413   # create PH weight and xbar vectors, on a per-scenario basis, for each variable that is not in the
     
    10011001         # IMPT: I decided to presolve unconditionally, as PH extensions can add arbitrary components
    10021002         #       to the base scenario instances - and the variable values/etc. need to be collectged.
    1003          instance.presolve()
     1003         instance.preprocess()
    10041004           
    10051005         # there's nothing to warm-start from in iteration 0, so don't include the keyword in the solve call.
     
    13671367         # don't do this, you won't see any chance in the output files as you vary the problem parameters!
    13681368         # ditto for instance fixing!
    1369          instance.presolve()
     1369         instance.preprocess()
    13701370
    13711371         # once past iteration 0, there is always a feasible solution from which to warm-start.
  • coopr.pysp/stable/2.3/coopr/pysp/scenariotree.py

    r2361 r2366  
    501501      print "Tree Nodes:"
    502502      print ""
    503       for tree_node_name, tree_node in sorted(self._tree_node_map.iteritems()):
     503      for tree_node_name in sorted(self._tree_node_map.keys()):
     504         tree_node = self._tree_node_map[tree_node_name]
    504505         print "\tName=" + tree_node_name
    505506         if tree_node._stage is not None:
     
    517518         print "\tChildren:"
    518519         if len(tree_node._children) > 0:
    519             for child_node in sorted(tree_node._children):
     520            for child_node in sorted(tree_node._children, cmp=lambda x,y: cmp(x._name, y._name)):
    520521               print "\t\t" + child_node._name
    521522         else:
     
    525526            print "\t\tNone"
    526527         else:
    527             for scenario in tree_node._scenarios:
     528            for scenario in sorted(tree_node._scenarios, cmp=lambda x,y: cmp(x._name, y._name)):
    528529               print "\t\t" + scenario._name
    529530         print ""
    530531      print "----------------------------------------------------"
    531532      print "Stages:"
    532       for stage_name, stage in sorted(self._stage_map.iteritems()):
     533      for stage_name in sorted(self._stage_map.keys()):
     534         stage = self._stage_map[stage_name]
    533535         print "\tName=" + stage_name
    534536         print "\tTree Nodes: "
    535          for tree_node in stage._tree_nodes:
     537         for tree_node in sorted(stage._tree_nodes, cmp=lambda x,y: cmp(x._name, y._name)):
    536538            print "\t\t" + tree_node._name
    537539         print "\tVariables: "
     
    549551      print "----------------------------------------------------"
    550552      print "Scenarios:"
    551       for scenario_name, scenario in sorted(self._scenario_map.iteritems()):
     553      for scenario_name in sorted(self._scenario_map.keys()):
     554         scenario = self._scenario_map[scenario_name]
    552555         print "\tName=" + scenario_name
    553556         print "\tProbability=%4.4f" % scenario._probability
     
    580583      print "Tree Nodes:"
    581584      print ""
    582       for tree_node_name, tree_node in sorted(self._tree_node_map.iteritems()):
     585      for tree_node_name in sorted(self._tree_node_map.keys()):
     586         tree_node = self._tree_node_map[tree_node_name]
    583587         print "\tName=" + tree_node_name
    584588         if tree_node._stage is not None:
     
    596600         print "\tChildren:"
    597601         if len(tree_node._children) > 0:
    598             for child_node in sorted(tree_node._children):
     602            for child_node in sorted(tree_node._children, cmp=lambda x,y: cmp(x._name, y._name)):
    599603               print "\t\t" + child_node._name
    600604         else:
     
    604608            print "\t\tNone"
    605609         else:
    606             for scenario in tree_node._scenarios:
     610            for scenario in sorted(tree_node._scenarios, cmp=lambda x,y: cmp(x._name, y._name)):
    607611               print "\t\t" + scenario._name
    608612         print "\tExpected node cost=%10.4f" % tree_node.computeExpectedNodeCost(scenario_instance_map)
  • coopr.pysp/stable/2.3/coopr/pysp/tests/unit/farmer_linearized.baseline

    r2317 r2366  
    9797        Children:
    9898                AboveAverageNode
     99                AverageNode
    99100                BelowAverageNode
    100                 AverageNode
    101101        Scenarios:
    102102                BelowAverageScenario
     
    140140----------------------------------------------------
    141141
    142 Total PH execution time=    1.10 seconds
     142Total PH execution time=    2.69 seconds
    143143
  • coopr.pysp/stable/2.3/coopr/pysp/tests/unit/farmer_quadratic.baseline

    r2317 r2366  
    213213        Conditional probability=1.0000
    214214        Children:
    215                 BelowAverageNode
    216215                AboveAverageNode
    217216                AverageNode
     217                BelowAverageNode
    218218        Scenarios:
    219219                BelowAverageScenario
     
    257257----------------------------------------------------
    258258
    259 Total PH execution time=    6.31 seconds
    260 
     259Total PH execution time=    8.38 seconds
     260
  • coopr.pysp/stable/2.3/coopr/pysp/tests/unit/test_ph.py

    r2317 r2366  
    7979    def test_linearized_farmer(self):
    8080
    81         if cplex_available is False:
    82            return       
     81        if cplex_available:
     82            solver='cplex'
     83        elif glpk_available:
     84            solver='glpk'
     85        else:
     86           return
    8387
    8488        pyutilib.misc.setup_redirect(current_directory+"farmer_linearized.out")
     
    8690        model_dir = farmer_examples_dir + os.sep + "models"
    8791        instance_dir = farmer_examples_dir + os.sep + "scenariodata"       
    88         argstring = "runph --solver=cplex --solver-manager=serial --model-directory="+model_dir+" --instance-directory="+instance_dir+" --linearize-nonbinary-penalty-terms=10"
     92        argstring = "runph --solver="+solver+" --solver-manager=serial --model-directory="+model_dir+" --instance-directory="+instance_dir+" --linearize-nonbinary-penalty-terms=10"
    8993        args = string.split(argstring)
    9094        coopr.pysp.phinit.run(args=args)       
     
    116120        self.cleanup()       
    117121
    118     def run(self, result=None):
    119        global cplex_available
    120        if not cplex_available:
    121           return
    122        pyutilib.th.TestCase.run(self,result)
     122    #def run(self, result=None):
     123       #global cplex_available
     124       #if not cplex_available:
     125          #return
     126       #pyutilib.th.TestCase.run(self,result)
    123127
    124128if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.