Ignore:
Timestamp:
Nov 29, 2010 5:26:46 PM (10 years ago)
Author:
jwatson
Message:

Adding two options to the runef and runph pysp scripts, to facilitate scenario downsampling - the case where you have a big tree, but you don't want to use it all.

The options are:
--scenario-tree-downsample-fraction=X
--scenario-tree-random-seed

The options are fairly self-explanatory - the only possible nuance is that the downsample fraction is the fraction of scenarios retained.

File:
1 edited

Legend:

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

    r3168 r3261  
    5151   parser.usage = usage_string
    5252
    53    inputOpts       = OptionGroup( parser, 'Input Options' )
    54    phOpts          = OptionGroup( parser, 'PH Options' )
    55    solverOpts      = OptionGroup( parser, 'Solver Options' )
    56    postprocessOpts = OptionGroup( parser, 'Postprocessing Options' )   
    57    outputOpts      = OptionGroup( parser, 'Output Options' )
    58    otherOpts       = OptionGroup( parser, 'Other Options' )
     53   # NOTE: these groups should eventually be queried from the PH, scenario tree, etc. classes (to facilitate re-use).
     54   inputOpts        = OptionGroup( parser, 'Input Options' )
     55   scenarioTreeOpts = OptionGroup( parser, 'Scenario Tree Options' )
     56   phOpts           = OptionGroup( parser, 'PH Options' )
     57   solverOpts       = OptionGroup( parser, 'Solver Options' )
     58   postprocessOpts  = OptionGroup( parser, 'Postprocessing Options' )   
     59   outputOpts       = OptionGroup( parser, 'Output Options' )
     60   otherOpts        = OptionGroup( parser, 'Other Options' )
    5961   parser.add_option_group( inputOpts )
     62   parser.add_option_group( scenarioTreeOpts )
    6063   parser.add_option_group( phOpts )
    6164   parser.add_option_group( solverOpts )
     
    8184     dest="bounds_cfgfile",
    8285     default=None)
     86
     87   scenarioTreeOpts.add_option('--scenario-tree-seed',
     88     help="The random seed associated with manipulation operations on the scenario tree (e.g., down-sampling). Default is 0, indicating unassigned.",
     89     action="store",
     90     dest="scenario_tree_random_seed",
     91     type="int",
     92     default=None)
     93   scenarioTreeOpts.add_option('--scenario-tree-downsample-fraction',
     94     help="The proportion of the scenarios in the scenario tree that are actually used. Specific scenarios are selected at random. Default is 1.0, indicating no down-sampling.",
     95     action="store",
     96     dest="scenario_tree_downsample_fraction",
     97     type="float",
     98     default=1.0)   
    8399
    84100   phOpts.add_option('-r','--default-rho',
     
    412428   scenario_tree = ScenarioTree(scenarioinstance=reference_instance,
    413429                                scenariotreeinstance=scenario_tree_instance)
     430
     431   #
     432   # compress/down-sample the scenario tree, if operation is required.
     433   #
     434   if options.scenario_tree_downsample_fraction < 1.0:
     435       
     436      scenario_tree.downsample(options.scenario_tree_downsample_fraction, options.scenario_tree_random_seed, options.verbose)
    414437
    415438   return reference_model, reference_instance, scenario_tree, scenario_tree_instance
Note: See TracChangeset for help on using the changeset viewer.