Changeset 3065


Ignore:
Timestamp:
Oct 1, 2010 3:46:57 PM (11 years ago)
Author:
jwatson
Message:

Reworked some of the options groups in the runph script, and created some new aliases.

File:
1 edited

Legend:

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

    r3055 r3065  
    5151   parser.usage = usage_string
    5252
    53    inputOpts  = OptionGroup( parser, 'Input Options' )
    54    solverOpts = OptionGroup( parser, 'Solver Options' )
    55    outputOpts = OptionGroup( parser, 'Output Options' )
    56    otherOpts  = OptionGroup( parser, 'Other Opts' )
     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' )
    5759   parser.add_option_group( inputOpts )
     60   parser.add_option_group( phOpts )
    5861   parser.add_option_group( solverOpts )
     62   parser.add_option_group( postprocessOpts )   
    5963   parser.add_option_group( outputOpts )
    6064   parser.add_option_group( otherOpts )
    6165
     66   inputOpts.add_option('-m','--model-directory',
     67     help="The directory in which all model (reference and scenario) definitions are stored. Default is \".\".",
     68     action="store",
     69     dest="model_directory",
     70     type="string",
     71     default=".")
     72   inputOpts.add_option('-i','--instance-directory',
     73     help="The directory in which all instance (reference and scenario) definitions are stored. Default is '.'.",
     74     action="store",
     75     dest="instance_directory",
     76     type="string",
     77     default=".")
    6278   inputOpts.add_option('--bounds-cfgfile',
    6379     help="The name of a configuration script to set variable bound values. Default is None.",
     
    6581     dest="bounds_cfgfile",
    6682     default=None)
    67    inputOpts.add_option('-m','--model-directory',
    68      help="The directory in which all model (reference and scenario) definitions are stored. Default is \".\".",
    69      action="store",
    70      dest="model_directory",
    71      type="string",
    72      default=".")
    73    inputOpts.add_option('--rho-cfgfile',
    74      help="The name of a configuration script to compute PH rho values. Default is None.",
    75      action="store",
    76      dest="rho_cfgfile",
    77      type="string",
    78      default=None)
    79    inputOpts.add_option('--ww-extension-cfgfile',
    80      help="The name of a configuration file for the Watson-Woodruff PH extensions plugin. Default is wwph.cfg.",
    81      action="store",
    82      dest="ww_extension_cfgfile",
    83      type="string",
    84      default="")
    85    inputOpts.add_option('--ww-extension-suffixfile',
    86      help="The name of a variable suffix file for the Watson-Woodruff PH extensions plugin. Default is wwph.suffixes.",
    87      action="store",
    88      dest="ww_extension_suffixfile",
    89      type="string",
    90      default="")
    91    inputOpts.add_option('-i','--instance-directory',
    92      help="The directory in which all instance (reference and scenario) definitions are stored. Default is '.'.",
    93      action="store",
    94      dest="instance_directory",
    95      type="string",
    96      default=".")
    97    otherOpts.add_option('--disable-gc',
    98      help="Disable the python garbage collecter. Default is False.",
    99      action="store_true",
    100      dest="disable_gc",
    101      default=False)
    102    otherOpts.add_option('--keep-solver-files',
    103      help="Retain temporary input and output files for scenario sub-problem solves",
    104      action="store_true",
    105      dest="keep_solver_files",
    106      default=False)
    107    otherOpts.add_option('--profile',
    108      help="Enable profiling of Python code.  The value of this option is the number of functions that are summarized.",
    109      action="store",
    110      dest="profile",
    111      type="int",
    112      default=0)
    113    outputOpts.add_option('--ef-output-file',
    114      help="The name of the extensive form output file (currently only LP format is supported), if writing of the extensive form is enabled. Default is efout.lp.",
    115      action="store",
    116      dest="ef_output_file",
    117      type="string",
    118      default="efout.lp")
    119    outputOpts.add_option('--output-ef-solver-log',
    120      help="Output solver log during the extensive form solve",
    121      action="store_true",
    122      dest="output_ef_solver_log",
    123      default=False)
    124    outputOpts.add_option('--output-scenario-tree-solution',
    125      help="Report the full solution (even leaves) in scenario tree format upon termination. Values represent averages, so convergence is not an issue. Default is False.",
    126      action="store_true",
    127      dest="output_scenario_tree_solution",
    128      default=False)
    129    outputOpts.add_option('--output-solver-logs',
    130      help="Output solver logs during scenario sub-problem solves",
    131      action="store_true",
    132      dest="output_solver_logs",
    133      default=False)
    134    outputOpts.add_option('--output-solver-results',
    135      help="Output solutions obtained after each scenario sub-problem solve",
    136      action="store_true",
    137      dest="output_solver_results",
    138      default=False)
    139    outputOpts.add_option('--output-times',
    140      help="Output timing statistics for various PH components",
    141      action="store_true",
    142      dest="output_times",
    143      default=False)
    144    outputOpts.add_option('--report-only-statistics',
    145      help="When reporting solutions (if enabled), only output per-variable statistics - not the individual scenario values. Default is False.",
    146      action="store_true",
    147      dest="report_only_statistics",
    148      default=False)
    149    outputOpts.add_option('--report-solutions',
    150      help="Always report PH solutions after each iteration. Enabled if --verbose is enabled. Default is False.",
    151      action="store_true",
    152      dest="report_solutions",
    153      default=False)
    154    outputOpts.add_option('--report-weights',
    155      help="Always report PH weights prior to each iteration. Enabled if --verbose is enabled. Default is False.",
    156      action="store_true",
    157      dest="report_weights",
    158      default=False)
    159    outputOpts.add_option('--restore-from-checkpoint',
    160      help="The name of the checkpoint file from which PH should be initialized. Default is \"\", indicating no checkpoint restoration",
    161      action="store",
    162      dest="restore_from_checkpoint",
    163      type="string",
    164      default="")
    165    outputOpts.add_option('--solution-writer',
    166      help="The plugin invoked to write the scenario tree solution. Defaults to the empty list.",
    167      action="append",
    168      dest="solution_writer",
    169      type="string",
    170      default = [])
    171    outputOpts.add_option('--suppress-continuous-variable-output',
    172      help="Eliminate PH-related output involving continuous variables.",
    173      action="store_true",
    174      dest="suppress_continuous_variable_output",
    175      default=False)
    176    outputOpts.add_option('--verbose',
    177      help="Generate verbose output for both initialization and execution. Default is False.",
    178      action="store_true",
    179      dest="verbose",
    180      default=False)
    181    outputOpts.add_option('--write-ef',
    182      help="Upon termination, write the extensive form of the model - accounting for all fixed variables.",
    183      action="store_true",
    184      dest="write_ef",
    185      default=False)
    186    solverOpts.add_option('--breakpoint-strategy',
    187      help="Specify the strategy to distribute breakpoints on the [lb, ub] interval of each variable when linearizing. 0 indicates uniform distribution. 1 indicates breakpoints at the node min and max, uniformly in-between. 2 indicates more aggressive concentration of breakpoints near the observed node min/max.",
    188      action="store",
    189      dest="breakpoint_strategy",
    190      type="int",
    191      default=0)
    192    solverOpts.add_option('--checkpoint-interval',
    193      help="The number of iterations between writing of a checkpoint file. Default is 0, indicating never.",
    194      action="store",
    195      dest="checkpoint_interval",
    196      type="int",
    197      default=0)
    198    solverOpts.add_option('--default-rho',
     83
     84   phOpts.add_option('-r','--default-rho',
    19985     help="The default (global) rho for all blended variables. Default is 1.",
    20086     action="store",
     
    20288     type="float",
    20389     default=1.0)
    204    solverOpts.add_option('--disable-warmstarts',
    205      help="Disable warm-start of scenario sub-problem solves in PH iterations >= 1. Default is False.",
    206      action="store_true",
    207      dest="disable_warmstarts",
    208      default=False)
    209    solverOpts.add_option('--drop-proximal-terms',
    210      help="Eliminate proximal terms (i.e., the quadratic penalty terms) from the weighted PH objective. Default is False.",
    211      action="store_true",
    212      dest="drop_proximal_terms",
    213      default=False)
    214    solverOpts.add_option('--ef-mipgap',
    215      help="Specifies the mipgap for the EF solve",
    216      action="store",
    217      dest="ef_mipgap",
     90   phOpts.add_option('--rho-cfgfile',
     91     help="The name of a configuration script to compute PH rho values. Default is None.",
     92     action="store",
     93     dest="rho_cfgfile",
     94     type="string",
     95     default=None)
     96   phOpts.add_option('--max-iterations',
     97     help="The maximal number of PH iterations. Default is 100.",
     98     action="store",
     99     dest="max_iterations",
     100     type="int",
     101     default=100)
     102   phOpts.add_option('--termdiff-threshold',
     103     help="The convergence threshold used in the term-diff and normalized term-diff convergence criteria. Default is 0.01.",
     104     action="store",
     105     dest="termdiff_threshold",
    218106     type="float",
    219      default=None)
    220    solverOpts.add_option('--ef-solver-options',
    221      help="Solver options for the extension form problem",
    222      action="append",
    223      dest="ef_solver_options",
    224      type="string",
    225      default=[])
    226    solverOpts.add_option('--enable-free-discrete-count-convergence',
     107     default=0.01)
     108   phOpts.add_option('--enable-free-discrete-count-convergence',
    227109     help="Terminate PH based on the free discrete variable count convergence metric. Default is False.",
    228110     action="store_true",
    229111     dest="enable_free_discrete_count_convergence",
    230112     default=False)
    231    solverOpts.add_option('--enable-normalized-termdiff-convergence',
     113   phOpts.add_option('--enable-normalized-termdiff-convergence',
    232114     help="Terminate PH based on the normalized termdiff convergence metric. Default is True.",
    233115     action="store_true",
    234116     dest="enable_normalized_termdiff_convergence",
    235117     default=False)
    236    solverOpts.add_option('--enable-termdiff-convergence',
     118   phOpts.add_option('--enable-termdiff-convergence',
    237119     help="Terminate PH based on the termdiff convergence metric. Default is True.",
    238120     action="store_true",
    239121     dest="enable_termdiff_convergence",
    240122     default=True)
    241    solverOpts.add_option('--enable-ww-extensions',
    242      help="Enable the Watson-Woodruff PH extensions plugin. Default is False.",
    243      action="store_true",
    244      dest="enable_ww_extensions",
    245      default=False)
    246    solverOpts.add_option('--free-discrete-count-threshold',
     123   phOpts.add_option('--free-discrete-count-threshold',
    247124     help="The convergence threshold used in the criterion based on when the free discrete variable count convergence criterion. Default is 20.",
    248125     action="store",
     
    250127     type="float",
    251128     default=20)
    252    solverOpts.add_option('--linearize-nonbinary-penalty-terms',
     129   phOpts.add_option('--linearize-nonbinary-penalty-terms',
    253130     help="Approximate the PH quadratic term for non-binary variables with a piece-wise linear function, using the supplied number of equal-length pieces from each bound to the average",
    254131     action="store",
     
    256133     type="int",
    257134     default=0)
    258    solverOpts.add_option('--max-iterations',
    259      help="The maximal number of PH iterations. Default is 100.",
    260      action="store",
    261      dest="max_iterations",
     135   phOpts.add_option('--breakpoint-strategy',
     136     help="Specify the strategy to distribute breakpoints on the [lb, ub] interval of each variable when linearizing. 0 indicates uniform distribution. 1 indicates breakpoints at the node min and max, uniformly in-between. 2 indicates more aggressive concentration of breakpoints near the observed node min/max.",
     137     action="store",
     138     dest="breakpoint_strategy",
    262139     type="int",
    263      default=100)
    264    solverOpts.add_option('--retain-quadratic-binary-terms',
     140     default=0)   
     141   phOpts.add_option('--retain-quadratic-binary-terms',
    265142     help="Do not linearize PH objective terms involving binary decision variables",
    266143     action="store_true",
    267144     dest="retain_quadratic_binary_terms",
    268145     default=False)
     146   phOpts.add_option('--drop-proximal-terms',
     147     help="Eliminate proximal terms (i.e., the quadratic penalty terms) from the weighted PH objective. Default is False.",
     148     action="store_true",
     149     dest="drop_proximal_terms",
     150     default=False)
     151   phOpts.add_option('--enable-ww-extensions',
     152     help="Enable the Watson-Woodruff PH extensions plugin. Default is False.",
     153     action="store_true",
     154     dest="enable_ww_extensions",
     155     default=False)
     156   phOpts.add_option('--ww-extension-cfgfile',
     157     help="The name of a configuration file for the Watson-Woodruff PH extensions plugin. Default is wwph.cfg.",
     158     action="store",
     159     dest="ww_extension_cfgfile",
     160     type="string",
     161     default="")
     162   phOpts.add_option('--ww-extension-suffixfile',
     163     help="The name of a variable suffix file for the Watson-Woodruff PH extensions plugin. Default is wwph.suffixes.",
     164     action="store",
     165     dest="ww_extension_suffixfile",
     166     type="string",
     167     default="")
     168   phOpts.add_option('--user-defined-extension',
     169     help="The name of a python module specifying a user-defined PH extension plugin.",
     170     action="store",
     171     dest="user_defined_extension",
     172     type="string",
     173     default=None)
     174   
    269175   solverOpts.add_option('--scenario-mipgap',
    270176     help="Specifies the mipgap for all PH scenario sub-problems",
     
    279185     type="string",
    280186     default=[])
    281    solverOpts.add_option('--solve-ef',
    282      help="Following write of the extensive form model, solve it.",
    283      action="store_true",
    284      dest="solve_ef",
    285      default=False)
    286187   solverOpts.add_option('--solver',
    287188     help="The type of solver used to solve scenario sub-problems. Default is cplex.",
     
    296197     type="string",
    297198     default="serial")
    298    solverOpts.add_option('--termdiff-threshold',
    299      help="The convergence threshold used in the term-diff and normalized term-diff convergence criteria. Default is 0.01.",
    300      action="store",
    301      dest="termdiff_threshold",
     199   solverOpts.add_option('--disable-warmstarts',
     200     help="Disable warm-start of scenario sub-problem solves in PH iterations >= 1. Default is False.",
     201     action="store_true",
     202     dest="disable_warmstarts",
     203     default=False)
     204
     205   postprocessOpts.add_option('--ef-output-file',
     206     help="The name of the extensive form output file (currently only LP format is supported), if writing of the extensive form is enabled. Default is efout.lp.",
     207     action="store",
     208     dest="ef_output_file",
     209     type="string",
     210     default="efout.lp")
     211   postprocessOpts.add_option('--solve-ef',
     212     help="Following write of the extensive form model, solve it.",
     213     action="store_true",
     214     dest="solve_ef",
     215     default=False)
     216   postprocessOpts.add_option('--ef-mipgap',
     217     help="Specifies the mipgap for the EF solve",
     218     action="store",
     219     dest="ef_mipgap",
    302220     type="float",
    303      default=0.01)
    304    solverOpts.add_option('--user-defined-extension',
    305      help="The name of a python module specifying a user-defined PH extension plugin.",
    306      action="store",
    307      dest="user_defined_extension",
    308      type="string",
    309221     default=None)
     222   postprocessOpts.add_option('--ef-solver-options',
     223     help="Solver options for the extension form problem",
     224     action="append",
     225     dest="ef_solver_options",
     226     type="string",
     227     default=[])   
     228   postprocessOpts.add_option('--output-ef-solver-log',
     229     help="Output solver log during the extensive form solve",
     230     action="store_true",
     231     dest="output_ef_solver_log",
     232     default=False)
     233
     234   
     235   outputOpts.add_option('--output-scenario-tree-solution',
     236     help="Report the full solution (even leaves) in scenario tree format upon termination. Values represent averages, so convergence is not an issue. Default is False.",
     237     action="store_true",
     238     dest="output_scenario_tree_solution",
     239     default=False)
     240   outputOpts.add_option('--output-solver-logs',
     241     help="Output solver logs during scenario sub-problem solves",
     242     action="store_true",
     243     dest="output_solver_logs",
     244     default=False)
     245   outputOpts.add_option('--output-solver-results',
     246     help="Output solutions obtained after each scenario sub-problem solve",
     247     action="store_true",
     248     dest="output_solver_results",
     249     default=False)
     250   outputOpts.add_option('--output-times',
     251     help="Output timing statistics for various PH components",
     252     action="store_true",
     253     dest="output_times",
     254     default=False)
     255   outputOpts.add_option('--report-only-statistics',
     256     help="When reporting solutions (if enabled), only output per-variable statistics - not the individual scenario values. Default is False.",
     257     action="store_true",
     258     dest="report_only_statistics",
     259     default=False)
     260   outputOpts.add_option('--report-solutions',
     261     help="Always report PH solutions after each iteration. Enabled if --verbose is enabled. Default is False.",
     262     action="store_true",
     263     dest="report_solutions",
     264     default=False)
     265   outputOpts.add_option('--report-weights',
     266     help="Always report PH weights prior to each iteration. Enabled if --verbose is enabled. Default is False.",
     267     action="store_true",
     268     dest="report_weights",
     269     default=False)
     270   outputOpts.add_option('--restore-from-checkpoint',
     271     help="The name of the checkpoint file from which PH should be initialized. Default is \"\", indicating no checkpoint restoration",
     272     action="store",
     273     dest="restore_from_checkpoint",
     274     type="string",
     275     default="")
     276   outputOpts.add_option('--solution-writer',
     277     help="The plugin invoked to write the scenario tree solution. Defaults to the empty list.",
     278     action="append",
     279     dest="solution_writer",
     280     type="string",
     281     default = [])
     282   outputOpts.add_option('--suppress-continuous-variable-output',
     283     help="Eliminate PH-related output involving continuous variables.",
     284     action="store_true",
     285     dest="suppress_continuous_variable_output",
     286     default=False)
     287   outputOpts.add_option('--verbose',
     288     help="Generate verbose output for both initialization and execution. Default is False.",
     289     action="store_true",
     290     dest="verbose",
     291     default=False)
     292   outputOpts.add_option('--write-ef',
     293     help="Upon termination, write the extensive form of the model - accounting for all fixed variables.",
     294     action="store_true",
     295     dest="write_ef",
     296     default=False)
     297
     298
     299   otherOpts.add_option('--disable-gc',
     300     help="Disable the python garbage collecter. Default is False.",
     301     action="store_true",
     302     dest="disable_gc",
     303     default=False)
     304   otherOpts.add_option('--keep-solver-files',
     305     help="Retain temporary input and output files for scenario sub-problem solves",
     306     action="store_true",
     307     dest="keep_solver_files",
     308     default=False)
     309   otherOpts.add_option('--profile',
     310     help="Enable profiling of Python code.  The value of this option is the number of functions that are summarized.",
     311     action="store",
     312     dest="profile",
     313     type="int",
     314     default=0)
     315   otherOpts.add_option('--checkpoint-interval',
     316     help="The number of iterations between writing of a checkpoint file. Default is 0, indicating never.",
     317     action="store",
     318     dest="checkpoint_interval",
     319     type="int",
     320     default=0)
     321   
     322
     323   
    310324
    311325   return parser
Note: See TracChangeset for help on using the changeset viewer.