Пример #1
0
   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)
Пример #2
0
    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)
Пример #3
0
    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)
Пример #4
0
    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)
Пример #6
0
   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)
Пример #7
0
    def test_connector_basic(self):
        """
        Test that the connector can instantiate the pysd interface object
        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)
        self.assertIsInstance(model, PysdModel)
Пример #8
0
    def test_connector_basic(self):
        """
        Test that the connector can instantiate the pysd interface object
        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)
        self.assertIsInstance(model, PysdModel)
Пример #9
0
'''


'''

# 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)
Пример #10
0
'''


'''
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)