Changeset 2402


Ignore:
Timestamp:
Feb 25, 2010 11:33:25 AM (10 years ago)
Author:
jwatson
Message:

Added --all-scenarios option to PH solver server

File:
1 edited

Legend:

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

    r2401 r2402  
    132132                     dest="scenarios",
    133133                     default=[])
     134   parser.add_option("--all-scenarios",
     135                     help="Indicate that the server is responsible for solving all scenarios",
     136                     action="store_true",
     137                     dest="all_scenarios",
     138                     default=False)
    134139   parser.add_option("--report-solutions",
    135140                     help="Always report PH solutions after each iteration. Enabled if --verbose is enabled. Default is False.",
     
    321326def exec_server(options):
    322327
    323    # we need the base model (not so much the reference instance, but that -
    324    # can't hurt too much until proven otherwise, that is) to construct
     328   # we need the base model (not so much the reference instance, but that
     329   # can't hurt too much - until proven otherwise, that is) to construct
    325330   # the scenarios that this server is responsible for.
    326331   reference_model, reference_instance, scenario_tree, scenario_tree_instance = load_reference_and_scenario_models(options)
     
    331336   # construct the set of scenario instances based on the command-line.
    332337   scenario_instances = {}
    333    if len(options.scenarios) == 0:
    334       print "***Unable to launch PH solver server - no scenario specified!"
     338   if (options.all_scenarios is True) and (len(options.scenarios) > 0):
     339      print "***WARNING: Both individual scenarios and all-scenarios were specified on the command-line; proceeding using all scenarios"
     340
     341   if (len(options.scenarios) == 0) and (options.all_scenarios is False):
     342      print "***Unable to launch PH solver server - no scenario(s) specified!"
    335343      return
    336344
    337    for scenario_name in options.scenarios:
     345   scenarios_to_construct = []
     346   if options.all_scenarios is True:
     347      scenarios_to_construct.extend(scenario_tree._scenario_map.keys())
     348   else:
     349      scenarios_to_construct.extend(options.scenarios)
     350
     351   for scenario_name in scenarios_to_construct:
    338352      print "Creating instance for scenario="+scenario_name
    339353      if scenario_tree.contains_scenario(scenario_name) is False:
Note: See TracChangeset for help on using the changeset viewer.