def test_multiple_models(self): """ Test running running with two different pysd models Returns ------- """ relative_path_to_file = '../models/Sales_Agent_Market_Building_Dynamics.mdl' directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) mdl_file = os.path.join(directory, relative_path_to_file) market_model = PysdModel(mdl_file=mdl_file) market_model.uncertainties = [RealParameter('Startup Subsidy',0, 3), RealParameter('Startup Subsidy Length', 0, 10)] market_model.outcomes = [TimeSeriesOutcome('Still Employed')] relative_path_to_file = '../models/Sales_Agent_Motivation_Dynamics.mdl' directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) mdl_file = os.path.join(directory, relative_path_to_file) motivation_model = PysdModel(mdl_file=mdl_file) motivation_model.uncertainties = [RealParameter('Startup Subsidy', 0, 3), RealParameter('Startup Subsidy Length', 0, 10)] motivation_model.outcomes =[TimeSeriesOutcome('Still Employed')] models = [market_model, motivation_model] # set the model on the ensemble perform_experiments(models, 5)
def test_parallel_experiment(self): """ Test running an experiment in parallel Returns ------- """ relative_path_to_file = '../models/Teacup.mdl' directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) mdl_file = os.path.join(directory, relative_path_to_file) model = PysdModel(mdl_file=mdl_file) model.uncertainties = [RealParameter('Room Temperature', 33, 120)] model.outcomes = [TimeSeriesOutcome('Teacup Temperature')] with MultiprocessingEvaluator(model, 2) as evaluator: perform_experiments(model, 5, evaluator=evaluator)
def test_sequential_experiment(self): """ Test running an experiment in parallel Returns ------- """ directory = os.path.dirname(__file__) relative_path_to_file = '../models/Teacup.mdl' mdl_file = os.path.join(directory, relative_path_to_file) model = PysdModel(mdl_file=mdl_file) model.uncertainties = [RealParameter('Room Temperature', 33, 120)] model.outcomes = [TimeSeriesOutcome('Teacup Temperature')] with SequentialEvaluator(model) as evaluator: evaluator.perform_experiments(5)
def test_parallel_experiment(self): """ Test running an experiment in parallel Returns ------- """ relative_path_to_file = '../models/Teacup.mdl' directory = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) mdl_file = os.path.join(directory, relative_path_to_file) model = PysdModel(mdl_file=mdl_file) model.uncertainties = [RealParameter('Room Temperature', 33, 120)] model.outcomes = [TimeSeriesOutcome('Teacup Temperature')] ensemble = ModelEnsemble() # instantiate an ensemble ensemble.model_structures = model # set the model on the ensemble ensemble.parallel = True ensemble.perform_experiments(5)
''' ''' # Created on Jul 23, 2016 # # .. codeauthor::jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> from ema_workbench import (RealParameter, TimeSeriesOutcome, ema_logging, perform_experiments) from ema_workbench.connectors.pysd_connector import PysdModel if __name__ == '__main__': ema_logging.log_to_stderr(ema_logging.INFO) mdl_file = './models/pysd/Teacup.mdl' model = PysdModel(mdl_file=mdl_file) model.uncertainties = [RealParameter('Room Temperature', 33, 120)] model.outcomes = [TimeSeriesOutcome('Teacup Temperature')] perform_experiments(model, 100)
''' ''' from __future__ import (unicode_literals, print_function, absolute_import, division) # Created on Jul 23, 2016 # # .. codeauthor::jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> from ema_workbench import (RealParameter, TimeSeriesOutcome, ema_logging, perform_experiments) from ema_workbench.connectors.pysd_connector import PysdModel if __name__ == '__main__': ema_logging.log_to_stderr(ema_logging.DEBUG) mdl_file = './models/pysd/Teacup.mdl' model = PysdModel(mdl_file=mdl_file) model.uncertainties = [RealParameter('Room Temperature', 33, 120)] model.outcomes = [TimeSeriesOutcome('Teacup Temperature')] perform_experiments(model, 100)