本文整理汇总了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)
示例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)
示例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)
示例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
)
示例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)
示例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
示例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)
示例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())
示例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)
示例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])
示例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()
示例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)
示例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()
示例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