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


Python ModelEnsemble.set_model_structure方法代碼示例

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


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

示例1: transition_test

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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: maxmin_optimize

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [as 別名]
def maxmin_optimize():
    ema_logging.log_to_stderr(ema_logging.INFO)
 
    model = TestModel("", 'simpleModel') #instantiate the model
    ensemble = ModelEnsemble() #instantiate an ensemble
    ensemble.set_model_structure(model) #set the model on the ensemble
    ensemble.parallel = True
    ensemble.processes = 12
    
    def obj_function1(outcomes):
        return outcomes['y']
    
    policy_levers = { "L1": (0,1),
                      "L2": (0,1)}
    
    
    
    results = ensemble.perform_maximin_optimization(obj_function1 = obj_function1, 
                                                policy_levers = policy_levers,
                                                minimax1='minimize',
                                                nrOfGenerations1=50,
                                                nrOfPopMembers1=200,
                                                minimax2 = "maximize",                                   
                                                nrOfGenerations2 = 50,
                                                nrOfPopMembers2 = 100,
                                                )

    graph_errorbars_raw(results['stats'])
    plt.show()
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例3: flu_test

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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

示例4: test_optimization

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [as 別名]
def test_optimization():
    ema_logging.log_to_stderr(ema_logging.INFO)
    
    model = FluModel(r'..\data', "fluCase")
    ensemble = ModelEnsemble()
    
    ensemble.set_model_structure(model)
    ensemble.parallel=True
#    ensemble.processes = 12
        
    stats, pop  = ensemble.perform_outcome_optimization(obj_function = obj_function_multi,
                                                    reporting_interval=10, 
                                                    weights=(MAXIMIZE, MAXIMIZE),
                                                    pop_size=100,
                                                    nr_of_generations=5,
                                                    crossover_rate=0.5,
                                                    mutation_rate=0.05)
    res = stats.hall_of_fame.keys
    
    x = [entry.values[0] for entry in res]
    y = [entry.values[1] for entry in res]
    
    print len(x), len(y)
    
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.scatter(x,y)
    ax.set_ylabel("deceased population")
    ax.set_xlabel("infected fraction")
    
    plt.show()
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例5: test_inspect

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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,代碼來源:

示例6: perform_experiments

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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_save_results

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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

示例8: test_running_lookup_uncertainties

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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

示例9: test_vensim_model

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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

示例10: test_optimization

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [as 別名]
def test_optimization():
    ema_logging.log_to_stderr(ema_logging.INFO)
    
    model = FluModel(r'..\data', "fluCase")
    ensemble = ModelEnsemble()
    
    ensemble.set_model_structure(model)
    ensemble.parallel=True
        
    stats, pop  = ensemble.perform_outcome_optimization(obj_function = obj_function_multi,
                                                    reporting_interval=100, 
                                                    weights=(MAXIMIZE, MAXIMIZE),
                                                    pop_size=100,
                                                    nr_of_generations=20,
                                                    crossover_rate=0.5,
                                                    mutation_rate=0.05,
                                                    caching=False)
    res = stats.hall_of_fame.keys
    
    print len(stats.tried_solutions.values())
開發者ID:bram32,項目名稱:EMAworkbench,代碼行數:22,代碼來源:test_outcome_optimization.py

示例11: test_tree

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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

示例12: outcome_optimize

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [as 別名]
def outcome_optimize():
    ema_logging.log_to_stderr(ema_logging.INFO)
 
    model = TestModel("", 'simpleModel') #instantiate the model
    ensemble = ModelEnsemble() #instantiate an ensemble
    ensemble.set_model_structure(model) #set the model on the ensemble
    policy = {"name": "test",
              "L1": 1,
              "L2": 1}
    ensemble.add_policy(policy)
    
    def obj_func(results):
        return results['y']        
    
    results = ensemble.perform_outcome_optimization(obj_function=obj_func, 
                                          minimax = 'minimize', 
                                          nrOfGenerations = 1000, 
                                          nrOfPopMembers = 10)

    graph_errorbars_raw(results['stats'])
    plt.show()
開發者ID:,項目名稱:,代碼行數:23,代碼來源:

示例13: test_feature_selection

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [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

示例14: robust_optimize

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [as 別名]
def robust_optimize():
    ema_logging.log_to_stderr(ema_logging.INFO)
 
    model = TestModel("", 'simpleModel') #instantiate the model
    ensemble = ModelEnsemble() #instantiate an ensemble
    ensemble.set_model_structure(model) #set the model on the ensemble
    
    
    policy_levers = { "L1": (0,1),
                      "L2": (0,1)}
    
    def obj_func(results):
        return np.average(results['y'])        
    
    results = ensemble.perform_robust_optimization(cases=1000, 
                                                   obj_function=obj_func, 
                                                   policy_levers=policy_levers, 
                                                   minimax='minimize', 
                                                   nrOfGenerations=50, 
                                                   nrOfPopMembers=20 )
    graph_errorbars_raw(results['stats'])
    plt.show()
開發者ID:,項目名稱:,代碼行數:24,代碼來源:

示例15: test_optimization

# 需要導入模塊: from expWorkbench import ModelEnsemble [as 別名]
# 或者: from expWorkbench.ModelEnsemble import set_model_structure [as 別名]
def test_optimization():
    ema_logging.log_to_stderr(ema_logging.INFO)
    
    model = FluModel(r'../models', "fluCase")
    ensemble = ModelEnsemble()
    
    ensemble.set_model_structure(model)
    ensemble.parallel=True
    
    pop_size = 8
    nr_of_generations = 10
    eps = np.array([1e-3, 1e6])

    stats, pop  = ensemble.perform_outcome_optimization(obj_function = obj_function_multi,
                                                    algorithm=epsNSGA2,
                                                    reporting_interval=100, 
                                                    weights=(MAXIMIZE, MAXIMIZE),
                                                    pop_size=pop_size,          
                                                    nr_of_generations=nr_of_generations,
                                                    crossover_rate=0.8,
                                                    mutation_rate=0.05,
                                                    eps=eps)
    fn = '../data/test optimization save.bz2'
開發者ID:epruyt,項目名稱:EMAworkbench,代碼行數:25,代碼來源:test_outcome_optimization.py


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