Changeset 2990 for coopr.pysp/trunk/coopr/pysp/ef_writer_script.py
- Timestamp:
- Sep 4, 2010 1:28:07 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
coopr.pysp/trunk/coopr/pysp/ef_writer_script.py
r2986 r2990 29 29 from coopr.opt.parallel import SolverManagerFactory 30 30 31 from pyutilib.component.core import ExtensionPoint 32 from coopr.pysp.solutionwriter import ISolutionWriterExtension 33 31 34 # 32 35 # utility method to construct an option parser for ef writer arguments … … 105 108 type="float", 106 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 = []) 107 116 parser.add_option("--output-solver-log", 108 117 help="Output solver log during the extensive form solve.", … … 142 151 cvar_weight = options.cvar_weight 143 152 risk_alpha = options.risk_alpha 153 154 # validate the solution writer plugin exists, to avoid a lot of wasted work. 155 for solution_writer_name in options.solution_writer: 156 print "Trying to import solution writer="+solution_writer_name 157 __import__(solution_writer_name) 158 print "Module successfully loaded" 144 159 145 160 scenario_tree, binding_instance, scenario_instances = write_ef_from_scratch(os.path.expanduser(options.model_directory), … … 184 199 load_ef_solution(ef_results, binding_instance, scenario_instances) 185 200 scenario_tree.snapshotSolutionFromInstances(scenario_instances) 201 202 # handle output of solution from the scenario tree. 186 203 print "" 187 204 print "Extensive form solution:" … … 190 207 print "Extensive form costs:" 191 208 scenario_tree.pprintCosts(scenario_instances) 209 210 solution_writer_plugins = ExtensionPoint(ISolutionWriterExtension) 211 for plugin in solution_writer_plugins: 212 plugin.write(scenario_tree, "ef") 192 213 193 214 def run(args=None):
Note: See TracChangeset
for help on using the changeset viewer.