def _init(self, factory): _setUpPyro() [_poll(proc) for proc in _taskworker_processes] options = ScenarioTreeManagerClientPyro.register_options() options.pyro_port = _pyomo_ns_port options.pyro_required_scenariotreeservers = 3 options.pyro_handshake_at_startup = True sp = ScenarioTreeManagerClientPyro(options, factory=factory) sp.initialize() return sp
def _init(self, factory): _setUpPyro() [_poll(proc) for proc in _taskworker_processes] options = ScenarioTreeManagerClientPyro.register_options() options.pyro_port = _pyomo_ns_port options.pyro_required_scenariotreeservers = 3 options.pyro_handshake_at_startup = True sp = ScenarioTreeManagerClientPyro( options, factory=factory) sp.initialize() return sp
def pyro_sample_sp(self, size, **kwds): assert size > 0 model = self.reference_model.clone() scenario_tree_model = \ self._create_scenario_tree_model(size) factory = ScenarioTreeInstanceFactory( model=self.reference_model, scenario_tree=scenario_tree_model) options = \ ScenarioTreeManagerClientPyro.register_options() for key in kwds: options[key] = kwds[key] manager = ScenarioTreeManagerClientPyro(options, factory=factory) try: init = manager.initialize(async_call=True) pcuids = ComponentMap() for param in self.stochastic_data: pcuids[param] = ComponentUID(param) init.complete() for scenario in manager.scenario_tree.scenarios: data = [] for param, dist in self.stochastic_data.items(): data.append((pcuids[param], dist.sample())) manager.invoke_function( "_update_data", thisfile, invocation_type=InvocationType.OnScenario(scenario.name), function_args=(data, ), oneway_call=True) manager.reference_model = model except: manager.close() raise return manager
def pyro_sample_sp(self, size, **kwds): assert size > 0 model = self.reference_model.clone() scenario_tree_model = \ self._create_scenario_tree_model(size) factory = ScenarioTreeInstanceFactory( model=self.reference_model, scenario_tree=scenario_tree_model) options = \ ScenarioTreeManagerClientPyro.register_options() for key in kwds: options[key] = kwds[key] manager = ScenarioTreeManagerClientPyro( options, factory=factory) try: init = manager.initialize(async_call=True) pcuids = ComponentMap() for param in self.stochastic_data: pcuids[param] = ComponentUID(param) init.complete() for scenario in manager.scenario_tree.scenarios: data = [] for param, dist in self.stochastic_data.items(): data.append((pcuids[param], dist.sample())) manager.invoke_function( "_update_data", thisfile, invocation_type=InvocationType.OnScenario(scenario.name), function_args=(data,), oneway_call=True) manager.reference_model = model except: manager.close() raise return manager