當前位置: 首頁>>代碼示例>>Python>>正文


Python ModelEnsemble.perform_experiments方法代碼示例

本文整理匯總了Python中expWorkbench.ModelEnsemble.perform_experiments方法的典型用法代碼示例。如果您正苦於以下問題:Python ModelEnsemble.perform_experiments方法的具體用法?Python ModelEnsemble.perform_experiments怎麽用?Python ModelEnsemble.perform_experiments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在expWorkbench.ModelEnsemble的用法示例。


在下文中一共展示了ModelEnsemble.perform_experiments方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: transition_test

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def transition_test():

    model = EnergyTrans(r"..\..\..\models\EnergyTrans", "fluCase")
    ensemble = ModelEnsemble()
    ensemble.set_model_structure(model)

    ensemble.perform_experiments(cases=10, callback=HDF5Callback)
開發者ID:rahalim,項目名稱:EMAworkbench,代碼行數:9,代碼來源:pytable_test.py

示例2: flu_test

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def flu_test():

    model = FluModel(r"..\..\..\models\flu", "fluCase")
    ensemble = ModelEnsemble()
    ensemble.set_model_structure(model)

    ensemble.perform_experiments(cases=10, callback=HDF5Callback)
開發者ID:rahalim,項目名稱:EMAworkbench,代碼行數:9,代碼來源:pytable_test.py

示例3: test_inspect

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def test_inspect():
    import inspect_test
    model = FluModel(r'..\..\..\models\flu', "fluCase")
    ensemble = ModelEnsemble()
    ensemble.set_model_structure(model)
    
    ensemble.perform_experiments(cases = 10,
                                 callback=inspect_test.InspectCallback)
開發者ID:,項目名稱:,代碼行數:10,代碼來源:

示例4: test_save_results

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def test_save_results():
    os.remove("test.h5")

    nrOfExperiments = 10
    fileName = "test.h5"
    experimentName = "one_exp_test"

    ensemble = ModelEnsemble()
    ensemble.set_model_structure(FluModel(r"..\..\..\models\flu", "fluCase"))

    ensemble.perform_experiments(
        nrOfExperiments, callback=HDF5Callback, fileName=fileName, experimentName=experimentName
    )
開發者ID:rahalim,項目名稱:EMAworkbench,代碼行數:15,代碼來源:pytable_test.py

示例5: test_running_lookup_uncertainties

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
 def test_running_lookup_uncertainties(self):
     '''
     This is the more comprehensive test, given that the lookup
     uncertainty replaces itself with a bunch of other uncertainties, check
     whether we can successfully run a set of experiments and get results
     back. We assert that the uncertainties are correctly replaced by
     analyzing the experiments array. 
     
     '''
     model = LookupTestModel( r'../models/', 'lookupTestModel')
     
     #model.step = 4 #reduce data to be stored
     ensemble = ModelEnsemble()
     ensemble.set_model_structure(model)
     
     ensemble.perform_experiments(10)
開發者ID:epruyt,項目名稱:EMAworkbench,代碼行數:18,代碼來源:test_vensim.py

示例6: perform_experiments

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def perform_experiments():
    ema_logging.log_to_stderr(level=ema_logging.INFO)
    model = SalinizationModel(r"C:\workspace\EMA-workbench\models\salinization", "verzilting")
    model.step = 4
    
    ensemble = ModelEnsemble()
    ensemble.set_model_structure(model)
    
    ensemble.parallel = True
    nr_of_experiments = 10000
    results = ensemble.perform_experiments(nr_of_experiments)
    return results
開發者ID:canerhamarat,項目名稱:EMAworkbench,代碼行數:14,代碼來源:salinization_example.py

示例7: test_multiple_models

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def test_multiple_models():
    class Model1(ModelStructureInterface):
        uncertainties = [ParameterUncertainty((0,1),"a"),
                         ParameterUncertainty((0,1),"b")]
        
        outcomes = [Outcome("test")]
        
        def model_init(self, policy, kwargs):
            pass
        
        def run_model(self, case):
            self.output['test'] = 1

    class Model2(ModelStructureInterface):
        uncertainties = [ParameterUncertainty((0,1),"b"),
                         ParameterUncertainty((0,1),"c")]
        
        outcomes = [Outcome("test")]
        
        def model_init(self, policy, kwargs):
            pass
        
        def run_model(self, case):
            self.output['test'] = 1
    
