def main(): args = _parse_args() num_scen = args.num_scens crops_mult = args.crops_mult with_fwph = args.with_fwph with_xhatlshaped = args.with_xhatlshaped scenario_creator = farmer.scenario_creator scenario_denouement = farmer.scenario_denouement all_scenario_names = [f"scen{sn}" for sn in range(num_scen)] scenario_creator_kwargs = { "use_integer": False, "crops_multiplier": crops_mult, } # Things needed for vanilla cylinders beans = (args, scenario_creator, scenario_denouement, all_scenario_names) # Options for the L-shaped method at the hub # Bounds only valid for 3 scenarios, I think? Need to ask Chris spo = None if args.max_solver_threads is None else {"threads": args.max_solver_threads} options = { "master_solver": args.solver_name, "sp_solver": args.solver_name, "sp_solver_options" : spo, #"valid_eta_lb": {i: -432000 for i in all_scenario_names}, "max_iter": args.max_iterations, "verbose": False, "master_scenarios":[all_scenario_names[len(all_scenario_names)//2]] } # L-shaped hub hub_dict = { "hub_class": LShapedHub, "hub_kwargs": { "options": { "rel_gap": args.rel_gap, "abs_gap": args.abs_gap, }, }, "opt_class": LShapedMethod, "opt_kwargs": { # Args passed to LShapedMethod __init__ "options": options, "all_scenario_names": all_scenario_names, "scenario_creator": scenario_creator, "scenario_creator_kwargs": scenario_creator_kwargs, }, } # FWPH spoke if with_fwph: fw_spoke = vanilla.fwph_spoke(*beans, scenario_creator_kwargs=scenario_creator_kwargs) # xhat looper bound spoke -- any scenario will do for # lshaped (they're all the same) xhat_scenario_dict = {"ROOT": all_scenario_names[0]} if with_xhatlshaped: xhatlshaped_spoke = vanilla.xhatlshaped_spoke(*beans, scenario_creator_kwargs=scenario_creator_kwargs) list_of_spoke_dict = list() if with_fwph: list_of_spoke_dict.append(fw_spoke) if with_xhatlshaped: list_of_spoke_dict.append(xhatlshaped_spoke) spin_the_wheel(hub_dict, list_of_spoke_dict)
def main(): args = _parse_args() num_scen = args.num_scens with_fwph = args.with_fwph with_xhatlshaped = args.with_xhatlshaped scenario_creator = uc.scenario_creator scenario_denouement = uc.scenario_denouement scenario_creator_kwargs = {"path": f"./{num_scen}scenarios_r1/"} all_scenario_names = [f"Scenario{i+1}" for i in range(num_scen)] # Things needed for vanilla cylinders beans = (args, scenario_creator, scenario_denouement, all_scenario_names) # Options for the L-shaped method at the hub spo = None if args.max_solver_threads is None else { "threads": args.max_solver_threads } spo['mipgap'] = 0.005 options = { "master_solver": args.solver_name, "sp_solver": args.solver_name, "sp_solver_options": spo, "master_solver_options": spo, #"valid_eta_lb": {n:0. for n in all_scenario_names}, "max_iter": args.max_iterations, "verbose": False, "master_scenarios": [all_scenario_names[len(all_scenario_names) // 2]], } # L-shaped hub hub_dict = { "hub_class": LShapedHub, "hub_kwargs": { "options": { "rel_gap": args.rel_gap, "abs_gap": args.abs_gap, }, }, "opt_class": LShapedMethod, "opt_kwargs": { # Args passed to LShapedMethod __init__ "options": options, "all_scenario_names": all_scenario_names, "scenario_creator": scenario_creator, "scenario_creator_kwargs": scenario_creator_kwargs, }, } # FWPH spoke if with_fwph: fw_spoke = vanilla.fwph_spoke( *beans, scenario_creator_kwargs=scenario_creator_kwargs) fw_spoke["opt_kwargs"]["PH_options"]["abs_gap"] = 0. fw_spoke["opt_kwargs"]["PH_options"]["rel_gap"] = 1e-5 fw_spoke["opt_kwargs"]["rho_setter"] = uc.scenario_rhos if with_xhatlshaped: xhatlshaped_spoke = vanilla.xhatlshaped_spoke( *beans, scenario_creator_kwargs=scenario_creator_kwargs) list_of_spoke_dict = list() if with_fwph: list_of_spoke_dict.append(fw_spoke) if with_xhatlshaped: list_of_spoke_dict.append(xhatlshaped_spoke) spin_the_wheel(hub_dict, list_of_spoke_dict)