예제 #1
0
                        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')
    ]

    results = perform_experiments(model,
                                  1000,
                                  policies=policies,
                                  parallel=True)
    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')
                ]

    with MultiprocessingEvaluator(model, 2) as evaluator:
        results = perform_experiments(model, 1000, policies=policies,
                                      evaluator == evaluator)