Changeset 3101
- Timestamp:
- Oct 14, 2010 5:06:40 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
coopr.pysp/trunk/coopr/pysp/ef_writer_script.py
r3100 r3101 12 12 import sys 13 13 import os 14 from optparse import OptionParser 14 from optparse import OptionParser, OptionGroup 15 15 16 16 import pyutilib.services … … 39 39 40 40 parser = OptionParser() 41 parser.add_option("--verbose",42 help="Generate verbose output, beyond the usual status output. Default is False.",43 action="store_true",44 dest="verbose",45 default=False)46 parser.add_option("--model-directory",47 help="The directory in which all model (reference and scenario) definitions are stored. Default is \".\".",48 action="store",49 dest="model_directory",50 type="string",51 default=".")52 parser.add_option("--instance-directory",53 help="The directory in which all instance (reference and scenario) definitions are stored. Default is \".\".",54 action="store",55 dest="instance_directory",56 type="string",57 default=".")58 parser.add_option("--generate-weighted-cvar",59 help="Add a weighted CVaR term to the primary objective",60 action="store_true",61 dest="generate_weighted_cvar",62 default=False)63 parser.add_option("--cvar-weight",64 help="The weight associated with the CVaR term in the risk-weighted objective formulation. Default is 1.0. If the weight is 0, then *only* a non-weighted CVaR cost will appear in the EF objective - the expected cost component will be dropped.",65 action="store",66 dest="cvar_weight",67 type="float",68 default=1.0)69 parser.add_option("--risk-alpha",70 help="The probability threshold associated with cvar (or any future) risk-oriented performance metrics. Default is 0.95.",71 action="store",72 dest="risk_alpha",73 type="float",74 default=0.95)75 parser.add_option("--output-file",76 help="Specify the name of the extensive form output file",77 action="store",78 dest="output_file",79 type="string",80 default="efout.lp")81 parser.add_option("--solve",82 help="Following write of the extensive form model, solve it.",83 action="store_true",84 dest="solve_ef",85 default=False)86 parser.add_option("--solver",87 help="The type of solver used to solve scenario sub-problems. Default is cplex.",88 action="store",89 dest="solver_type",90 type="string",91 default="cplex")92 parser.add_option("--solver-manager",93 help="The type of solver manager used to coordinate scenario sub-problem solves. Default is serial.",94 action="store",95 dest="solver_manager_type",96 type="string",97 default="serial")98 parser.add_option("--solver-options",99 help="Solver options for the extension form problem.",100 action="append",101 dest="solver_options",102 type="string",103 default=[])104 parser.add_option("--mipgap",105 help="Specifies the mipgap for the EF solve.",106 action="store",107 dest="mipgap",108 type="float",109 default=None)110 parser.add_option("--solution-writer",111 help="The plugin invoked to write the scenario tree solution. Defaults to the empty list.",112 action="append",113 dest="solution_writer",114 type="string",115 default = [])116 parser.add_option("--output-solver-log",117 help="Output solver log during the extensive form solve.",118 action="store_true",119 dest="output_solver_log",120 default=False)121 parser.add_option("--keep-solver-files",122 help="Retain temporary input and output files for solve.",123 action="store_true",124 dest="keep_solver_files",125 default=False)126 parser.add_option("--profile",127 help="Enable profiling of Python code. The value of this option is the number of functions that are summarized.",128 action="store",129 dest="profile",130 default=0)131 parser.add_option("--disable-gc",132 help="Disable the python garbage collecter. Default is False.",133 action="store_true",134 dest="disable_gc",135 default=False)136 parser.add_option('--traceback',137 help="When an exception is thrown, show the entire call stack. Ignored if profiling is enabled. Default is False.",138 action="store_true",139 dest="traceback",140 default=False)141 41 parser.usage=usage_string 142 42 43 inputOpts = OptionGroup( parser, 'Input Options' ) 44 efOpts = OptionGroup( parser, 'EF Options' ) 45 solverOpts = OptionGroup( parser, 'Solver Options' ) 46 outputOpts = OptionGroup( parser, 'Output Options' ) 47 otherOpts = OptionGroup( parser, 'Other Options' ) 48 parser.add_option_group( inputOpts ) 49 parser.add_option_group( efOpts ) 50 parser.add_option_group( solverOpts ) 51 parser.add_option_group( outputOpts ) 52 parser.add_option_group( otherOpts ) 53 54 inputOpts.add_option('--instance-directory', 55 help='The directory in which all instance (reference and scenario) definitions are stored. Default is ".".', 56 action='store', 57 dest='instance_directory', 58 type='string', 59 default='.') 60 inputOpts.add_option('--model-directory', 61 help='The directory in which all model (reference and scenario) definitions are stored. Default is ".".', 62 action='store', 63 dest='model_directory', 64 type='string', 65 default='.') 66 67 efOpts.add_option('--cvar-weight', 68 help='The weight associated with the CVaR term in the risk-weighted objective formulation. Default is 1.0. If the weight is 0, then *only* a non-weighted CVaR cost will appear in the EF objective - the expected cost component will be dropped.', 69 action='store', 70 dest='cvar_weight', 71 type='float', 72 default=1.0) 73 efOpts.add_option('--generate-weighted-cvar', 74 help='Add a weighted CVaR term to the primary objective', 75 action='store_true', 76 dest='generate_weighted_cvar', 77 default=False) 78 efOpts.add_option('--risk-alpha', 79 help='The probability threshold associated with cvar (or any future) risk-oriented performance metrics. Default is 0.95.', 80 action='store', 81 dest='risk_alpha', 82 type='float', 83 default=0.95) 84 85 solverOpts.add_option('--mipgap', 86 help='Specifies the mipgap for the EF solve.', 87 action='store', 88 dest='mipgap', 89 type='float', 90 default=None) 91 solverOpts.add_option('--solve', 92 help='Following write of the extensive form model, solve it.', 93 action='store_true', 94 dest='solve_ef', 95 default=False) 96 solverOpts.add_option('--solver', 97 help='The type of solver used to solve scenario sub-problems. Default is cplex.', 98 action='store', 99 dest='solver_type', 100 type='string', 101 default='cplex') 102 solverOpts.add_option('--solver-manager', 103 help='The type of solver manager used to coordinate scenario sub-problem solves. Default is serial.', 104 action='store', 105 dest='solver_manager_type', 106 type='string', 107 default='serial') 108 solverOpts.add_option('--solver-options', 109 help='Solver options for the extension form problem.', 110 action='append', 111 dest='solver_options', 112 type='string', 113 default=[]) 114 115 outputOpts.add_option('--output-file', 116 help='Specify the name of the extensive form output file', 117 action='store', 118 dest='output_file', 119 type='string', 120 default='efout.lp') 121 outputOpts.add_option('--output-solver-log', 122 help='Output solver log during the extensive form solve.', 123 action='store_true', 124 dest='output_solver_log', 125 default=False) 126 outputOpts.add_option('--solution-writer', 127 help='The plugin invoked to write the scenario tree solution. Defaults to the empty list.', 128 action='append', 129 dest='solution_writer', 130 type='string', 131 default = []) 132 outputOpts.add_option('--verbose', 133 help='Generate verbose output, beyond the usual status output. Default is False.', 134 action='store_true', 135 dest='verbose', 136 default=False) 137 138 otherOpts.add_option('--disable-gc', 139 help='Disable the python garbage collecter. Default is False.', 140 action='store_true', 141 dest='disable_gc', 142 default=False) 143 otherOpts.add_option('--keep-solver-files', 144 help='Retain temporary input and output files for solve.', 145 action='store_true', 146 dest='keep_solver_files', 147 default=False) 148 otherOpts.add_option('--profile', 149 help='Enable profiling of Python code. The value of this option is the number of functions that are summarized.', 150 action='store', 151 dest='profile', 152 default=0) 153 otherOpts.add_option('--traceback', 154 help='When an exception is thrown, show the entire call stack. Ignored if profiling is enabled. Default is False.', 155 action='store_true', 156 dest='traceback', 157 default=False) 158 143 159 return parser 160 144 161 145 162 def run_ef_writer(options, args):
Note: See TracChangeset
for help on using the changeset viewer.