#    os.remove('test.h5')

    nrOfExperiments = 10
    fileName = 'test.h5'
    experimentName = "one_exp_test"
    
    ensemble = ModelEnsemble()
    ensemble.add_model_structure(Model1('', "test1"))
    ensemble.add_model_structure(Model2('', "test2"))
    
    ensemble.perform_experiments(nrOfExperiments,
                                 callback=HDF5Callback,
                                 fileName=fileName,
                                 experimentName=experimentName)
開發者ID:,項目名稱:,代碼行數:41,代碼來源:

示例8: test_vensim_model

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
 def test_vensim_model(self):
     #instantiate a model
     wd = r'../models'
     model = VensimExampleModel(wd, "simpleModel")
     
     #instantiate an ensemble
     ensemble = ModelEnsemble()
     
     #set the model on the ensemble
     ensemble.set_model_structure(model)
     
     nr_runs = 10
     experiments, outcomes = ensemble.perform_experiments(nr_runs)
     
     self.assertEqual(experiments.shape[0], nr_runs)
     self.assertIn('TIME', outcomes.keys())
     self.assertIn(model.outcomes[0].name, outcomes.keys())
開發者ID:epruyt,項目名稱:EMAworkbench,代碼行數:19,代碼來源:test_vensim.py

示例9: test_tree

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def test_tree():
    
    log_to_stderr(level= INFO)
        
    model = FluModel(r'..\..\models\flu', "fluCase")
    ensemble = ModelEnsemble()
    ensemble.parallel = True
    ensemble.set_model_structure(model)
    
    policies = [{'name': 'no policy',
                 'file': r'\FLUvensimV1basecase.vpm'},
                {'name': 'static policy',
                 'file': r'\FLUvensimV1static.vpm'},
                {'name': 'adaptive policy',
                 'file': r'\FLUvensimV1dynamic.vpm'}
                ]
    ensemble.add_policies(policies)
    
    results = ensemble.perform_experiments(10)
   
    a_tree = tree(results, classify)
開發者ID:bram32,項目名稱:EMAworkbench,代碼行數:23,代碼來源:test_orange_functions.py

示例10: test_feature_selection

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
def test_feature_selection():
    log_to_stderr(level= INFO)
        
    model = FluModel(r'..\..\models\flu', "fluCase")
    ensemble = ModelEnsemble()
    ensemble.parallel = True
    ensemble.set_model_structure(model)
    
    policies = [{'name': 'no policy',
                 'file': r'\FLUvensimV1basecase.vpm'},
                {'name': 'static policy',
                 'file': r'\FLUvensimV1static.vpm'},
                {'name': 'adaptive policy',
                 'file': r'\FLUvensimV1dynamic.vpm'}
                ]
    ensemble.add_policies(policies)
    
    results = ensemble.perform_experiments(5000)
   
    results = feature_selection(results, classify)
    for entry in results:
        print entry[0] +"\t" + str(entry[1])
開發者ID:bram32,項目名稱:EMAworkbench,代碼行數:24,代碼來源:test_orange_functions.py

示例11: Outcome

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
    ]

    outcomes = [
        Outcome("sheep", time=True),
        Outcome("wolves", time=True),
        Outcome("grass", time=True),  # TODO patches not working in reporting
    ]


if __name__ == "__main__":
    # turn on logging
    ema_logging.log_to_stderr(ema_logging.INFO)

    # instantiate a model
    vensimModel = PredatorPrey(r"..\..\models\predatorPreyNetlogo", "simpleModel")

    # instantiate an ensemble
    ensemble = ModelEnsemble()

    # set the model on the ensemble
    ensemble.set_model_structure(vensimModel)

    # run in parallel, if not set, FALSE is assumed
    ensemble.parallel = True

    # perform experiments
    results = ensemble.perform_experiments(100)

    plotting.lines(results, density=plotting.KDE)
    plt.show()
