Changeset 1956


Ignore:
Timestamp:
Dec 2, 2009 7:56:53 PM (10 years ago)
Author:
jwatson
Message:

Added --scenario-solver-options and --ef-solver-options options to the "runph" script.

Location:
coopr.pysp/trunk/coopr/pysp
Files:
2 edited

Legend:

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

    r1934 r1956  
    594594      self._integer_tolerance = 0.00001
    595595
     596      # I only store these temporarily...
     597      scenario_solver_options = None
     598
    596599      # process the keyword options
    597600      for key in kwds.keys():
     
    607610            self._solver_type = kwds[key]
    608611         elif key == "solver_manager":
    609             self._solver_manager_type = kwds[key]           
     612            self._solver_manager_type = kwds[key]
     613         elif key == "scenario_solver_options":
     614            scenario_solver_options = kwds[key]
    610615         elif key == "keep_solver_files":
    611616            self._keep_solver_files = kwds[key]
     
    669674      if self._keep_solver_files is True:
    670675         self._solver.keepFiles = True
     676      if len(scenario_solver_options) > 0:
     677         if self._verbose is True:
     678            print "Initializing scenario sub-problem solver with options="+str(scenario_solver_options)
     679         self._solver.set_options("".join(scenario_solver_options))
    671680
    672681      # construct the solver manager.
  • coopr.pysp/trunk/coopr/pysp/ph_script.py

    r1934 r1956  
    7070                  type="string",
    7171                  default="serial")
     72parser.add_option("--scenario-solver-options",
     73                  help="Solver options for all PH scenario sub-problems",
     74                  action="append",
     75                  dest="scenario_solver_options",
     76                  type="string",
     77                  default=[])
     78parser.add_option("--ef-solver-options",
     79                  help="Solver options for the extension form problem",
     80                  action="append",
     81                  dest="ef_solver_options",
     82                  type="string",
     83                  default=[])
    7284parser.add_option("--max-iterations",
    7385                  help="The maximal number of PH iterations. Default is 100.",
     
    452464                              solver=options.solver_type, \
    453465                              solver_manager=options.solver_manager_type, \
     466                              scenario_solver_options=options.scenario_solver_options, \
    454467                              keep_solver_files=options.keep_solver_files, \
    455468                              output_solver_log=options.output_solver_logs, \
     
    513526      if ef_solver is None:
    514527         raise ValueError, "Failed to create solver of type="+options.solver_type+" for use in extensive form solve"
     528      if len(options.ef_solver_options) > 0:
     529         print "Initializing ef solver with options="+str(options.ef_solver_options)         
     530         ef_solver.set_options("".join(options.ef_solver_options))
    515531
    516532      ef_solver_manager = SolverManagerFactory(options.solver_manager_type)
     
    523539      ef_results = ef_solver_manager.wait_for(ef_action_handle)
    524540      print "Extensive form solve results:"
    525       print ef_results
    526      
     541      ef_results.write(num=1)
    527542
    528543def run(args=None):
Note: See TracChangeset for help on using the changeset viewer.