def get_custom_R_metrics_for_workbench(): """Returns robustness metrics that can interact with ema_workbench It is simple to create robustness metrics (see get_custom_R_metrics()) and ema_workbench requires them be specified in a particular way. Therefore, this function specifies them for the ema_workbench. Returns a list of robustness metrics to be used for the Lake Model. """ # Note that we want to minimise max_P, so we define this in the # robustness metrics above (maximise=False), and this changes # the sign of the robustness metric, so that we can always # make the objective to MAXIMIZE robustness. R_metrics = get_custom_R_metrics() robustness_functions = [ ScalarOutcome('Av vulnerability R', kind=ScalarOutcome.MAXIMIZE, variable_name='max_P', function=R_metrics[0]), ScalarOutcome('Reliability R', kind=ScalarOutcome.MAXIMIZE, variable_name='reliability', function=R_metrics[1]), ScalarOutcome('Utility R', kind=ScalarOutcome.MAXIMIZE, variable_name='utility', function=R_metrics[2]), ScalarOutcome('Inertia R', kind=ScalarOutcome.MAXIMIZE, variable_name='inertia', function=R_metrics[3]) ] return robustness_functions
def get_lake_model(): """Returns a fully formulated model of the lake problem.""" # instantiate the model lake_model = Model('lakeproblem', function=lake_problem) lake_model.time_horizon = 100 # specify uncertainties lake_model.uncertainties = [ RealParameter('b', 0.1, 0.45), RealParameter('q', 2.0, 4.5), RealParameter('mean', 0.01, 0.05), RealParameter('stdev', 0.001, 0.005), RealParameter('delta', 0.93, 0.99) ] # set levers, one for each time step lake_model.levers = [ RealParameter(str(i), 0, 0.1) for i in range(lake_model.time_horizon) ] # specify outcomes lake_model.outcomes = [ ScalarOutcome('max_P', ), ScalarOutcome('utility'), ScalarOutcome('inertia'), ScalarOutcome('reliability') ] # override some of the defaults of the model lake_model.constants = [Constant('alpha', 0.41), Constant('nsamples', 150)] return lake_model
def robustness_func_generator(thresholds): dict_funcs = {} for key, thresh in thresholds.items(): dict_funcs[key] = functools.partial(robustness, thresh) direction = ScalarOutcome.MAXIMIZE robustness_functions = [] outcomes = [ 'Expected Number of Deaths(1/3)', 'Expected Number of Deaths(2/5)', 'Expected Number of Deaths(4)', 'Dike Investment Costs(1/3)', 'Dike Investment Costs(2/5)', 'Dike Investment Costs(4)', 'RfR Total Costs', 'Expected Evacuation Costs' ] var_names = outcomes for i, var_name in enumerate(var_names): frac_name = "frac_{}".format(var_name) func = dict_funcs[var_name] robust_func = ScalarOutcome(name=frac_name, kind=direction, variable_name=var_name, function=func) robustness_functions.append(robust_func) return robustness_functions
def performExperiments(): ema_logging.LOG_FORMAT = '[%(name)s/%(levelname)s/%(processName)s] %(message)s' ema_logging.log_to_stderr(ema_logging.INFO) model = Model('SimulateER', function=simulate_ER) # instantiate the model # specify uncertainties model.uncertainties = [RealParameter("p", 0.1, 1.0)] model.uncertainties = [RealParameter("f", 0.1, 0.9)] model.levers = [IntegerParameter("n", 10, 100)] # specify outcomes model.outcomes = [ScalarOutcome('cc')] model.constants = [Constant('replications', 10)] n_scenarios = 10 n_policies = 10 res = perform_experiments(model, n_scenarios, n_policies) experiments, outcomes = res data = experiments[['n', 'p', 'f']] data.to_csv('out.csv', index=False) return data
def set_model(func=recycle_model): experiment_model = EMA_Model('plastic', function=func) uncertainties = [ RealParameter('target_mean', 0.05, 0.20), RealParameter('amb_mean', 0.1, 0.5), RealParameter('percep_range', 0.1, 0.5), RealParameter('know_range', 0.1, 0.5), RealParameter('technology', 0.1, 0.5), RealParameter('tech_std', 0.05, 0.20), IntegerParameter('cap_mean', 400, 800), IntegerParameter('cap_std', 100, 400), ] levers = [ RealParameter("campaign_bud_prop", 0.05, 0.5), RealParameter("final_target", 0.1, 0.4) ] outcomes = [ ScalarOutcome('target_met_frac', ), ScalarOutcome('no_budget_frac', ), ScalarOutcome('avg_fine_period'), ScalarOutcome('fine_per_house'), ScalarOutcome('time_conv'), ScalarOutcome('profit_std'), ] experiment_model.uncertainties = uncertainties experiment_model.levers = levers experiment_model.outcomes = outcomes return experiment_model
def get_original_R_metrics(): """Returns the Robustness metrics from original example.""" robustness_functions = [ ScalarOutcome('mean p', kind=ScalarOutcome.MINIMIZE, variable_name='max_P', function=np.mean), ScalarOutcome('std p', kind=ScalarOutcome.MINIMIZE, variable_name='max_P', function=np.std), ScalarOutcome('sn reliability', kind=ScalarOutcome.MAXIMIZE, variable_name='reliability', function=signal_to_noise), ScalarOutcome('10th percentile utility', kind=ScalarOutcome.MAXIMIZE, variable_name='reliability', function=functools.partial(np.percentile, q=10)) ] return robustness_functions
model = Model('lakeproblem', function=lake_model_actual) model.time_horizon = 100 # specify uncertainties model.uncertainties = [ RealParameter('b', 0.1, 0.45), RealParameter('q', 2.0, 4.5), RealParameter('mean', 0.01, 0.05), RealParameter('stdev', 0.001, 0.005), RealParameter('delta', 0.93, 0.99) ] # specify outcomes model.outcomes = [ ScalarOutcome('max_P'), ScalarOutcome('utility'), ScalarOutcome('inertia'), ScalarOutcome('reliability') ] # set levers #model.levers = [RealParameter('decisions', 0, 0.1)] model.levers = [ RealParameter(f"l{i}", 0, 0.1) for i in range(model.time_horizon) ] # model constants model.constants = [Constant('alpha', 0.4), Constant('nsamples', 100)] #####################################################################################################
# function=np.sum), # ScalarOutcome('total subsidy PoRA', ScalarOutcome.MINIMIZE, variable_name='total-subsidy-to-por-global', # function=np.max), # ScalarOutcome('total subsidy industries', ScalarOutcome.MINIMIZE, variable_name='total-subsidy-to-industries-global', # function=np.max)] #model.outcomes = [ScalarOutcome('lastvalue-co2-emitted-to-air-global', ScalarOutcome.MINIMIZE), # ScalarOutcome('sum-co2-emitted-to-air-global', ScalarOutcome.MAXIMIZE), # ScalarOutcome('sum-subsidy-to-por-global', ScalarOutcome.MINIMIZE), # ScalarOutcome('sum-subsidy-to-industries-global', ScalarOutcome.MINIMIZE)] #np.max is used as the outcome is a list of one value #-> it doesn't matter which function is used to extract it, np.max was chosen arbitrarily model.outcomes = [ ScalarOutcome('2050 yearly CO2 emitted', ScalarOutcome.MINIMIZE, variable_name='lastvalue-co2-emitted-to-air-global', function=np.max), ScalarOutcome('sum-co2-emitted-to-air-global', ScalarOutcome.MAXIMIZE, variable_name='sum-co2-emitted-to-air-global', function=np.max), ScalarOutcome('sum-subsidy-to-por-global', ScalarOutcome.MINIMIZE, variable_name='sum-subsidy-to-por-global', function=np.max), ScalarOutcome('sum-subsidy-to-industries-global', ScalarOutcome.MINIMIZE, variable_name='sum-subsidy-to-industries-global', function=np.max) ]
IntegerParameter('scenario_pop_gdp', 0, 5), IntegerParameter('scenario_sigma', 0, 2), IntegerParameter('scenario_cback', 0, 1), IntegerParameter('scenario_elasticity_of_damages', 0, 2), IntegerParameter('scenario_limmiu', 0, 1) ] RICE.levers = [ RealParameter('sr', 0.1, 0.5), RealParameter('irstp', 0.001, 0.015), IntegerParameter('miu_period', 5, 30), IntegerParameter('egalitarian_discounting', 0, 1) ] #0 = no discouting , 1 = normal discounting, RICE.outcomes = [ ScalarOutcome('Intratemporal utility GINI 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal utility GINI 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Intertemporal utility GINI', ScalarOutcome.MINIMIZE), ScalarOutcome('Intertemporal impact GINI', ScalarOutcome.MINIMIZE) ] convergence_metrics = [EpsilonProgress()] minimize = ScalarOutcome.MINIMIZE maximize = ScalarOutcome.MAXIMIZE for outcome in RICE.outcomes:
def get_model_for_problem_formulation(problem_formulation_id): ''' Prepare DikeNetwork in a way it can be input in the EMA-workbench. Specify uncertainties, levers and problem formulation. ''' # Load the model: function = DikeNetwork() # workbench model: dike_model = Model('dikesnet', function=function) ## Uncertainties and Levers: # Specify uncertainties range: Real_uncert = {'Bmax': [30, 350], 'pfail': [0, 1]} # m and [.] cat_uncert_loc = {'Brate': (0.9, 1.5, 1000)} # breach growth rate [m/day] cat_uncert = {'discount rate': (1.5, 2.5, 3.5, 4.5)} Int_uncert = {'A.0_ID flood wave shape': [0, 133]} # Range of dike heightening: dike_lev = {'DikeIncrease': [0, 10]} # dm # Series of five Room for the River projects: rfr_lev = ['{}_RfR'.format(project_id) for project_id in range(0, 5)] # Time of warning: 0, 1, 2, 3, 4 days ahead from the flood EWS_lev = {'EWS_DaysToThreat': [0, 4]} # days uncertainties = [] levers = [] for dike in function.dikelist: # uncertainties in the form: locationName_uncertaintyName for uncert_name in Real_uncert.keys(): name = "{}_{}".format(dike, uncert_name) lower, upper = Real_uncert[uncert_name] uncertainties.append(RealParameter(name, lower, upper)) for uncert_name in cat_uncert_loc.keys(): name = "{}_{}".format(dike, uncert_name) categories = cat_uncert_loc[uncert_name] uncertainties.append(CategoricalParameter(name, categories)) # location-related levers in the form: locationName_leversName for lev_name in dike_lev.keys(): name = "{}_{}".format(dike, lev_name) levers.append( IntegerParameter(name, dike_lev[lev_name][0], dike_lev[lev_name][1])) for uncert_name in cat_uncert.keys(): categories = cat_uncert[uncert_name] uncertainties.append(CategoricalParameter(uncert_name, categories)) # project-related levers can be either 0 (not implemented) or 1 (implemented) for uncert_name in Int_uncert.keys(): uncertainties.append( IntegerParameter(uncert_name, Int_uncert[uncert_name][0], Int_uncert[uncert_name][1])) # RfR levers can be either 0 (not implemented) or 1 (implemented) for lev_name in rfr_lev: levers.append(IntegerParameter(lev_name, 0, 1)) # Early Warning System lever for lev_name in EWS_lev.keys(): levers.append( IntegerParameter(lev_name, EWS_lev[lev_name][0], EWS_lev[lev_name][1])) # load uncertainties and levers in dike_model: dike_model.uncertainties = uncertainties dike_model.levers = levers ## Problem formulations: # Outcomes are all costs, thus they have to minimized: direction = ScalarOutcome.MINIMIZE # 2-objective PF: if problem_formulation_id == 0: dikes_variable_names = [] for dike in function.dikelist: dikes_variable_names.extend([ '{}_{}'.format(dike, e) for e in ['Expected Annual Damage', 'Dike Investment Costs'] ]) dikes_variable_names.extend(['RfR Total Costs']) dikes_variable_names.extend(['Expected Evacuation Costs']) dike_model.outcomes = [ ScalarOutcome('All Costs', variable_name=[var for var in dikes_variable_names], function=sum_over, kind=direction), ScalarOutcome('Expected Number of Deaths', variable_name=[ '{}_Expected Number of Deaths'.format(dike) for dike in function.dikelist ], function=sum_over, kind=direction) ] # 3-objectives PF: elif problem_formulation_id == 1: dike_model.outcomes = [ ScalarOutcome('Expected Annual Damage', variable_name=[ '{}_Expected Annual Damage'.format(dike) for dike in function.dikelist ], function=sum_over, kind=direction), ScalarOutcome('Total Investment Costs', variable_name=[ '{}_Dike Investment Costs'.format(dike) for dike in function.dikelist ] + ['RfR Total Costs'] + ['Expected Evacuation Costs'], function=sum_over, kind=direction), ScalarOutcome('Expected Number of Deaths', variable_name=[ '{}_Expected Number of Deaths'.format(dike) for dike in function.dikelist ], function=sum_over, kind=direction) ] # 12-objectives PF: elif problem_formulation_id == 2: outcomes = [] for dike in function.dikelist: outcomes.append( ScalarOutcome( '{} Total Costs'.format(dike), variable_name=[ '{}_{}'.format(dike, e) for e in ['Expected Annual Damage', 'Dike Investment Costs'] ], function=sum_over, kind=direction)) outcomes.append( ScalarOutcome('{}_Expected Number of Deaths'.format(dike), kind=direction)) outcomes.append(ScalarOutcome('RfR Total Costs', kind=direction)) outcomes.append( ScalarOutcome('Expected Evacuation Costs', kind=direction)) dike_model.outcomes = outcomes # 17-objectives PF: elif problem_formulation_id == 3: outcomes = [] for dike in function.dikelist: for entry in [ 'Expected Annual Damage', 'Dike Investment Costs', 'Expected Number of Deaths' ]: o = ScalarOutcome('{}_{}'.format(dike, entry), kind=direction) outcomes.append(o) outcomes.append(ScalarOutcome('RfR Total Costs', kind=direction)) outcomes.append( ScalarOutcome('Expected Evacuation Costs', kind=direction)) dike_model.outcomes = outcomes else: raise TypeError('unknonw identifier') return dike_model
IntegerParameter('scenario_sigma',0,5), IntegerParameter('scenario_cback',0,2), IntegerParameter('cback_to_zero',0,1), RealParameter('fosslim', 4000, 13649), RealParameter('limmiu',0.8,1.2)] RICE.levers = [RealParameter('sr', 0.1, 0.5), RealParameter('irstp', 0.001, 0.015), IntegerParameter('miu_period', 5, 30), IntegerParameter('sufficitarian_discounting', 0,1), RealParameter('growth_factor_suf',1,1.04), RealParameter('ini_suf_treshold',0.7,2.4)] RICE.outcomes =[ScalarOutcome('Distance to treshold 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Total Aggregated Utility',ScalarOutcome.MAXIMIZE) ]
RealParameter("dev_rate_storage_elec", 0.025, 0.075), #0.05 is estimated base value #RealParameter("dev_rate_storage_heat",0.0125,0.0375),#0.016 is estimated base value RealParameter("dev_rate_conv_P2G", 0.0395, 0.1185), #0.079 is estimated base value #RealParameter("dev_rate_conv_HP",0.0125,0.0375),#0.01 is estimated base value RealParameter("discount_rate", 0.01, 0.15) ] #'base value' is 0.04. # specify outcomes model.outcomes = [ ArrayOutcome('value_vector'), ArrayOutcome('line_value'), ArrayOutcome('cost_vector'), ArrayOutcome('line_cost_vector'), ScalarOutcome('stopping_condition') ] ############################################################################## # Use small number of experiments to quickly test the model and EMA workbench. #experiments, outcomes = perform_experiments(model, 2) #Open exploration n_experiments = 800 with MultiprocessingEvaluator(model) as evaluator: results = evaluator.perform_experiments(n_experiments) save_results(results, f'./results/{n_experiments }experiments_300s_7%.tar.gz')
@author: Pedro """ from __future__ import (division, print_function, absolute_import, unicode_literals) from ema_workbench import (RealParameter, ScalarOutcome, ema_logging, perform_experiments) from ema_workbench.connectors.excel import ExcelModel if __name__ == "__main__": ema_logging.log_to_stderr(level=ema_logging.DEBUG) model = ExcelModel("excelModel", wd="./models", model_file= '/excelModel.xlsx') model.uncertainties = [RealParameter("B2", 0.04, 0.2), #we can refer to a cell in the normal way RealParameter("B3", 4000,6000), # we can also use named cells RealParameter("B4", 0.9,1.1), RealParameter("B5", 0.9,1.1)] #specification of the outcomes model.outcomes = [ScalarOutcome("B7")] # we can also use named range #name of the sheet model.sheet = "EMA" results = perform_experiments(model, 100, parallel=True, reporting_interval=1) print("blaat")
# initiate model model = Model(name='taxidriver', function=ema_experiment) # levers model.levers = [ RealParameter("startup_fee", 2, 5), RealParameter("km_fee", 0.2, 0.5), RealParameter("speed", 90, 130), ] # uncertainties model.uncertainties = [ RealParameter("distance", 3, 60), RealParameter("fuel_price", 1.1, 1.8), RealParameter("driver_salary_rate", 10, 20), ] # specify outcomes model.outcomes = [ ScalarOutcome("profit"), ScalarOutcome("fuel_use"), ScalarOutcome("time_spent"), ] # run experiments results = perform_experiments(model, scenarios=10, policies=3) # # save results # results_file_name = os.path.join(RESULT_FOLDER, f"cabelpooling_ema_results_{RUNID}.tar.gz") # save_results(results, file_name=results_file_name)
#a=[] #k=0 #l=0 #m=[] #n=1 #for k in range(len(dams)): #for i in range(12): #a=Constraint("Constraint_"+str(n),parameter_names=[dams[k][0][i],dams[k][1][i]],function=lambda x,y:max(0,-x+y)) #m.append(a) #n=n+1 #a=Constraint("Constraint_"+str(n),parameter_names=[dams[k][1][i],dams[k][2][i]],function=lambda x,y:max(0,-x+y)) #m.append(a) #n=n+1 basin_model.outcomes = [ ScalarOutcome('pwsshortageavg', kind=ScalarOutcome.MINIMIZE), ScalarOutcome('energyaverage', kind=ScalarOutcome.MAXIMIZE), ScalarOutcome('pwssum', kind=ScalarOutcome.MINIMIZE) ] convergence_metrics = [EpsilonProgress()] #with SequentialEvaluator(basin_model) as evaluator: #experiments, outcomes=evaluator.perform_experiments(policies=10)#constraints=constraints) with SequentialEvaluator(basin_model) as evaluator: #experiments, outcomes=evaluator.perform_experiments(scenarios=100) results, convergence = evaluator.optimize( nfe=100, searchover='levers', epsilons=[1, 1, 1], convergence=convergence_metrics,
RealParameter(name = 'Steam Pipe CAPEX (euro)', variable_name = 'CAPEX Steam Pipe:Price', lower_bound = 6.0*10**6, upper_bound = 12.0*10**6)] # define the levers (Power-to-X alternatives) model.levers = [BooleanParameter(name = 'E-boiler', variable_name = 'e_boiler'), BooleanParameter(name = 'Steam Pipe', variable_name = 'steam_pipe'), BooleanParameter(name = 'Chlorine Storage', variable_name = 'chlorine_storage')] # define the outcomes model.outcomes = [ScalarOutcome(name = 'Total cash flow of the cluster (euro/week)', variable_name = 'CF total', function = np.sum), ScalarOutcome(name = 'Total cash flow of Air Liquide (euro/week)', variable_name = 'CF Air Liquide', function = np.sum), ScalarOutcome(name = 'Total cash flow of Huntsman (euro/week)', variable_name = 'CF Huntsman', function = np.sum), ScalarOutcome(name = 'Total cash flow of Nouryon (euro/week)', variable_name = 'CF Nouryon', function = np.sum), ScalarOutcome(name = 'Total CO2 emissions (ton/week)', variable_name = 'CO2 emission', function = np.sum), ScalarOutcome(name = 'Total green steam use by Air Liquide and Huntsman (ton/week)', variable_name= 'Use SP-A',
lake_model = Model('lakeproblem', function=lake_problem) lake_model.time_horizon = 100 #specify uncertainties lake_model.uncertainties = [RealParameter('b', 0.1, 0.45), RealParameter('q', 2.0, 4.5), RealParameter('mean', 0.01, 0.05), RealParameter('stdev', 0.001, 0.005), RealParameter('delta', 0.93, 0.99)] # set levers, one for each time step lake_model.levers = [RealParameter(str(i), 0, 0.1) for i in range(lake_model.time_horizon)] #specify outcomes lake_model.outcomes = [ScalarOutcome('max_P',), ScalarOutcome('utility'), ScalarOutcome('inertia'), ScalarOutcome('reliability')] # override some of the defaults of the model lake_model.constants = [Constant('alpha', 0.41), Constant('nsamples', 150)] # generate sa single default no release policy policy = Policy('no release', **{str(i):0.1 for i in range(100)}) n_scenarios = 1000 with MultiprocessingEvaluator(lake_model) as evaluator:
RealParameter('fosslim', 4000.0, 13649), IntegerParameter('cback', 100, 600), RealParameter('emdd', -0.5, 0.99), ] dice_sm.levers = [RealParameter('sr', 0.1, 0.5), RealParameter('prtp_con', 0.001, 0.015), # RealParameter('prtp_dam', 0.001, 0.015), RealParameter('emuc', 1.01, 2.00), IntegerParameter('vd_switch', 0, 1), IntegerParameter('periodfullpart', 10, 58), IntegerParameter('miu_period', 10, 58) ] dice_sm.outcomes = [ ScalarOutcome('Atmospheric Temperature 2300', kind=ScalarOutcome.MINIMIZE), ScalarOutcome('Total Output 2300', kind=ScalarOutcome.MAXIMIZE), # ScalarOutcome('Per Capita Consumption 2300', kind=ScalarOutcome.INFO), # ScalarOutcome('Consumption Growth 2300', kind=ScalarOutcome.INFO), ScalarOutcome('Utility of Consumption 2300', kind=ScalarOutcome.MAXIMIZE), # ScalarOutcome('Per Capita Damage 2300', kind=ScalarOutcome.INFO), # ScalarOutcome('Damage Growth 2300', kind=ScalarOutcome.INFO), ScalarOutcome('Disutility of Damage 2300', kind=ScalarOutcome.MINIMIZE), ScalarOutcome('Welfare 2300', kind=ScalarOutcome.MAXIMIZE), # ScalarOutcome('Undiscounted Period Welfare 2300', kind=ScalarOutcome.INFO), ScalarOutcome('Consumption SDR 2300', kind=ScalarOutcome.INFO), ScalarOutcome('Damage SDR 2300', kind=ScalarOutcome.INFO) ] # %%
.. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl> ''' from __future__ import (absolute_import, print_function, division, unicode_literals) from ema_workbench import (Model, RealParameter, ScalarOutcome, ema_logging, perform_experiments) def some_model(x1=None, x2=None, x3=None): return {'y': x1 * x2 + x3} if __name__ == '__main__': ema_logging.LOG_FORMAT = '[%(name)s/%(levelname)s/%(processName)s] %(message)s' ema_logging.log_to_stderr(ema_logging.INFO) model = Model('simpleModel', function=some_model) # instantiate the model # specify uncertainties model.uncertainties = [ RealParameter("x1", 0.1, 10), RealParameter("x2", -0.01, 0.01), RealParameter("x3", -0.01, 0.01) ] # specify outcomes model.outcomes = [ScalarOutcome('y')] results = perform_experiments(model, 100)
def get_model_for_problem_formulation(problem_formulation_idea): disease_model = VensimModel("multidisease", wd=r'.\models', model_file='disease_model.vpm') disease_model.uncertainties = [ # Sanitation Unknowns IntegerParameter('desire for improved sanitation', 10, 100), # Water Supply Unknowns IntegerParameter('Cost of well repair', 660, 1800), # Water Quality Unknowns IntegerParameter('use HWT', 10, 100), # Hygiene Unknowns IntegerParameter('Intensity of hygiene campaign', 10, 100), # Vaccination Unknowns IntegerParameter('Reliability of vaccine supply', 10, 100), # Treatment Unknowns IntegerParameter('seeking treatment', 10, 100), # Other Unknowns IntegerParameter('percent willing to accept MDA', 10, 100), # RealParameter('Childbearing years', 9, 14), #N.B. huge impact ] disease_model.constants = [ Constant('Length latrine program', 10), Constant('Length GW supply program', 10), Constant('Length of water quality program', 10), Constant("Duration of hygiene campaign", 10), Constant("Length of ORT subsidy", 10), Constant("Years of MDA campaign", 10) ] disease_model.levers = [ # Sanitation Levers IntegerParameter("Number of new latrines to build", 0, 9000), IntegerParameter("Number of latrines to maintain", 0, 4000), # Water Supply Levers IntegerParameter("Number of new wells to drill", 0, 2000), IntegerParameter("Number of wells to repair", 0, 2000), # Water Quality Levers IntegerParameter("Availability HWT", 0, 100), # Hygiene Promotion Levers IntegerParameter("HW stations to build", 0, 8000), # Vaccination Levers IntegerParameter("percentage of infants to vaccinate", 0, 100), # Treatment Levers IntegerParameter("Access to tmt", 0, 100), # MDA levers IntegerParameter("percent adults given MDA", 0, 100), IntegerParameter("percent youth given Albendazole", 0, 100), ] # add policies disease_model.policies = [ Policy( 'LatrineProgram', **{ "Number of new latrines to build": 5000, "Number of latrines to maintain": 4000, "Length latrine program": 10, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 0, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), Policy( 'GWsupply', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 1000, "Number of wells to repair": 100, "Length GW supply program": 10, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 0, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), Policy( 'ORT', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 0, "Access to tmt": 100, "Length of ORT subsidy": 10, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), Policy( 'Hygiene', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 1000, "Duration of hygiene campaign": 10, "percentage of infants to vaccinate": 0, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), Policy( 'Vaccin', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 100, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), Policy( 'DrinkingWater', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 100, "Length of water quality program": 10, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 0, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), Policy( 'MDA', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 0, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 100, "percent youth given Albendazole": 100, "Years of MDA campaign": 10, }), Policy( 'DoNothing', **{ "Number of new latrines to build": 0, "Number of latrines to maintain": 0, "Length latrine program": 0, "Number of new wells to drill": 0, "Number of wells to repair": 0, "Length GW supply program": 0, "Availability HWT": 0, "Length of water quality program": 0, "HW stations to build": 0, "Duration of hygiene campaign": 0, "percentage of infants to vaccinate": 0, "Access to tmt": 0, "Length of ORT subsidy": 0, "percent adults given Albendazole": 0, "percent youth given Albendazole": 0, "Years of MDA campaign": 0, }), ] # Problem formulations: direction = ScalarOutcome.MINIMIZE if problem_formulation_idea == 1: ##PF1: Minimum child (<5 yo) deaths due to Rotavirus disease_model.name = 'Minimize Child <5 Rotavirus infections by 2030' disease_model.outcomes.clear() disease_model.outcomes = [ ScalarOutcome( 'Mortality', #Deaths due to Rotavirus variable_name=[ 'children under 5 deaths[Rota]', 'ts until 2020', 'ts at 2030' ], function=avg_over_period, kind=direction, expected_range=(10000, 250000)), ScalarOutcome( 'Morbidity', #Rota DALYs children variable_name=[ "Years Lost to Disability in Children[Rota]", 'ts until 2020', 'ts at 2030' ], function=avg_over_period, kind=direction, expected_range=(6000, 9000)), ScalarOutcome( 'Timeliness', #Delta child infections 2030 variable_name=[ "Number of Children Infected[Rota]", 'ts until 2020', 'ts at 2030' ], function=change_over_period, kind=direction, expected_range=(-0.9, 0.1)), ScalarOutcome( 'CapEx', variable_name=['Upfront Cost', 'ts until 2020', 'ts at 2040'], function=total_over_period, kind=direction, expected_range=(0, 3000000000000)), ScalarOutcome( 'OpEx', #Recurring Cost variable_name=[ 'Recurring Cost', 'ts until 2020', 'ts at 2040' ], function=total_over_period, kind=direction, expected_range=(0, 2000000000000)), ] elif problem_formulation_idea == 2: ##PF2: Minimum prevalence of ascariasis in Youth (Infants, PreSACs, and SACs) in 5 years disease_model.name = 'Minimize Ascariasis in Youth by 2025' disease_model.outcomes.clear() disease_model.outcomes = [ ScalarOutcome('Mortality', variable_name=[ 'Youth Mortality[Ascar]', 'ts until 2020', 'ts at 2025' ], function=avg_over_period, kind=direction, expected_range=(1000, 20000)), ScalarOutcome('Morbidity', variable_name=[ 'Years Lost to Disability in Youth[Ascar]', 'ts until 2020', 'ts at 2025' ], function=avg_over_period, kind=direction, expected_range=(20000, 160000)), ScalarOutcome( 'Timeliness', #Change in prevalence of ascariasis in youth by 2025 variable_name=[ 'Number of Youth Infected[Ascar]', 'ts until 2020', 'ts at 2025' ], function=change_over_period, kind=direction, expected_range=(-1, 0)), ScalarOutcome( 'CapEx', #Upfront Cost variable_name=['Upfront Cost', 'ts until 2020', 'ts at 2040'], function=total_over_period, kind=direction, expected_range=(0, 3000000000000)), ScalarOutcome( 'OpEx', #Recurring Cost variable_name=[ 'Recurring Cost', 'ts until 2020', 'ts at 2040' ], function=total_over_period, kind=direction, expected_range=(0, 2000000000000)), ] elif problem_formulation_idea == 3: #PF3: Minimum Child (<5 yo) mortality, all diseases, w/in one year disease_model.name = 'Immediately minimize Child <5 burden from all causes' disease_model.outcomes.clear() disease_model.outcomes = [ ScalarOutcome('Mortality', variable_name=[ 'Total children under 5 deaths', 'ts until 2020', 'ts at 2021' ], function=avg_over_period, kind=direction, expected_range=(50000, 400000)), ScalarOutcome('Morbidity', variable_name=[ 'morbidity in children', 'ts until 2020', 'ts at 2021' ], function=avg_over_period, kind=direction, expected_range=(40000, 100000)), ScalarOutcome( 'Timeliness', #Delta child infections 2021 variable_name=[ 'Total children w gastroenteric infection', 'ts until 2020', 'ts at 2021' ], function=change_over_period, kind=direction, expected_range=(-0.5, 0)), ScalarOutcome( 'CapEx', #Upfront Cost variable_name=['Upfront Cost', 'ts until 2020', 'ts at 2040'], function=total_over_period, kind=direction, expected_range=(5000000, 3000000000000)), ScalarOutcome( 'OpEx', #Recurring Cost variable_name=[ 'Recurring Cost', 'ts until 2020', 'ts at 2040' ], #bc no rec cost will show up in 1 yr function=total_over_period, kind=direction, expected_range=(50000000000, 2000000000000)), ] elif problem_formulation_idea == 4: #PF4: Minimum number infected, all diseases, sustainably disease_model.name = 'Minimize number infected all diseases by 2040' disease_model.outcomes.clear() disease_model.outcomes = [ ScalarOutcome('Mortality', variable_name=[ 'Total lives lost', 'ts until 2020', 'ts at 2040' ], function=avg_over_period, kind=direction, expected_range=(50000, 250000)), ScalarOutcome('Morbidity', variable_name=[ 'disability burden', 'ts until 2020', 'ts at 2040' ], function=avg_over_period, kind=direction, expected_range=(100000, 900000)), ScalarOutcome( 'Timeliness', #delta infections 2040 variable_name=[ 'Total number of gastroenteric infection', 'ts until 2020', 'ts at 2040' ], function=change_over_period, kind=direction, expected_range=(-1, -.45)), ScalarOutcome( 'CapEx', #Upfront Cost variable_name=['Upfront Cost', 'ts until 2020', 'ts at 2040'], function=total_over_period, kind=direction, expected_range=(20000000000, 3000000000000)), ScalarOutcome( 'OpEx', #Recurring Cost variable_name=[ 'Recurring Cost', 'ts until 2020', 'ts at 2040' ], function=total_over_period, kind=direction, expected_range=(20000000000, 2000000000000)), ##recurring costs divided by 20 years ] else: raise TypeError('unknown problem identifier') return disease_model
density = cum / replications return {'density': density} if __name__ == '__main__': ema_logging.LOG_FORMAT = '[%(name)s/%(levelname)s/%(processName)s] %(message)s' ema_logging.log_to_stderr(ema_logging.INFO) model = Model('SimulateER', function=simulate_ER) # instantiate the model # specify uncertainties model.uncertainties = [RealParameter("p", 0.1, 1.0)] model.levers = [IntegerParameter("n", 10, 100)] # specify outcomes model.outcomes = [ScalarOutcome('density')] model.constants = [Constant('replications', 10)] n_scenarios = 10 n_policies = 10 res = perform_experiments(model, n_scenarios, n_policies) """ with MultiprocessingEvaluator(model) as evaluator: res = evaluator.perform_experiments(n_scenarios, n_policies, levers_sampling=MC) """ experiments, outcomes = res data = experiments[['n', 'p']] data.to_csv('outExperiment.csv', index=False)
# specify uncertainties lake_model.uncertainties = [RealParameter('b', 0.1, 0.45), RealParameter('q', 2.0, 4.5), RealParameter('mean', 0.01, 0.05), RealParameter('stdev', 0.001, 0.005), RealParameter('delta', 0.93, 0.99)] # set levers lake_model.levers = [RealParameter("c1", -2, 2), RealParameter("c2", -2, 2), RealParameter("r1", 0, 2), RealParameter("r2", 0, 2), CategoricalParameter("w1", np.linspace(0, 1, 10)) ] # specify outcomes lake_model.outcomes = [ScalarOutcome('max_P', kind=ScalarOutcome.MINIMIZE), # @UndefinedVariable ScalarOutcome('utility', kind=ScalarOutcome.MAXIMIZE), # @UndefinedVariable ScalarOutcome('inertia', kind=ScalarOutcome.MAXIMIZE), # @UndefinedVariable ScalarOutcome('reliability', kind=ScalarOutcome.MAXIMIZE)] # @UndefinedVariable # override some of the defaults of the model lake_model.constants = [Constant('alpha', 0.41), Constant('nsamples', 100), Constant('myears', 100)] # reference is optional, but can be used to implement search for # various user specified scenarios along the lines suggested by # Watson and Kasprzyk (2017)
IntegerParameter('scenario_pop_tfp', 0, 5), IntegerParameter('scenario_sigma', 0, 5), IntegerParameter('scenario_cback', 0, 2), IntegerParameter('cback_to_zero', 0, 1), RealParameter('fosslim', 4000.0, 13649), RealParameter('limmiu', 0.8, 1.2) ] RICE.levers = [ RealParameter('sr', 0.1, 0.5), RealParameter('irstp', 0.001, 0.015), IntegerParameter('miu_period', 5, 30) ] RICE.outcomes = [ ScalarOutcome('Damages 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2055', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2105', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2155', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2205', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2305', ScalarOutcome.MAXIMIZE), ScalarOutcome('Total Aggregated Utility', ScalarOutcome.MAXIMIZE) ] epsilon_list = [0.01] eps = []
return timing if __name__ == '__main__': ema_logging.log_to_stderr(ema_logging.INFO) model = VensimModel("fluCase", wd=r'./models/flu', model_file=r'/FLUvensimV1basecase.vpm') #outcomes model.outcomes = [ TimeSeriesOutcome('deceased population region 1'), TimeSeriesOutcome('infected fraction R1'), ScalarOutcome('max infection fraction', variable_name='infected fraction R1', function=np.max), ScalarOutcome('time of max', variable_name=['infected fraction R1', 'TIME'], function=time_of_max) ] #create uncertainties based on csv model.uncertainties = create_parameters( './models/flu/flu_uncertainties.csv') #add policies policies = [ Policy('no policy', model_file=r'/FLUvensimV1basecase.vpm'), Policy('static policy', model_file=r'/FLUvensimV1static.vpm'), Policy('adaptive policy', model_file=r'/FLUvensimV1dynamic.vpm')
from ema_workbench.em_framework.parameters import Policy from ema_workbench.connectors.vensim import VensimModel if __name__ == '__main__': ema_logging.log_to_stderr(ema_logging.INFO) model = VensimModel("fluCase", wd=r'./models/flu', model_file=r'FLUvensimV1basecase.vpm') #outcomes model.outcomes = [ TimeSeriesOutcome('deceased population region 1'), TimeSeriesOutcome('infected fraction R1'), ScalarOutcome('max infection fraction', variable_name='infected fraction R1', function=np.max) ] #Plain Parametric Uncertainties model.uncertainties = [ RealParameter('additional seasonal immune population fraction R1', 0, 0.5), RealParameter('additional seasonal immune population fraction R2', 0, 0.5), RealParameter('fatality ratio region 1', 0.0001, 0.1), RealParameter('fatality rate region 2', 0.0001, 0.1), RealParameter('initial immune fraction of the population of region 1', 0, 0.5), RealParameter('initial immune fraction of the population of region 2', 0, 0.5),
RealParameter('Base Societal Stress Coefficient Medical Care I', 0.05, 0.1), RealParameter('Base Effort Coefficient Medical Care I', 1, 4), RealParameter('Implementation Time Medical Care I', 5, 20), RealParameter('Duration Medical Care I', 14, 60), RealParameter('Base Transmission Coefficient Medical Care II', 0.83, 0.9), RealParameter('Base Recovery Coefficient Medical Care II', 0.7, 0.98), RealParameter('Base Societal Stress Coefficient Medical Care II', 0.05, 0.1), RealParameter('Base Effort Coefficient Medical Care II', 4, 8), RealParameter('Implementation Time Medical Care II', 20, 40), RealParameter('Duration Medical Care II', 14, 60), ] outcomes = [ ScalarOutcome('Deceased population'), ScalarOutcome('Infectious population'), ScalarOutcome('Stock Total Effort'), ScalarOutcome('Stock Societal Stress') ] robustness = [ ScalarOutcome('Deceased population', kind=ScalarOutcome.MINIMIZE, function=np.max), ScalarOutcome('Infectious population', kind=ScalarOutcome.MINIMIZE, function=np.mean), ScalarOutcome('Stock Total Effort', kind=ScalarOutcome.MINIMIZE, function=np.max),
ema_logging.log_to_stderr(ema_logging.INFO) model = Model('omegaDriver', function=omegaDriver) # instantiate the model # specify uncertainties model.uncertainties = [ RealParameter("SCUDB.targetRange", 100000.0, 200000.0), RealParameter("SCUDB.targetAltitude", 15000.0, 20000.0) ] model.levers = [ RealParameter("SCUDB.MassProperties.initialMass", 5000.0, 6000.0) ] model.outcomes = [ ScalarOutcome('burnout'), ScalarOutcome('impact'), ScalarOutcome('apogeeAlt'), ScalarOutcome('apogeeTime') ] #model.constants = [Constant('replications', 10)] n_contextScenarios = 10 n_designPolicies = 10 res = perform_experiments(model, n_contextScenarios, n_designPolicies, levers_sampling=LHS)
lake_model.uncertainties = [RealParameter('b', 0.1, 0.45), RealParameter('q', 2.0, 4.5), RealParameter('mean', 0.01, 0.05), RealParameter('stdev', 0.001, 0.005), RealParameter('delta', 0.93, 0.99)] # set levers lake_model.levers = [RealParameter("c1", -2, 2), RealParameter("c2", -2, 2), RealParameter("r1", 0, 2), RealParameter("r2", 0, 2), RealParameter("w1", 0, 1) ] # specify outcomes lake_model.outcomes = [ScalarOutcome('max_P'), ScalarOutcome('utility'), ScalarOutcome('inertia'), ScalarOutcome('reliability')] # override some of the defaults of the model lake_model.constants = [Constant('alpha', 0.41), Constant('nsamples', 100), Constant('myears', 100)] # setup and execute the robust optimization def signal_to_noise(data): mean = np.mean(data) std = np.std(data) sn = mean/std return sn
def get_all_model_outcomes_uncertainty_search( optimization_formulation="utilitarian"): if optimization_formulation == "utilitarian": outcomes = [ ScalarOutcome('Intratemporal utility GINI 2055', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2055', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2105', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2105', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2155', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2155', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2205', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2205', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2305', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2305', ScalarOutcome.INFO), ScalarOutcome('Intertemporal utility GINI', ScalarOutcome.INFO), ScalarOutcome('Intertemporal impact GINI', ScalarOutcome.INFO), ScalarOutcome('Damages 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2055', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2105', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2155', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2205', ScalarOutcome.MAXIMIZE), ScalarOutcome('Damages 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Utility 2305', ScalarOutcome.MAXIMIZE), ScalarOutcome('Total Aggregated Utility', ScalarOutcome.MAXIMIZE), ScalarOutcome('Lowest income per capita 2055', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2055', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2105', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2105', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2155', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2155', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2205', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2205', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2305', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2055', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2055', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2105', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2105', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2155', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2155', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2205', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2205', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2055', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2055', ScalarOutcome.INFO), ScalarOutcome('Total Output 2055', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2105', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2105', ScalarOutcome.INFO), ScalarOutcome('Total Output 2105', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2205', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2205', ScalarOutcome.INFO), ScalarOutcome('Total Output 2205', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2305', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2305', ScalarOutcome.INFO), ScalarOutcome('Total Output 2305', ScalarOutcome.INFO), ] if optimization_formulation == "sufficitarian": outcomes = [ ScalarOutcome('Intratemporal utility GINI 2055', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2055', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2105', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2105', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2155', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2155', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2205', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2205', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2305', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2305', ScalarOutcome.INFO), ScalarOutcome('Intertemporal utility GINI', ScalarOutcome.INFO), ScalarOutcome('Intertemporal impact GINI', ScalarOutcome.INFO), ScalarOutcome('Damages 2055', ScalarOutcome.INFO), ScalarOutcome('Utility 2055', ScalarOutcome.INFO), ScalarOutcome('Damages 2105', ScalarOutcome.INFO), ScalarOutcome('Utility 2105', ScalarOutcome.INFO), ScalarOutcome('Damages 2155', ScalarOutcome.INFO), ScalarOutcome('Utility 2155', ScalarOutcome.INFO), ScalarOutcome('Damages 2205', ScalarOutcome.INFO), ScalarOutcome('Utility 2205', ScalarOutcome.INFO), ScalarOutcome('Damages 2305', ScalarOutcome.INFO), ScalarOutcome('Utility 2305', ScalarOutcome.INFO), ScalarOutcome('Total Aggregated Utility', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2055', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2055', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2105', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2105', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2155', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2155', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2205', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2205', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2305', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Population under treshold 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Atmospheric Temperature 2055', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2055', ScalarOutcome.INFO), ScalarOutcome('Total Output 2055', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2105', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2105', ScalarOutcome.INFO), ScalarOutcome('Total Output 2105', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2205', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2205', ScalarOutcome.INFO), ScalarOutcome('Total Output 2205', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2305', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2305', ScalarOutcome.INFO), ScalarOutcome('Total Output 2305', ScalarOutcome.INFO), ] if optimization_formulation == "prioritarian": outcomes = [ ScalarOutcome('Intratemporal utility GINI 2055', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2055', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2105', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2105', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2155', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2155', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2205', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2205', ScalarOutcome.INFO), ScalarOutcome('Intratemporal utility GINI 2305', ScalarOutcome.INFO), ScalarOutcome('Intratemporal impact GINI 2305', ScalarOutcome.INFO), ScalarOutcome('Intertemporal utility GINI', ScalarOutcome.INFO), ScalarOutcome('Intertemporal impact GINI', ScalarOutcome.INFO), ScalarOutcome('Damages 2055', ScalarOutcome.INFO), ScalarOutcome('Utility 2055', ScalarOutcome.INFO), ScalarOutcome('Damages 2105', ScalarOutcome.INFO), ScalarOutcome('Utility 2105', ScalarOutcome.INFO), ScalarOutcome('Damages 2155', ScalarOutcome.INFO), ScalarOutcome('Utility 2155', ScalarOutcome.INFO), ScalarOutcome('Damages 2205', ScalarOutcome.INFO), ScalarOutcome('Utility 2205', ScalarOutcome.INFO), ScalarOutcome('Damages 2305', ScalarOutcome.INFO), ScalarOutcome('Utility 2305', ScalarOutcome.INFO), ScalarOutcome('Total Aggregated Utility', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2055', ScalarOutcome.MAXIMIZE), ScalarOutcome('Highest climate impact per capita 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Lowest income per capita 2105', ScalarOutcome.MAXIMIZE), ScalarOutcome('Highest climate impact per capita 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Lowest income per capita 2155', ScalarOutcome.MAXIMIZE), ScalarOutcome('Highest climate impact per capita 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Lowest income per capita 2205', ScalarOutcome.MAXIMIZE), ScalarOutcome('Highest climate impact per capita 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Lowest income per capita 2305', ScalarOutcome.MAXIMIZE), ScalarOutcome('Highest climate impact per capita 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Distance to treshold 2055', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2055', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2105', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2105', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2155', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2155', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2205', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2205', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2055', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2055', ScalarOutcome.INFO), ScalarOutcome('Total Output 2055', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2105', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2105', ScalarOutcome.INFO), ScalarOutcome('Total Output 2105', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2205', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2205', ScalarOutcome.INFO), ScalarOutcome('Total Output 2205', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2305', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2305', ScalarOutcome.INFO), ScalarOutcome('Total Output 2305', ScalarOutcome.INFO), ] if optimization_formulation == "egalitarian": outcomes = [ ScalarOutcome('Intratemporal utility GINI 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2055', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal utility GINI 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2105', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal utility GINI 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2155', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal utility GINI 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2205', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal utility GINI 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Intratemporal impact GINI 2305', ScalarOutcome.MINIMIZE), ScalarOutcome('Intertemporal utility GINI', ScalarOutcome.MINIMIZE), ScalarOutcome('Intertemporal impact GINI', ScalarOutcome.MINIMIZE), ScalarOutcome('Damages 2055', ScalarOutcome.INFO), ScalarOutcome('Utility 2055', ScalarOutcome.INFO), ScalarOutcome('Damages 2105', ScalarOutcome.INFO), ScalarOutcome('Utility 2105', ScalarOutcome.INFO), ScalarOutcome('Damages 2155', ScalarOutcome.INFO), ScalarOutcome('Utility 2155', ScalarOutcome.INFO), ScalarOutcome('Damages 2205', ScalarOutcome.INFO), ScalarOutcome('Utility 2205', ScalarOutcome.INFO), ScalarOutcome('Damages 2305', ScalarOutcome.INFO), ScalarOutcome('Utility 2305', ScalarOutcome.INFO), ScalarOutcome('Total Aggregated Utility', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2055', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2055', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2105', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2105', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2155', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2155', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2205', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2205', ScalarOutcome.INFO), ScalarOutcome('Lowest income per capita 2305', ScalarOutcome.INFO), ScalarOutcome('Highest climate impact per capita 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2055', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2055', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2105', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2105', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2155', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2155', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2205', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2205', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Distance to treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Population under treshold 2305', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2055', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2055', ScalarOutcome.INFO), ScalarOutcome('Total Output 2055', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2105', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2105', ScalarOutcome.INFO), ScalarOutcome('Total Output 2105', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2205', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2205', ScalarOutcome.INFO), ScalarOutcome('Total Output 2205', ScalarOutcome.INFO), ScalarOutcome('Atmospheric Temperature 2305', ScalarOutcome.INFO), ScalarOutcome('Industrial Emission 2305', ScalarOutcome.INFO), ScalarOutcome('Total Output 2305', ScalarOutcome.INFO), ] return outcomes
RealParameter('stdev', 0.001, 0.005), RealParameter('delta', 0.93, 0.99) ] # set levers lake_model.levers = [ RealParameter("c1", -2, 2), RealParameter("c2", -2, 2), RealParameter("r1", 0, 2), RealParameter("r2", 0, 2), RealParameter("w1", 0, 1) ] # specify outcomes lake_model.outcomes = [ ScalarOutcome('max_P'), ScalarOutcome('utility'), ScalarOutcome('inertia'), ScalarOutcome('reliability') ] # override some of the defaults of the model lake_model.constants = [ Constant('alpha', 0.41), Constant('nsamples', 100), Constant('myears', 100) ] # setup and execute the robust optimization def signal_to_noise(data): mean = np.mean(data)