開發者ID:rahalim,項目名稱:EMAworkbench,代碼行數:32,代碼來源:netlogo_example.py

示例12: ParameterUncertainty

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
                             "susceptible to immune population delay time region 1"),
        ParameterUncertainty((0.5,2), 
                             "susceptible to immune population delay time region 2"),
        ParameterUncertainty((0.01, 5), 
                             "root contact rate region 1"),
        ParameterUncertainty((0.01, 5), 
                             "root contact ratio region 2"),
        ParameterUncertainty((0, 0.15), 
                             "infection ratio region 1"),
        ParameterUncertainty((0, 0.15), 
                             "infection rate region 2"),
        ParameterUncertainty((10, 100), 
                             "normal contact rate region 1"),
        ParameterUncertainty((10, 200), 
                             "normal contact rate region 2")]
                         
        
if __name__ == "__main__":
    ema_logging.log_to_stderr(ema_logging.INFO)
        
    model = FluModel(r'./models/flu', "fluCase")
    ensemble = ModelEnsemble()
    ensemble.set_model_structure(model)
    
    ensemble.parallel = True #turn on parallel processing

    nr_experiments = 1000
    results = ensemble.perform_experiments(nr_experiments)
    
    fh =  r'./data/{} flu cases no policy.tar.gz'.format(nr_experiments)
    save_results(results, fh)
開發者ID:epruyt,項目名稱:EMAworkbench,代碼行數:33,代碼來源:flu_vensim_no_policy_example.py

示例13: return

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
        susceptible_population_region_1 = susceptible_population_region_1_NEXT
        susceptible_population_region_2 = susceptible_population_region_2_NEXT
    
        immune_population_region_1 = immune_population_region_1_NEXT
        immune_population_region_2 = immune_population_region_2_NEXT
    
        deceased_population_region_1.append(deceased_population_region_1_NEXT)
        deceased_population_region_2.append(deceased_population_region_2_NEXT)
        
        #End of main code
    return (runTime, deceased_population_region_1) #, Max_infected, Max_time)

        
if __name__ == "__main__":
    import expWorkbench.ema_logging as logging
    np.random.seed(150) #set the seed for replication purposes
    logging.log_to_stderr(logging.INFO)
    
    fluModel = MexicanFlu(None, "mexicanFluExample")
    ensemble = ModelEnsemble()
    ensemble.parallel = True
    ensemble.set_model_structure(fluModel)
    
    nr_experiments = 500
    results = ensemble.perform_experiments(nr_experiments, reporting_interval=100)

    lines(results, outcomes_to_show="deceased_population_region_1", 
          show_envelope=True, density=KDE, titles=None, 
          experiments_to_show=np.arange(0, nr_experiments, 10)
          )
    plt.show()
開發者ID:canerhamarat,項目名稱:EMAworkbench,代碼行數:33,代碼來源:flu_example.py

示例14: SimplePythonModel

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import perform_experiments [as 別名]
class SimplePythonModel(ModelStructureInterface):
    """
    This class represents a simple example of how one can extent the basic
    ModelStructureInterface in order to do EMA on a simple model coded in
    Python directly
    """

    # specify uncertainties
    uncertainties = [
        ParameterUncertainty((0.1, 10), "x1"),
        ParameterUncertainty((-0.01, 0.01), "x2"),
        ParameterUncertainty((-0.01, 0.01), "x3"),
    ]

    # specify outcomes
    outcomes = [Outcome("y")]

    def model_init(self, policy, kwargs):
        pass

    def run_model(self, case):
        """Method for running an instantiated model structure """
        self.output[self.outcomes[0].name] = case["x1"] * case["x2"] + case["x3"]


if __name__ == "__main__":
    model = SimplePythonModel(None, "simpleModel")  # instantiate the model
    ensemble = ModelEnsemble()  # instantiate an ensemble
    ensemble.set_model_structure(model)  # set the model on the ensemble
    results = ensemble.perform_experiments(1000)  # generate 1000 cases
開發者ID:rahalim,項目名稱:EMAworkbench,代碼行數:32,代碼來源:python_example.py


注:本文中的expWorkbench.ModelEnsemble.perform_experiments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。