def test_save_and_load(): import matplotlib.pyplot as plt from expWorkbench.EMAlogging import log_to_stderr, INFO from expWorkbench.model import SimpleModelEnsemble from examples.FLUvensimExample import FluModel from analysis.graphs import lines log_to_stderr(level= INFO) model = FluModel(r'..\..\models\flu', "fluCase") ensemble = SimpleModelEnsemble() # 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) file = r'C:\eclipse\workspace\EMA workbench\models\results.cPickle' save_results(results, file) results = load_results(file) lines(results) plt.show()
def test_transform_data(): results = transform_old_cPickle_to_new_cPickle(r'C:\workspace\EMA workbench\src\sandbox\100Flu.cPickle') from analysis.graphs import lines import matplotlib.pyplot as plt lines(results) plt.show()
''' Created on 26 sep. 2011 @author: jhkwakkel ''' import matplotlib.pyplot as plt from expWorkbench import load_results from analysis.graphs import lines data = load_results(r'../../../src/analysis/1000 flu cases.cPickle') fig = lines(data, column='fatality ratio region 1', density=False) plt.show()
ensemble = SimpleModelEnsemble() ensemble.set_model_structure(model) cases, uncertainties = ensemble._generate_cases(1) valuelist = [15.467089994193 , 18.3948367845855 , 17.5216359599053 , 0.0323513175268276 , 0.0267216806566911 , 0.0252897989265933 , 0.0211748970259063 , 0.0192967619764282 , 0.0298868721235403 , 0.026846492561752 , 0.0282265728603356 , 0.0274643497911105 , 0.0206173186487346 , 0.930953610229856 , 1.05807449426449 , 58.6261672319115 , 1.0959476696141 , 48.4897275078371 , 79.8968117041453 , 2.03012275630195 , 2.33576352581696 , 2.60266175740213 , 1.24700542123355 , 3.06884098418713 , 1 , 0 , 0 , 0 , 0 , 1.45807445678444 , 3.53395235847141 , 1.75257486371618 , 2.9795030911447 , 4.00199168664975 , 1.97473349200058 , 4.74196793795403 , 4.72730891245437 , 0 , 0 , 14826.4074143275 , 1.24609526886412 , 1.18827514220571 , 1.09824115488565 , 1245886.83942348 , 6282282.69560999 , 6118827.67237203 , 9531496.10651471 , 8693813.50295679 , 32.948697875027 , 17.1705785135149 , 13.0971274404015 , 3.74255065304761 , 1.36231655867486 , 1.92101352688469 , 3.8941723138427 , 0.898745338298322 , 0.782806406356795 , 0.817631734201507 , 0.705822656618514 , 43.3820783577107] newcases = [] case = {} i=0 for uncertainty in uncertainties: print uncertainty.name case[uncertainty.name] = valuelist[i] i+=1 # case['desired fraction'] = 1.0 # uncertainties.add(ParameterUncertainty((0.7,1), "desired fraction")) newcases.append(case) # uncertainties.append('desired fraction') results = ensemble.perform_experiments(newcases) print results[1]['total fraction new technologies'][0, -1] print results[1]['total capacity installed'][0, -1] lines(results) plt.show()
#self.uncertainties.pop() self.uncertainties.append(LookupUncertainty([(0, 4), (1, 5), (1, 5), (0, 2), (0, 2)], "TF2", 'approximation', self, 0, 10)) #self.uncertainties.pop() self.uncertainties.append(ParameterUncertainty((0.02, 0.08), "rate1")) self.uncertainties.append(ParameterUncertainty((0.02, 0.08), "rate2")) self.uncertainties.append(LookupUncertainty([[(0.0, 0.05), (0.25, 0.15), (0.5, 0.4), (0.75, 1), (1, 1.25)], [(0.0, 0.1), (0.25, 0.25), (0.5, 0.75), (1, 1.25)], [(0.0, 0.0), (0.1, 0.2), (0.3, 0.6), (0.6, 0.9), (1, 1.25)]], "TF3", 'categories', self, 0, 2)) #self.uncertainties.pop() self.delete_lookup_uncertainties() if __name__ == "__main__": logger = logging.log_to_stderr(logging.INFO) model = lookup_model(r'..\lookups', "sampleModel") #model.step = 4 #reduce data to be stored ensemble = ModelEnsemble() ensemble.set_model_structure(model) #turn on parallel ensemble.parallel = False #run policy with old cases results = ensemble.perform_experiments(10) save_results(results, 'lookup_3methods.cpickle') results = load_results('lookup_3methods.cpickle') outcomes =['TF', 'TF2', 'TF3', 'flow1'] lines(results, outcomes, density=True, hist=True) plt.show()
''' Created on Sep 18, 2012 @author: sibeleker ''' import numpy as np import matplotlib.pyplot as plt from expWorkbench import load_results from analysis.graphs import lines, envelopes results = load_results('lookup_3methods.cpickle') outcomes_distorted =['TF'] lines(results, outcomes=outcomes_distorted, density=True, hist=True) plt.show()
''' Created on 26 sep. 2011 @author: jhkwakkel ''' import matplotlib.pyplot as plt from expWorkbench import load_results from analysis.graphs import lines data = load_results(r'../../../src/analysis/1000 flu cases.cPickle') fig = lines(data, density=True, hist=True) plt.show()