def make_sim(seed,
             beta,
             calibration=True,
             future_symp_test=None,
             scenario=None,
             end_day='2021-10-30',
             verbose=0):

    # Set the parameters
    #total_pop    = 67.86e6 # UK population size
    total_pop = 55.98e6  # UK population size
    pop_size = 100e3  # Actual simulated population
    pop_scale = int(total_pop / pop_size)
    pop_type = 'hybrid'
    pop_infected = 1000
    beta = beta
    asymp_factor = 2
    contacts = {'h': 3.0, 's': 20, 'w': 20, 'c': 20}
    beta_layer = {'h': 3.0, 's': 1.0, 'w': 0.6, 'c': 0.3}
    if end_day is None: end_day = '2021-05-05'

    pars = sc.objdict(
        use_waning=True,
        pop_size=pop_size,
        pop_infected=pop_infected,
        pop_scale=pop_scale,
        pop_type=pop_type,
        start_day=start_day,
        end_day=end_day,
        beta=beta,
        asymp_factor=asymp_factor,
        contacts=contacts,
        rescale=True,
        rand_seed=seed,
        verbose=verbose,
        rel_symp_prob=1.0,
        rel_severe_prob=0.9,
        rel_crit_prob=1.4,
        rel_death_prob=1.2,
    )

    sim = cv.Sim(pars=pars, datafile=data_path, location='uk')
    #sim['prognoses']['sus_ORs'][0] = 0.5 # ages 20-30
    #sim['prognoses']['sus_ORs'][1] = 1.0 # ages 20-30

    # ADD BETA INTERVENTIONS
    sbv = 0.63
    beta_past = sc.odict({
        '2020-02-14': [1.00, 1.00, 0.90, 0.90],
        '2020-03-16': [1.00, 0.90, 0.80, 0.80],
        '2020-03-23': [1.29, 0.02, 0.20, 0.20],
        '2020-06-01': [1.00, 0.23, 0.40, 0.40],
        '2020-06-15': [1.00, 0.38, 0.50, 0.50],
        '2020-07-22': [1.29, 0.00, 0.30, 0.50],
        '2020-09-02': [1.25, sbv, 0.50, 0.70],
        '2020-10-01': [1.25, sbv, 0.50, 0.70],
        '2020-10-16': [1.25, sbv, 0.50, 0.70],
        '2020-10-26': [1.00, 0.00, 0.50, 0.70],
        '2020-11-05': [1.25, sbv, 0.30, 0.40],
        '2020-11-14': [1.25, sbv, 0.30, 0.40],
        '2020-11-21': [1.25, sbv, 0.30, 0.40],
        '2020-11-30': [1.25, sbv, 0.30, 0.40],
        '2020-12-03': [1.50, sbv, 0.50, 0.70],
        '2020-12-20': [1.25, 0.00, 0.20, 0.40],
        '2020-12-25': [1.50, 0.00, 0.20, 0.40],
        '2020-12-26': [1.50, 0.00, 0.20, 0.40],
        '2020-12-31': [1.50, 0.00, 0.20, 0.40],
        '2021-01-01': [1.50, 0.00, 0.20, 0.40],
        '2021-01-04': [1.25, 0.14, 0.30, 0.40],
        '2021-01-11': [1.25, 0.14, 0.30, 0.40],
        '2021-01-18': [1.25, 0.14, 0.30, 0.40],
        '2021-01-30': [1.25, 0.14, 0.30, 0.40],
        '2021-02-08': [1.25, 0.14, 0.30, 0.40],
        '2021-02-15': [1.25, 0.14, 0.30, 0.40],
        '2021-02-22': [1.25, 0.14, 0.30, 0.40],
        '2021-03-08': [1.25, sbv, 0.30, 0.50],
        '2021-03-15': [1.25, sbv, 0.30, 0.50],
        '2021-03-22': [1.25, sbv, 0.30, 0.50],
        '2021-03-29': [1.25, 0.00, 0.30, 0.50],
        '2021-04-05': [1.25, 0.00, 0.30, 0.50],
        '2021-04-12': [1.25, 0.00, 0.40, 0.50],
        '2021-04-19': [1.25, sbv, 0.40, 0.50],
        '2021-04-26': [1.25, sbv, 0.40, 0.50],
        '2021-05-03': [1.25, sbv, 0.40, 0.50],
        '2021-05-10': [1.25, sbv, 0.40, 0.50],
        '2021-05-17': [1.15, sbv, 0.40, 0.60],
        '2021-05-21': [1.15, sbv, 0.40, 0.60],
        '2021-05-28': [1.15, 0.00, 0.40, 0.60],
        '2021-06-07': [1.15, sbv, 0.40, 0.60],
        '2021-06-14': [1.15, sbv, 0.40, 0.60],
        '2021-06-19': [1.15, sbv, 0.40, 0.60],
        '2021-06-21': [1.25, sbv, 0.40, 0.70],
        '2021-06-28': [1.25, sbv, 0.40, 0.70],
        '2021-07-05': [1.25, sbv, 0.40, 0.70],
        '2021-07-12': [1.25, sbv, 0.40, 0.70],
        '2021-07-19': [1.25, 0.00, 0.50, 0.80],
        '2021-07-26': [1.25, 0.00, 0.50, 0.80],
        '2021-08-02': [1.25, 0.00, 0.50, 0.80],
        '2021-08-16': [1.25, 0.00, 0.50, 0.80],
        '2021-09-01': [1.25, 0.63, 0.70, 0.90],
        '2021-09-15': [1.25, 0.63, 0.70, 0.90],
        '2021-09-29': [1.25, 0.63, 0.70, 0.90],
        '2021-10-13': [1.25, 0.63, 0.70, 0.90],
        '2021-10-22': [1.25, 0.02, 0.50, 0.90],
        '2021-11-01': [1.25, 0.63, 0.70, 0.90],
        '2021-11-08': [1.25, 0.63, 0.70, 0.90],
        '2021-11-15': [1.25, 0.63, 0.70, 0.90],
        '2021-11-22': [1.25, 0.63, 0.70, 0.90],
        '2021-12-01': [1.25, 0.63, 0.70, 0.90],
        #'2021-06-21': [1.25, sbv, 0.70, 0.90],
        #'2021-06-28': [1.25, sbv, 0.70, 0.90],
        #'2021-07-05': [1.25, sbv, 0.70, 0.90],
        #'2021-07-12': [1.25, sbv, 0.70, 0.90],
        #'2021-07-19': [1.25, 0.00, 0.70, 0.90],
        #'2021-07-26': [1.25, 0.00, 0.70, 0.90],
        #'2021-08-02': [1.25, 0.00, 0.70, 0.90],
        #'2021-08-16': [1.25, 0.00, 0.70, 0.90],
    })

    if not calibration:
        ##no schools until 8th March but assue 20% (1 in 5) in schools between 04/01-22/02;
        ##model transmission remaining at schools as 14% (to account for 30% reduction due to school measures)
        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April,
        ## society some more (stage 3) 17th May and everything (stage 4) 21st June 2021.
        ## Projecting until end of 2021.
        if scenario == 'Roadmap_All':

            beta_scens = sc.odict({
                '2021-06-21': [1.25, sbv, 0.70, 0.90],
                '2021-06-28': [1.25, sbv, 0.70, 0.90],
                '2021-07-05': [1.25, sbv, 0.70, 0.90],
                '2021-07-12': [1.25, sbv, 0.70, 0.90],
                '2021-07-19': [1.25, 0.00, 0.70, 0.90],
                '2021-07-26': [1.25, 0.00, 0.70, 0.90],
                '2021-08-02': [1.25, 0.00, 0.70, 0.90],
                '2021-08-16': [1.25, 0.00, 0.70, 0.90],
                '2021-09-01': [1.25, 0.63, 0.70, 0.90],
                '2021-09-15': [1.25, 0.63, 0.70, 0.90],
                '2021-09-29': [1.25, 0.63, 0.70, 0.90],
                '2021-10-13': [1.25, 0.63, 0.70, 0.90],
                '2021-10-22': [1.25, 0.02, 0.50, 0.90],
                '2021-11-01': [1.25, 0.63, 0.70, 0.90],
                '2021-11-08': [1.25, 0.63, 0.70, 0.90],
                '2021-11-23': [1.25, 0.63, 0.70, 0.90],
                '2021-11-30': [1.25, 0.63, 0.70, 0.90],
                '2021-12-07': [1.25, 0.63, 0.70, 0.90],
                '2021-12-20': [1.25, 0.02, 0.50, 0.80],
                '2022-01-05': [1.25, 0.63, 0.70, 0.90],
            })

        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April ONLY
        ## NO (stage 3) 17th May and NO stage 4 21st June 2021.
        ## Projecting until end of 2021.
        #elif scenario == 'Roadmap_Stage2':

        #beta_scens = sc.odict({'2021-04-12': [1.25, 0.02, 0.40, 0.70],
        #                   '2021-04-19': [1.25, sbv, 0.40, 0.70],
        #                   '2021-04-26': [1.25, sbv, 0.40, 0.70],
        #                   '2021-05-03': [1.25, sbv, 0.40, 0.70],
        #                   '2021-05-10': [1.25, sbv, 0.40, 0.70],
        #                   '2021-05-17': [1.25, sbv, 0.40, 0.70],
        #                   '2021-05-21': [1.25, sbv, 0.40, 0.70],
        #                   '2021-05-28': [1.25, 0.02, 0.40, 0.70],
        #                   '2021-06-07': [1.25, sbv, 0.40, 0.70],
        #                   '2021-06-21': [1.25, sbv, 0.40, 0.70],
        #                   '2021-06-28': [1.25, sbv, 0.40, 0.70],
        #                   '2021-07-05': [1.25, sbv, 0.40, 0.70],
        #                   '2021-07-12': [1.25, sbv, 0.40, 0.70],
        #                   '2021-07-19': [1.25, 0.00, 0.40, 0.70],
        #                   '2021-07-26': [1.25, 0.00, 0.40, 0.70],
        #                   '2021-08-02': [1.25, 0.00, 0.40, 0.70],
        #                   '2021-08-16': [1.25, 0.00, 0.40, 0.70],
        #                   '2021-09-01': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-09-15': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-09-29': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-10-13': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-10-27': [1.25, 0.02, 0.70, 0.90],
        #                   '2021-11-08': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-11-23': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-11-30': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-12-07': [1.25, 0.63, 0.70, 0.90],
        #                   '2021-12-21': [1.25, 0.63, 0.70, 0.90],
        #                  })
        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April,
        ## and society some more (stage 3) 17th May but NO stage 4 21st June 2021.
        ## Projecting until end of 2021.
        elif scenario == 'Roadmap_Stage3':
            beta_scens = sc.odict({
                '2021-06-21': [1.25, sbv, 0.40, 0.60],
                '2021-06-28': [1.25, sbv, 0.40, 0.60],
                '2021-07-05': [1.25, sbv, 0.40, 0.60],
                '2021-07-12': [1.25, sbv, 0.40, 0.60],
                '2021-07-19': [1.25, 0.00, 0.50, 0.80],
                '2021-07-26': [1.25, 0.00, 0.50, 0.80],
                '2021-08-02': [1.25, 0.00, 0.50, 0.80],
                '2021-08-16': [1.25, 0.00, 0.50, 0.80],
                '2021-09-01': [1.25, 0.63, 0.70, 0.90],
                '2021-09-15': [1.25, 0.63, 0.70, 0.90],
                '2021-09-29': [1.25, 0.63, 0.70, 0.90],
                '2021-10-13': [1.25, 0.63, 0.70, 0.90],
                '2021-10-22': [1.25, 0.02, 0.50, 0.90],
                '2021-11-01': [1.25, 0.63, 0.70, 0.90],
                '2021-11-08': [1.25, 0.63, 0.70, 0.90],
                '2021-11-23': [1.25, 0.63, 0.70, 0.90],
                '2021-11-30': [1.25, 0.63, 0.70, 0.90],
                '2021-12-07': [1.25, 0.63, 0.70, 0.90],
                '2021-12-20': [1.25, 0.02, 0.50, 0.80],
                '2022-01-05': [1.25, 0.63, 0.70, 0.90],
            })
        beta_dict = sc.mergedicts(beta_past, beta_scens)
    else:
        beta_dict = beta_past

    beta_days = list(beta_dict.keys())
    h_beta = cv.change_beta(days=beta_days,
                            changes=[c[0] for c in beta_dict.values()],
                            layers='h')
    s_beta = cv.change_beta(days=beta_days,
                            changes=[c[1] for c in beta_dict.values()],
                            layers='s')
    w_beta = cv.change_beta(days=beta_days,
                            changes=[c[2] for c in beta_dict.values()],
                            layers='w')
    c_beta = cv.change_beta(days=beta_days,
                            changes=[c[3] for c in beta_dict.values()],
                            layers='c')

    # Add B.1.117 strain
    b117 = cv.variant('b117',
                      days=np.arange(sim.day('2020-08-01'),
                                     sim.day('2020-08-10')),
                      n_imports=500)
    b117.p['rel_beta'] = 1.5
    b117.p['rel_crit_prob'] = 1.3
    b117.p['rel_death_prob'] = 1.6
    b117.p['rel_severe_prob'] = 0.3
    sim['variants'] += [b117]
    # Add B.1.1351 strain
    b1351 = cv.variant('b1351',
                       days=np.arange(sim.day('2020-01-10'),
                                      sim.day('2020-01-20')),
                       n_imports=500)
    b1351.p['rel_beta'] = 1.0
    b1351.p['rel_death_prob'] = 1.0
    b1351.p['rel_severe_prob'] = 1.0
    sim['variants'] += [b1351]
    # Add B.X.XXX strain starting middle of March
    custom_strain = cv.variant(label='delta',
                               variant=cvp.get_variant_pars()['p1'],
                               days=np.arange(sim.day('2021-03-17'),
                                              sim.day('2021-03-24')),
                               n_imports=2000)
    custom_strain.p['rel_beta'] = 2.2
    custom_strain.p['rel_crit_prob'] = 1.3
    custom_strain.p['rel_death_prob'] = 1.1
    custom_strain.p['rel_severe_prob'] = 1.0
    sim['variants'] += [custom_strain]
    # seems like we need to do this to deal with cross immunity?
    sim.initialize()
    sim['immunity']
    prior = {'wild': 0.8, 'b117': 0.8, 'b1351': 0.8, 'delta': 0.8}
    pre = {'wild': 0.8, 'b117': 0.8, 'b1351': 0.8, 'delta': 0.8}
    for k, v in sim['variant_map'].items():
        if v == 'delta':
            for j, j_lab in sim['variant_map'].items():
                sim['immunity'][k][j] = prior[j_lab]
                sim['immunity'][j][k] = pre[j_lab]
                #if j != k:
                #    sim['immunity'][k][j] = cross_immunities['b117'][j_lab]
                #    sim['immunity'][j][k] = cross_immunities[j_lab]['b117']
    # # Add a new change in beta to represent the takeover of the novel variant VOC B117 202012/01
    # # Assume that the new variant is 60% more transmisible (https://cmmid.github.io/topics/covid19/uk-novel-variant.html,
    # # Assume that between Nov 1 and Jan 30, the new variant grows from 0-100% of cases

    interventions = [h_beta, w_beta, s_beta, c_beta]

    # ADD TEST AND TRACE INTERVENTIONS
    tc_day = sim.day(
        '2020-03-16'
    )  #intervention of some testing (tc) starts on 16th March and we run until 1st April when it increases
    te_day = sim.day(
        '2020-04-01'
    )  #intervention of some testing (te) starts on 1st April and we run until 1st May when it increases
    tt_day = sim.day(
        '2020-05-01'
    )  #intervention of increased testing (tt) starts on 1st May
    tti_day = sim.day(
        '2020-06-01'
    )  #intervention of tracing and enhanced testing (tti) starts on 1st June
    tti_day_july = sim.day(
        '2020-07-01'
    )  #intervention of tracing and enhanced testing (tti) at different levels starts on 1st July
    tti_day_august = sim.day(
        '2020-08-01'
    )  #intervention of tracing and enhanced testing (tti) at different levels starts on 1st August
    tti_day_sep = sim.day('2020-09-01')
    tti_day_oct = sim.day('2020-10-01')
    tti_day_nov = sim.day('2020-11-01')
    tti_day_dec = sim.day('2020-12-01')
    tti_day_jan = sim.day('2021-01-01')
    tti_day_feb = sim.day('2021-02-01')
    tti_day_march = sim.day('2021-03-08')
    tti_day_april = sim.day('2021-03-01')
    #start of vaccinating those 75years+
    tti_day_vac1 = sim.day('2021-01-03')
    #start of vaccinating 60+ old
    tti_day_vac2 = sim.day('2021-02-03')
    #start of vaccinating 55+ years old
    tti_day_vac3 = sim.day('2021-02-28')
    #start of vaccination 50+ years old
    tti_day_vac4 = sim.day('2021-03-10')
    #start vaccinating of 45+
    tti_day_vac5 = sim.day('2021-03-30')
    #start vaccinating of 40+
    tti_day_vac6 = sim.day('2021-04-20')
    #start vaccinating of 35+
    tti_day_vac7 = sim.day('2021-05-05')
    #start vaccinating of 30+
    tti_day_vac8 = sim.day('2021-05-30')
    #start vaccinating of 25+
    tti_day_vac9 = sim.day('2021-06-10')
    #start vaccinating of 18+
    tti_day_vac10 = sim.day('2021-06-30')
    #start vaccinating of 11-17
    tti_day_vac11 = sim.day('2021-07-10')

    s_prob_april = 0.009
    s_prob_may = 0.012
    s_prob_june = 0.02769
    s_prob_july = 0.02769
    s_prob_august = 0.03769
    tn = 0.09
    s_prob_sep = 0.08769
    s_prob_oct = 0.08769
    s_prob_nov = 0.08769
    s_prob_dec = 0.08769
    s_prob_jan = 0.08769

    #0.114=70%; 0.149=80%; 0.205=90%

    if future_symp_test is None: future_symp_test = s_prob_jan
    t_delay = 1.0

    #isolation may-july
    iso_vals = [{k: 0.1 for k in 'hswc'}]
    #isolation august
    iso_vals1 = [{k: 0.7 for k in 'hswc'}]
    #isolation september
    iso_vals2 = [{k: 0.6 for k in 'hswc'}]
    #isolation october
    iso_vals3 = [{k: 0.6 for k in 'hswc'}]
    #isolation november
    iso_vals4 = [{k: 0.5 for k in 'hswc'}]
    #isolation december
    iso_vals5 = [{k: 0.4 for k in 'hswc'}]
    #isolation January-April
    #iso_vals6 = [{k:0.3 for k in 'hswc'}]

    #testing and isolation intervention
    interventions += [
        cv.test_prob(symp_prob=0.009,
                     asymp_prob=0.0,
                     symp_quar_prob=0.0,
                     start_day=tc_day,
                     end_day=te_day - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_april,
                     asymp_prob=0.0,
                     symp_quar_prob=0.0,
                     start_day=te_day,
                     end_day=tt_day - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_may,
                     asymp_prob=0.00076,
                     symp_quar_prob=0.0,
                     start_day=tt_day,
                     end_day=tti_day - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_june,
                     asymp_prob=0.00076,
                     symp_quar_prob=0.0,
                     start_day=tti_day,
                     end_day=tti_day_july - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_july,
                     asymp_prob=0.00076,
                     symp_quar_prob=0.0,
                     start_day=tti_day_july,
                     end_day=tti_day_august - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_august,
                     asymp_prob=0.0028,
                     symp_quar_prob=0.0,
                     start_day=tti_day_august,
                     end_day=tti_day_sep - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_sep,
                     asymp_prob=0.0028,
                     symp_quar_prob=0.0,
                     start_day=tti_day_sep,
                     end_day=tti_day_oct - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_oct,
                     asymp_prob=0.0028,
                     symp_quar_prob=0.0,
                     start_day=tti_day_oct,
                     end_day=tti_day_nov - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_nov,
                     asymp_prob=0.0063,
                     symp_quar_prob=0.0,
                     start_day=tti_day_nov,
                     end_day=tti_day_dec - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_dec,
                     asymp_prob=0.0063,
                     symp_quar_prob=0.0,
                     start_day=tti_day_dec,
                     end_day=tti_day_jan - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan,
                     asymp_prob=0.0063,
                     symp_quar_prob=0.0,
                     start_day=tti_day_jan,
                     end_day=tti_day_feb - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_feb,
                     end_day=tti_day_march - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_march,
                     end_day=tti_day_april - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_april,
                     test_delay=t_delay),
        cv.contact_tracing(trace_probs={
            'h': 1,
            's': 0.8,
            'w': 0.8,
            'c': 0.05
        },
                           trace_time={
                               'h': 0,
                               's': 1,
                               'w': 1,
                               'c': 2
                           },
                           start_day='2020-06-01',
                           end_day='2023-06-30',
                           quar_period=10),
        #cv.contact_tracing(trace_probs={'h': 1, 's': 0.5, 'w': 0.5, 'c': 0.05},
        #                   trace_time={'h': 0, 's': 1, 'w': 1, 'c': 2},
        #                   start_day='2021-03-08',
        #                   quar_period=5),
        cv.dynamic_pars({'iso_factor': {
            'days': te_day,
            'vals': iso_vals
        }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_august,
                 'vals': iso_vals1
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_sep,
                 'vals': iso_vals2
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_oct,
                 'vals': iso_vals3
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_nov,
                 'vals': iso_vals4
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_dec,
                 'vals': iso_vals5
             }})
    ]
    #cv.dynamic_pars({'rel_death_prob': {'days': tti_day_vac, 'vals': 0.9}})]
    #cv.vaccine(days=[0,14], rel_sus=0.4, rel_symp=0.2, cumulative=[0.7, 0.3])]

    # derived from AZ default params (3.0.2) with increased interval between doses)
    # dose_pars = cvp.get_vaccine_dose_pars()['az']
    # dose_pars.update({'nab_interval': 14, 'interval':7*9})
    # strain_pars = cvp.get_vaccine_strain_pars()['az']
    # hard code them
    dose_pars = cvp.get_vaccine_dose_pars()['az']
    dose_pars['interval'] = 7 * 12
    variant_pars = cvp.get_vaccine_variant_pars()['az']
    az_vaccine = sc.mergedicts({'label': 'az_uk'},
                               sc.mergedicts(dose_pars, variant_pars))

    dose_pars = cvp.get_vaccine_dose_pars()['pfizer']
    dose_pars['interval'] = 7 * 12
    variant_pars = cvp.get_vaccine_variant_pars()['pfizer']
    pfizer_vaccine = sc.mergedicts({'label': 'pfizer_uk'},
                                   sc.mergedicts(dose_pars, variant_pars))

    #  age targeted vaccination
    #def subtarget_75_100(sim):
    #    inds = cv.true(sim.people.age >= 75)
    #    return {'inds': inds, 'vals': 0.020*np.ones(len(inds))}
    #interventions += [utils_vac.vaccinate(vaccine=vaccine, prob=0.1, subtarget=subtarget_75_100,
    #                               days=np.arange(sim.day('2020-12-20'), sim.day('2023-01-01')))]

    #  age targeted vaccination
    def subtarget_75_100(sim):
        inds = cv.true(sim.people.age >= 75)
        if not hasattr(sim, 'subtarget_75_100'):
            sim.subtarget_75_100 = cv.binomial_filter(
                0.05, inds)  # 95% of 70+ years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_75_100)
        return {'inds': inds, 'vals': 0.02 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=pfizer_vaccine,
                     subtarget=subtarget_75_100,
                     days=np.arange(sim.day('2020-12-20'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_60_75(sim):
        inds = cv.true((sim.people.age >= 60) & (sim.people.age < 75))
        if not hasattr(sim, 'subtarget_60_75'):
            sim.subtarget_60_75 = cv.binomial_filter(
                0.05, inds)  # 95% of 60+ years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_60_75)
        return {'inds': inds, 'vals': 0.02 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=pfizer_vaccine,
                     subtarget=subtarget_60_75,
                     days=np.arange(sim.day('2021-01-28'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_50_60(sim):
        inds = cv.true((sim.people.age >= 50) & (sim.people.age < 60))
        if not hasattr(sim, 'subtarget_50_60'):
            sim.subtarget_50_60 = cv.binomial_filter(
                0.1, inds)  # 90% of 50-60 years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_50_60)
        return {'inds': inds, 'vals': 0.005 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=az_vaccine,
                     subtarget=subtarget_50_60,
                     days=np.arange(sim.day('2021-02-10'),
                                    sim.day('2021-09-15')))
    ]

    #def subtarget_40_50(sim):
    #    inds = cv.true((sim.people.age >= 40) & (sim.people.age < 50))
    #    if not hasattr(sim, 'subtarget_40_50'):
    #        sim.subtarget_40_50 = cv.binomial_filter(0.07, inds) # 93% of 40-50 years olds vaccinated
    #    inds = np.setdiff1d(inds, sim.subtarget_40_50)
    #    return {'inds': inds, 'vals': 0.005*np.ones(len(inds))}
    #interventions += [cv.vaccinate(vaccine=az_vaccine, prob=0.1, subtarget=subtarget_40_50,
    #                               days=np.arange(sim.day('2021-04-10'), sim.day('2023-01-01')))]

    def subtarget_45_50(sim):
        inds = cv.true((sim.people.age >= 45) & (sim.people.age < 50))
        if not hasattr(sim, 'subtarget_45_50'):
            sim.subtarget_45_50 = cv.binomial_filter(
                0.1, inds)  # 90% of 45-50 years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_45_50)
        return {'inds': inds, 'vals': 0.002 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=az_vaccine,
                     subtarget=subtarget_45_50,
                     days=np.arange(sim.day('2021-03-20'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_40_45(sim):
        inds = cv.true((sim.people.age >= 40) & (sim.people.age < 45))
        if not hasattr(sim, 'subtarget_40_45'):
            sim.subtarget_40_45 = cv.binomial_filter(
                0.1, inds)  # 90% of 40-45 years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_40_45)
        return {'inds': inds, 'vals': 0.002 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=az_vaccine,
                     subtarget=subtarget_40_45,
                     days=np.arange(sim.day('2021-04-10'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_30_40(sim):
        inds = cv.true((sim.people.age >= 30) & (sim.people.age < 40))
        if not hasattr(sim, 'subtarget_30_40'):
            sim.subtarget_30_40 = cv.binomial_filter(
                0.1, inds)  # 90% of 30-40 years olds  vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_30_40)
        return {'inds': inds, 'vals': 0.002 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=pfizer_vaccine,
                     subtarget=subtarget_30_40,
                     days=np.arange(sim.day('2021-05-10'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_25_30(sim):
        inds = cv.true((sim.people.age >= 25) & (sim.people.age < 30))
        if not hasattr(sim, 'subtarget_25_30'):
            sim.subtarget_25_30 = cv.binomial_filter(
                0.1, inds)  # 90% of 25-30 years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_25_30)
        return {'inds': inds, 'vals': 0.002 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=pfizer_vaccine,
                     subtarget=subtarget_25_30,
                     days=np.arange(sim.day('2021-06-10'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_18_25(sim):
        inds = cv.true((sim.people.age >= 18) & (sim.people.age < 25))
        if not hasattr(sim, 'subtarget_18_30'):
            sim.subtarget_18_25 = cv.binomial_filter(
                0.1, inds)  # 90% of 18-25 years vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_18_25)
        return {'inds': inds, 'vals': 0.002 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=pfizer_vaccine,
                     subtarget=subtarget_18_25,
                     days=np.arange(sim.day('2021-06-20'),
                                    sim.day('2021-09-15')))
    ]

    def subtarget_16_17(sim):
        inds = cv.true((sim.people.age >= 16) & (sim.people.age < 17))
        if not hasattr(sim, 'subtarget_16_17'):
            sim.subtarget_16_17 = cv.binomial_filter(
                0.9, inds)  # 10% of 16-18 years olds vaccinated
        inds = np.setdiff1d(inds, sim.subtarget_16_17)
        return {'inds': inds, 'vals': 0.002 * np.ones(len(inds))}

    interventions += [
        cv.vaccinate(vaccine=pfizer_vaccine,
                     subtarget=subtarget_16_17,
                     days=np.arange(sim.day('2021-06-20'),
                                    sim.day('2021-09-15')))
    ]

    analyzers = []

    # add daily age stats analyzer
    analyzers += [
        cv.daily_age_stats(edges=[0, 10, 20, 30, 40, 50, 60, 70, 80, 90])
    ]
    #analyzers +=  [cv.age_histogram(datafile='uk_stats_by_age.xlsx', edges=np.concatenate([np.linspace(0, 90, 19),np.array([100])]))]

    # Finally, update the parameters
    sim.update_pars(interventions=interventions, analyzers=analyzers)

    # Change death and critical probabilities
    #    interventions += [cv.dynamic_pars({'rel_death_prob':{'days':sim.day('2020-07-01'), 'vals':0.6}})]

    # Finally, update the parameters
    #sim.update_pars(interventions=interventions)
    for intervention in sim['interventions']:
        intervention.do_plot = False

    sim.initialize()

    return sim
def make_sim(seed, beta, calibration=True, future_symp_test=None, scenario=None, vx_scenario=None, end_day='2021-10-30', verbose=0):

    # Set the parameters
    #total_pop    = 67.86e6 # UK population size
    total_pop    = 55.98e6 # UK population size
    pop_size     = 100e3 # Actual simulated population
    pop_scale    = int(total_pop/pop_size)
    pop_type     = 'hybrid'
    pop_infected = 1000
    beta         = beta
    asymp_factor = 2
    contacts     = {'h':3.0, 's':20, 'w':20, 'c':20}
    beta_layer   = {'h':3.0, 's':1.0, 'w':0.6, 'c':0.3}
    if end_day is None: end_day = '2021-05-05'

    pars = sc.objdict(
        use_waning   = True,
        pop_size     = pop_size,
        pop_infected = pop_infected,
        pop_scale    = pop_scale,
        pop_type     = pop_type,
        start_day    = start_day,
        end_day      = end_day,
        beta         = beta,
        asymp_factor = asymp_factor,
        contacts     = contacts,
        rescale      = True,
        rand_seed    = seed,
        verbose      = verbose,
        rel_symp_prob = 0.9,
        rel_severe_prob = 0.7,
        rel_crit_prob = 4.7,
        rel_death_prob=1.2,
    )

    sim = cv.Sim(pars=pars, datafile=data_path, location='uk')
    #sim['prognoses']['sus_ORs'][0] = 0.5 # ages 20-30
    #sim['prognoses']['sus_ORs'][1] = 1.0 # ages 20-30

   # ADD BETA INTERVENTIONS
    #sbv is transmission in schools and assumed to be 63%=0.7*90% assuming that masks are used and redyce it by 30%
    #from June 2021 we will asume that it is 50% as a combination of large scale isolation of bubbles - found via seeking optimal value
    sbv = 0.63
    sbv_new = 0.90
    beta_past  = sc.odict({'2020-02-14': [1.00, 1.00, 0.90, 0.90],
                           '2020-03-16': [1.00, 0.90, 0.80, 0.80],
                           #first lockdown starts
                           '2020-03-23': [1.00, 0.02, 0.20, 0.20],
                           #first lockdown ends
                           '2020-06-01': [1.00, 0.23, 0.40, 0.40],
                           '2020-06-15': [1.00, 0.38, 0.50, 0.50],
                           '2020-07-22': [1.15, 0.00, 0.30, 0.50],
                           #schools start in Sep 2020
                           '2020-09-02': [1.15, sbv,  0.50, 0.70],
                           '2020-10-01': [1.15, sbv, 0.40, 0.60],
                           '2020-10-16': [1.15, sbv, 0.40, 0.60],
                           #schools holiday Oct 2020
                           '2020-10-26': [1.15, 0.00, 0.30, 0.50],
                           #2nd lockdown starts
                           '2020-11-05': [1.15, sbv, 0.30, 0.40],
                           '2020-11-14': [1.15, sbv, 0.30, 0.40],
                           '2020-11-21': [1.15, sbv, 0.30, 0.40],
                           '2020-11-30': [1.15, sbv, 0.30, 0.40],
                           '2020-12-03': [1.15, sbv, 0.30, 0.40],
                           #2nd lockdown ends and opening for Christmas
                           '2020-12-10': [1.50, 0.00, 0.40, 0.70],
                           '2020-12-17': [1.50, 0.00, 0.40, 0.70],
                           '2020-12-25': [1.50, 0.00, 0.40, 0.70],
                           '2020-12-26': [1.50, 0.00, 0.40, 0.70],
                           '2020-12-31': [1.50, 0.00, 0.20, 0.70],
                           '2021-01-01': [1.50, 0.00, 0.30, 0.30],
                           #3rd lockdown starts
                           '2021-01-04': [1.10, 0.14, 0.20, 0.30],
                           '2021-01-11': [1.05, 0.14, 0.20, 0.30],
                           '2021-01-18': [1.05, 0.14, 0.30, 0.30],
                           '2021-01-30': [1.05, 0.14, 0.30, 0.30],
                           '2021-02-08': [1.05, 0.14, 0.30, 0.30],
                           '2021-02-15': [1.05, 0.00, 0.20, 0.20],
                           '2021-02-22': [1.05, 0.14, 0.30, 0.30],
                           #3rd lockdown ends and reopening starts in 4 steps
                           #schools open in March 2021 - step 1 part 1
                           '2021-03-08': [1.05, sbv, 0.30, 0.40],
                           '2021-03-15': [1.05, sbv, 0.30, 0.40],
                           '2021-03-22': [1.05, sbv, 0.30, 0.40],
                           #stay at home rule finishes - step 1 part 2
                           '2021-03-29': [1.05, 0.00, 0.30, 0.40],
                           '2021-04-05': [1.05, 0.00, 0.30, 0.40],
                           #further relaxation measures - step 2
                           '2021-04-12': [1.05, 0.00, 0.30, 0.40],
                           '2021-04-19': [1.05, sbv, 0.30, 0.40],
                           '2021-04-26': [1.05, sbv, 0.30, 0.40],
                           '2021-05-03': [1.05, sbv, 0.30, 0.40],
                           '2021-05-10': [1.05, sbv, 0.30, 0.40],
                           #some further relaxation  - step 3
                           '2021-05-17': [1.05, sbv, 0.30, 0.50],
                           '2021-05-21': [1.05, sbv, 0.30, 0.50],
                           #May half-term
                           '2021-05-28': [1.05, 0.00, 0.30, 0.40],
                           '2021-06-07': [1.05, sbv, 0.30, 0.60],
                           '2021-06-14': [1.05, sbv, 0.30, 0.60],
                           #full relaxing of social distancing - step 4 - delayed to 19/07/2021 
                           #but we needed to increase in the model to fit data
                           #note sporting events open and at the end of June
                           #large surge in cases from middle of June
                           '2021-06-19': [1.05, 0.50, 0.40, 0.80],
                           '2021-06-21': [1.05, 0.50, 0.40, 0.80],
                           '2021-06-28': [1.05, 0.50, 0.40, 0.80],
                           '2021-07-05': [1.05, 0.50, 0.40, 0.80],
                           '2021-07-12': [1.05, 0.50, 0.40, 0.80],
                           #cases start to drop from midle of July
                           '2021-07-16': [1.05, 0.00, 0.30, 0.50],
                           #easing of socal distancing measures - delayed step 4
                           '2021-07-26': [1.05, 0.00, 0.30, 0.50],
                           '2021-08-02': [1.05, 0.00, 0.30, 0.50],
                           '2021-08-09': [1.05, 0.00, 0.30, 0.50],
                           '2021-08-16': [1.05, 0.00, 0.30, 0.50],
                           '2021-08-23': [1.05, 0.00, 0.30, 0.50],
                           #reopening schools in Sep 2021
                           '2021-09-01': [1.05, sbv_new, 0.60, 0.80],
                           '2021-09-15': [1.05, sbv_new, 0.60, 0.80],
                           '2021-09-29': [1.05, sbv_new, 0.60, 0.80],
                           '2021-10-13': [1.05, sbv_new, 0.60, 0.80],
                           '2021-10-22': [1.05, 0.00, 0.60, 0.80],
                           '2021-11-01': [1.05, sbv_new, 0.60, 0.80],
                           '2021-11-08': [1.05, sbv_new, 0.60, 0.80],
                           '2021-11-15': [1.05, sbv_new, 0.60, 0.80],
                           '2021-11-22': [1.05, sbv_new, 0.60, 0.80],
                           '2021-12-01': [1.05, sbv_new, 0.60, 0.80],
                           #'2021-06-21': [1.25, sbv, 0.70, 0.90],
                           #'2021-06-28': [1.25, sbv, 0.70, 0.90],
                           #'2021-07-05': [1.25, sbv, 0.70, 0.90],
                           #'2021-07-12': [1.25, sbv, 0.70, 0.90],
                           #'2021-07-19': [1.25, 0.00, 0.70, 0.90],
                           #'2021-07-26': [1.25, 0.00, 0.70, 0.90],
                           #'2021-08-02': [1.25, 0.00, 0.70, 0.90],
                           #'2021-08-16': [1.25, 0.00, 0.70, 0.90],
                           })

    if not calibration:
        ##no schools until 8th March but assue 20% (1 in 5) in schools between 04/01-22/02;
        ##model transmission remaining at schools as 14% (to account for 30% reduction due to school measures)
        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April,
        ## society some more (stage 3) 17th May and everything (stage 4) 21st June 2021.
        ## Projecting until end of 2021.
        if scenario == 'Roadmap_All':

            beta_scens = sc.odict({'2021-06-21': [1.25, sbv, 0.70, 0.90],
                               '2021-06-28': [1.25, sbv, 0.70, 0.90],
                               '2021-07-05': [1.25, sbv, 0.70, 0.90],
                               '2021-07-12': [1.25, sbv, 0.70, 0.90],
                               '2021-07-19': [1.25, 0.00, 0.70, 0.90],
                               '2021-07-26': [1.25, 0.00, 0.70, 0.90],
                               '2021-08-02': [1.25, 0.00, 0.70, 0.90],
                               '2021-08-16': [1.25, 0.00, 0.70, 0.90],
                               '2021-09-01': [1.25, 0.63, 0.70, 0.90],
                               '2021-09-15': [1.25, 0.63, 0.70, 0.90],
                               '2021-09-29': [1.25, 0.63, 0.70, 0.90],
                               '2021-10-13': [1.25, 0.63, 0.70, 0.90],
                               '2021-10-22': [1.25, 0.02, 0.50, 0.90],
                               '2021-11-01': [1.25, 0.63, 0.70, 0.90],
                               '2021-11-08': [1.25, 0.63, 0.70, 0.90],
                               '2021-11-23': [1.25, 0.63, 0.70, 0.90],
                               '2021-11-30': [1.25, 0.63, 0.70, 0.90],
                               '2021-12-07': [1.25, 0.63, 0.70, 0.90],
                               '2021-12-20': [1.25, 0.02, 0.50, 0.80],
                               '2022-01-05': [1.25, 0.63, 0.70, 0.90],
                              })

        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April ONLY
        ## NO (stage 3) 17th May and NO stage 4 21st June 2021.
        ## Projecting until end of 2021.
        #elif scenario == 'Roadmap_Stage2':

            #beta_scens = sc.odict({'2021-04-12': [1.25, 0.02, 0.40, 0.70],
            #                   '2021-04-19': [1.25, sbv, 0.40, 0.70],
            #                   '2021-04-26': [1.25, sbv, 0.40, 0.70],
            #                   '2021-05-03': [1.25, sbv, 0.40, 0.70],
            #                   '2021-05-10': [1.25, sbv, 0.40, 0.70],
            #                   '2021-05-17': [1.25, sbv, 0.40, 0.70],
            #                   '2021-05-21': [1.25, sbv, 0.40, 0.70],
            #                   '2021-05-28': [1.25, 0.02, 0.40, 0.70],
            #                   '2021-06-07': [1.25, sbv, 0.40, 0.70],
            #                   '2021-06-21': [1.25, sbv, 0.40, 0.70],
            #                   '2021-06-28': [1.25, sbv, 0.40, 0.70],
            #                   '2021-07-05': [1.25, sbv, 0.40, 0.70],
            #                   '2021-07-12': [1.25, sbv, 0.40, 0.70],
            #                   '2021-07-19': [1.25, 0.00, 0.40, 0.70],
            #                   '2021-07-26': [1.25, 0.00, 0.40, 0.70],
            #                   '2021-08-02': [1.25, 0.00, 0.40, 0.70],
            #                   '2021-08-16': [1.25, 0.00, 0.40, 0.70],
            #                   '2021-09-01': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-09-15': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-09-29': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-10-13': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-10-27': [1.25, 0.02, 0.70, 0.90],
            #                   '2021-11-08': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-11-23': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-11-30': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-12-07': [1.25, 0.63, 0.70, 0.90],
            #                   '2021-12-21': [1.25, 0.63, 0.70, 0.90],
            #                  })
        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April,
        ## and society some more (stage 3) 17th May but NO stage 4 21st June 2021.
        ## Projecting until end of 2021.
        elif scenario == 'Roadmap_Stage3':
            beta_scens = sc.odict({'2021-06-21': [1.25, sbv, 0.40, 0.60],
                               '2021-06-28': [1.25, sbv, 0.40, 0.60],
                               '2021-07-05': [1.25, sbv, 0.40, 0.60],
                               '2021-07-12': [1.25, sbv, 0.40, 0.60],
                               '2021-07-19': [1.25, 0.00, 0.50, 0.80],
                               '2021-07-26': [1.25, 0.00, 0.50, 0.80],
                               '2021-08-02': [1.25, 0.00, 0.50, 0.80],
                               '2021-08-16': [1.25, 0.00, 0.50, 0.80],
                               '2021-09-01': [1.25, 0.63, 0.70, 0.90],
                               '2021-09-15': [1.25, 0.63, 0.70, 0.90],
                               '2021-09-29': [1.25, 0.63, 0.70, 0.90],
                               '2021-10-13': [1.25, 0.63, 0.70, 0.90],
                               '2021-10-22': [1.25, 0.02, 0.50, 0.90],
                               '2021-11-01': [1.25, 0.63, 0.70, 0.90],
                               '2021-11-08': [1.25, 0.63, 0.70, 0.90],
                               '2021-11-23': [1.25, 0.63, 0.70, 0.90],
                               '2021-11-30': [1.25, 0.63, 0.70, 0.90],
                               '2021-12-07': [1.25, 0.63, 0.70, 0.90],
                               '2021-12-20': [1.25, 0.02, 0.50, 0.80],
                               '2022-01-05': [1.25, 0.63, 0.70, 0.90],
                              })
        beta_dict = sc.mergedicts(beta_past, beta_scens)
    else:
        beta_dict = beta_past

    beta_days = list(beta_dict.keys())
    h_beta = cv.change_beta(days=beta_days, changes=[c[0] for c in beta_dict.values()], layers='h')
    s_beta = cv.change_beta(days=beta_days, changes=[c[1] for c in beta_dict.values()], layers='s')
    w_beta = cv.change_beta(days=beta_days, changes=[c[2] for c in beta_dict.values()], layers='w')
    c_beta = cv.change_beta(days=beta_days, changes=[c[3] for c in beta_dict.values()], layers='c')

    # Add B.1.117 strain
    b117 = cv.variant('b117', days=np.arange(sim.day('2020-08-20'), sim.day('2020-08-30')), n_imports=500)
    b117.p['rel_beta']        = 1.6
    b117.p['rel_symp_prob']   = 1.1
    b117.p['rel_severe_prob'] = 0.6
    b117.p['rel_crit_prob']   = 2.7
    b117.p['rel_death_prob']  = 0.6
    #b117.p['rel_severe_prob'] = 0.7
    #b117.p['rel_crit_prob']   = 1.0
    #b117.p['rel_death_prob']  = 1.0
    sim['variants'] += [b117]
    # Add B.1.1351 strain
    b1351 = cv.variant('b1351', days=np.arange(sim.day('2021-01-10'), sim.day('2021-01-20')), n_imports=1500)
    b1351.p['rel_beta']        = 1.0
    b1351.p['rel_severe_prob'] = 1.0
    b1351.p['rel_crit_prob']   = 1.0
    b1351.p['rel_death_prob']  = 1.0
    sim['variants'] += [b1351]
    # Add B.X.XXX strain starting middle of March
    b16172 = cv.variant('b16172', days=np.arange(sim.day('2021-03-17'), sim.day('2021-03-20')), n_imports=1000)
    b16172.p['rel_beta']         = 2.1
    b16172.p['rel_symp_prob']    = 0.4
    b16172.p['rel_severe_prob']  = 0.1
    b16172.p['rel_crit_prob']    = 0.2
    b16172.p['rel_death_prob']   = 0.4
    #b16172.p['rel_severe_prob'] = 0.7
    #b16172.p['rel_crit_prob']   = 1.0
    #b16172.p['rel_death_prob']  = 0.7
    sim['variants'] += [b16172]
    # seems like we need to do this to deal with cross immunity?
    #sim.initialize()
    #sim['immunity']
    #prior = {'wild': 0.8, 'b117': 0.5, 'b1351': 0.8, 'b16172': 0.8}
    #pre = {'wild': 0.8, 'b117': 0.5, 'b1351': 0.8, 'b16172': 0.8}
    #for k,v in sim['variant_map'].items():
    #    if v == 'b16172':
    #        for j, j_lab in sim['variant_map'].items():
    #            sim['immunity'][k][j] = prior[j_lab]
    #            sim['immunity'][j][k] = pre[j_lab]
                 #if j != k:
                 #    sim['immunity'][k][j] = cross_immunities['b117'][j_lab]
                 #    sim['immunity'][j][k] = cross_immunities[j_lab]['b117']
    # # Add a new change in beta to represent the takeover of the novel variant VOC B117 202012/01
    # # Assume that the new variant is 60% more transmisible (https://cmmid.github.io/topics/covid19/uk-novel-variant.html,
    # # Assume that between Nov 1 and Jan 30, the new variant grows from 0-100% of cases

    interventions = [h_beta, w_beta, s_beta, c_beta]

    # ADD TEST AND TRACE INTERVENTIONS
    tc_day = sim.day('2020-03-16') #intervention of some testing (tc) starts on 16th March and we run until 1st April when it increases
    te_day = sim.day('2020-04-01') #intervention of some testing (te) starts on 1st April and we run until 1st May when it increases
    tt_day = sim.day('2020-05-01') #intervention of increased testing (tt) starts on 1st May
    tti_day= sim.day('2020-06-01') #intervention of tracing and enhanced testing (tti) starts on 1st June
    tti_day_july= sim.day('2020-07-01') #intervention of tracing and enhanced testing (tti) at different levels starts on 1st July
    tti_day_august= sim.day('2020-08-01') #intervention of tracing and enhanced testing (tti) at different levels starts on 1st August
    tti_day_sep= sim.day('2020-09-01')
    tti_day_oct= sim.day('2020-10-01')
    tti_day_nov= sim.day('2020-11-01')
    tti_day_dec= sim.day('2020-12-01')
    tti_day_jan= sim.day('2021-01-01')
    tti_day_feb= sim.day('2021-02-01')
    tti_day_march= sim.day('2021-03-08')
    tti_day_april= sim.day('2021-03-01')
    tti_day_july21= sim.day('2021-07-20')
    tti_day_august21= sim.day('2021-08-15')

    s_prob_april = 0.012
    s_prob_may   = 0.012
    s_prob_june = 0.04769
    s_prob_july = 0.04769
    s_prob_august = 0.04769
    # tn = 0.09
    s_prob_sep = 0.07769
    s_prob_oct = 0.07769
    s_prob_nov = 0.07769
    s_prob_dec = 0.07769
    s_prob_jan = 0.07769
    s_prob_march = 0.07769
    s_prob_july21 = 0.032769
    s_prob_august21 = 0.05769

    #0.114=70%; 0.149=80%; 0.205=90%

    if future_symp_test is None: future_symp_test = s_prob_jan
    t_delay       = 1.0

    #isolation may-june
    iso_vals = [{k:0.2 for k in 'hswc'}]
    #isolation july
    iso_vals1 = [{k:0.4 for k in 'hswc'}]
    #isolation september
    iso_vals2 = [{k:0.6 for k in 'hswc'}]
    #isolation october
    iso_vals3 = [{k:0.6 for k in 'hswc'}]
    #isolation november
    iso_vals4 = [{k:0.5 for k in 'hswc'}]
     #isolation december
    iso_vals5 = [{k:0.4 for k in 'hswc'}]
    #isolation July 2021
    iso_vals6 = [{k:0.4 for k in 'hswc'}]
     #isolation from August 2021
    #iso_vals7 = [{k:0.4 for k in 'hswc'}]


    #testing and isolation intervention
    interventions += [
        cv.test_prob(symp_prob=0.009, asymp_prob=0.0, symp_quar_prob=0.0, start_day=tc_day, end_day=te_day-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_april, asymp_prob=0.0, symp_quar_prob=0.0, start_day=te_day, end_day=tt_day-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_may, asymp_prob=0.00076, symp_quar_prob=0.0, start_day=tt_day, end_day=tti_day-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_june, asymp_prob=0.00076, symp_quar_prob=0.0, start_day=tti_day, end_day=tti_day_july-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_july, asymp_prob=0.00076, symp_quar_prob=0.0, start_day=tti_day_july, end_day=tti_day_august-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_august, asymp_prob=0.0028, symp_quar_prob=0.0, start_day=tti_day_august, end_day=tti_day_sep-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_sep, asymp_prob=0.0028, symp_quar_prob=0.0, start_day=tti_day_sep, end_day=tti_day_oct-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_oct, asymp_prob=0.0028, symp_quar_prob=0.0, start_day=tti_day_oct, end_day=tti_day_nov-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_nov, asymp_prob=0.0063, symp_quar_prob=0.0, start_day=tti_day_nov, end_day=tti_day_dec-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_dec, asymp_prob=0.0063, symp_quar_prob=0.0, start_day=tti_day_dec, end_day=tti_day_jan-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan, asymp_prob=0.0063, symp_quar_prob=0.0, start_day=tti_day_jan, end_day=tti_day_feb-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan, asymp_prob=0.008, symp_quar_prob=0.0, start_day=tti_day_feb, end_day=tti_day_march-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_march, asymp_prob=0.008, symp_quar_prob=0.0, start_day=tti_day_march, end_day=tti_day_april-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_march, asymp_prob=0.008, symp_quar_prob=0.0, start_day=tti_day_april, end_day=tti_day_july21-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_july21, asymp_prob=0.004, symp_quar_prob=0.0, start_day=tti_day_july21, end_day=tti_day_august21-1, test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_august21, asymp_prob=0.008, symp_quar_prob=0.0, start_day=tti_day_august21, test_delay=t_delay),
        cv.contact_tracing(trace_probs={'h': 1, 's': 0.8, 'w': 0.8, 'c': 0.05},
                           trace_time={'h': 0, 's': 1, 'w': 1, 'c': 2},
                           start_day='2020-06-01', end_day='2023-06-30',
                           quar_period=10),
        #cv.contact_tracing(trace_probs={'h': 1, 's': 0.5, 'w': 0.5, 'c': 0.05},
        #                   trace_time={'h': 0, 's': 1, 'w': 1, 'c': 2},
        #                   start_day='2021-03-08',
        #                   quar_period=5),
        cv.dynamic_pars({'iso_factor': {'days': te_day, 'vals': iso_vals}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_july, 'vals': iso_vals1}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_sep, 'vals': iso_vals2}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_oct, 'vals': iso_vals3}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_nov, 'vals': iso_vals4}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_dec, 'vals': iso_vals5}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_july21, 'vals': iso_vals6}})]
        #cv.dynamic_pars({'iso_factor': {'days': tti_day_august21, 'vals': iso_vals7}})]
        #cv.dynamic_pars({'rel_death_prob': {'days': tti_day_vac, 'vals': 0.9}})]
        #cv.vaccine(days=[0,14], rel_sus=0.4, rel_symp=0.2, cumulative=[0.7, 0.3])]


    
    dose_pars = cvp.get_vaccine_dose_pars()['az']
    dose_pars['interval'] = 7 * 8
    variant_pars = cvp.get_vaccine_variant_pars()['az']
    az_vaccine = sc.mergedicts({'label':'az_uk'}, sc.mergedicts(dose_pars, variant_pars)) 

    dose_pars = cvp.get_vaccine_dose_pars()['pfizer']
    dose_pars['interval'] = 7 * 8
    variant_pars = cvp.get_vaccine_variant_pars()['pfizer']
    pfizer_vaccine = sc.mergedicts({'label':'pfizer_uk'}, sc.mergedicts(dose_pars, variant_pars))

    # Loop over vaccination in different ages
    for age in vx_ages:
        vaccine = az_vaccine if (age > 40 and age < 65) else pfizer_vaccine
        subtarget = subtargets[vx_scen][age]
        vx_start_day = sim.day(vx_rollout[age]['start_day'])
        vx_end_day = vx_start_day + vx_duration
        days = np.arange(vx_start_day, vx_end_day)
        vx = cv.vaccinate(vaccine=vaccine, subtarget=subtarget, days=days)
        #vx = cv.vaccinate(vaccine=vaccine, days=days, prob=0.01)
        interventions += [vx]

    analyzers = []

    # add daily age stats analyzer
    analyzers += [cv.daily_age_stats(edges= [0, 30,  65,  80, 100])]
    #analyzers +=  [cv.age_histogram(datafile='uk_stats_by_age.xlsx', edges=np.concatenate([np.linspace(0, 90, 19),np.array([100])]))]


# Finally, update the parameters
    sim.update_pars(interventions=interventions, analyzers=analyzers)

    # Change death and critical probabilities
#    interventions += [cv.dynamic_pars({'rel_death_prob':{'days':sim.day('2020-07-01'), 'vals':0.6}})]


    # Finally, update the parameters
    #sim.update_pars(interventions=interventions)
    for intervention in sim['interventions']:
        intervention.do_plot = False

    sim.initialize()

    return sim
        cv.dynamic_pars({'iso_factor': {'days': te_day, 'vals': iso_vals}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_july, 'vals': iso_vals1}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_sep, 'vals': iso_vals2}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_oct, 'vals': iso_vals3}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_nov, 'vals': iso_vals4}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_dec, 'vals': iso_vals5}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_july21, 'vals': iso_vals6}}),
        cv.dynamic_pars({'iso_factor': {'days': tti_day_august21, 'vals': iso_vals7}})]
        #cv.dynamic_pars({'rel_death_prob': {'days': tti_day_vac, 'vals': 0.9}})]
        #cv.vaccine(days=[0,14], rel_sus=0.4, rel_symp=0.2, cumulative=[0.7, 0.3])]


    
    dose_pars = cvp.get_vaccine_dose_pars()['az']
    dose_pars['interval'] = 7 * 8
    variant_pars = cvp.get_vaccine_variant_pars()['az']
    az_vaccine = sc.mergedicts({'label':'az_uk'}, sc.mergedicts(dose_pars, variant_pars)) 

    dose_pars = cvp.get_vaccine_dose_pars()['pfizer']
    dose_pars['interval'] = 7 * 8
    variant_pars = cvp.get_vaccine_variant_pars()['pfizer']
    pfizer_vaccine = sc.mergedicts({'label':'pfizer_uk'}, sc.mergedicts(dose_pars, variant_pars))

    # Loop over vaccination in different ages
    for age in vx_ages:
        vaccine = az_vaccine if (age > 40 and age < 65) else pfizer_vaccine
        subtarget = subtargets[vx_scen][age]
        vx_start_day = sim.day(vx_rollout[age]['start_day'])
        vx_end_day = vx_start_day + vx_duration
        days = np.arange(vx_start_day, vx_end_day)
        vx = cv.vaccinate(vaccine=vaccine, subtarget=subtarget, days=days)
Example #4
0
def make_sim(seed,
             beta,
             calibration=True,
             future_symp_test=None,
             scenario=None,
             vx_scenario=None,
             end_day='2021-08-31',
             verbose=0):

    # Set the parameters
    #total_pop    = 67.86e6 # UK population size
    total_pop = 55.98e6  # UK population size
    pop_size = 100e3  # Actual simulated population
    pop_scale = int(total_pop / pop_size)
    pop_type = 'hybrid'
    pop_infected = 1000
    beta = beta
    asymp_factor = 2
    contacts = {'h': 3.0, 's': 20, 'w': 20, 'c': 20}
    beta_layer = {'h': 3.0, 's': 1.0, 'w': 0.6, 'c': 0.3}
    if end_day is None: end_day = '2021-05-05'

    pars = sc.objdict(
        use_waning=True,
        pop_size=pop_size,
        pop_infected=pop_infected,
        pop_scale=pop_scale,
        pop_type=pop_type,
        start_day=start_day,
        end_day=end_day,
        beta=beta,
        asymp_factor=asymp_factor,
        contacts=contacts,
        rescale=True,
        rand_seed=seed,
        verbose=verbose,
    )

    sim = cv.Sim(pars=pars, datafile=data_path, location='uk')
    #sim['prognoses']['sus_ORs'][0] = 0.5 # ages 0-10
    #sim['prognoses']['sus_ORs'][1] = 1.0 # ages 11-20

    # ADD BETA INTERVENTIONS
    #sbv is transmission in schools and assumed to be 63%=0.7*90% assuming that masks are used and redyce it by 30%
    #from June 2021 we will asume that it is 50% as a combination of large scale isolation of bubbles - found via seeking optimal value
    sbv = 0.63
    sbv_new = 0.63
    beta_past = sc.odict({
        '2020-02-14': [1.00, 1.00, 0.90, 0.90],
        '2020-03-16': [1.00, 0.90, 0.80, 0.80],
        #first lockdown starts
        '2020-03-23': [1.00, 0.02, 0.20, 0.20],
        #first lockdown ends
        '2020-06-01': [1.00, 0.23, 0.40, 0.40],
        '2020-06-15': [1.00, 0.38, 0.50, 0.50],
        '2020-07-22': [1.15, 0.00, 0.30, 0.50],
        '2020-07-29': [1.15, 0.00, 0.30, 0.70],
        '2020-08-12': [1.15, 0.00, 0.30, 0.70],
        '2020-07-19': [1.15, 0.00, 0.30, 0.70],
        '2020-07-26': [1.15, 0.00, 0.30, 0.70],
        #schools start in Sep 2020
        '2020-09-02': [1.15, sbv, 0.50, 0.70],
        '2020-10-01': [1.15, sbv, 0.40, 0.70],
        '2020-10-16': [1.15, sbv, 0.40, 0.70],
        #schools holiday Oct 2020
        '2020-10-26': [1.15, 0.00, 0.30, 0.60],
        #2nd lockdown starts
        '2020-11-05': [1.15, sbv, 0.30, 0.40],
        '2020-11-14': [1.15, sbv, 0.30, 0.40],
        '2020-11-21': [1.15, sbv, 0.30, 0.40],
        '2020-11-30': [1.15, sbv, 0.30, 0.40],
        '2020-12-05': [1.15, sbv, 0.30, 0.40],
        #2nd lockdown ends and opening for Christmas
        '2020-12-10': [1.50, sbv, 0.40, 0.80],
        '2020-12-17': [1.50, sbv, 0.40, 0.80],
        '2020-12-24': [1.50, 0.00, 0.40, 0.60],
        '2020-12-26': [1.50, 0.00, 0.40, 0.70],
        '2020-12-31': [1.50, 0.00, 0.20, 0.70],
        '2021-01-01': [1.50, 0.00, 0.20, 0.70],
        #3rd lockdown starts
        '2021-01-04': [1.10, 0.14, 0.20, 0.40],
        '2021-01-11': [1.05, 0.14, 0.20, 0.40],
        '2021-01-18': [1.05, 0.14, 0.30, 0.30],
        '2021-01-30': [1.05, 0.14, 0.30, 0.30],
        '2021-02-08': [1.05, 0.14, 0.30, 0.30],
        '2021-02-15': [1.05, 0.00, 0.20, 0.20],
        '2021-02-22': [1.05, 0.14, 0.30, 0.30],
        #3rd lockdown ends and reopening starts in 4 steps
        #schools open in March 2021 - step 1 part 1
        '2021-03-08': [1.05, sbv, 0.30, 0.40],
        '2021-03-15': [1.05, sbv, 0.30, 0.40],
        '2021-03-22': [1.05, sbv, 0.30, 0.40],
        #stay at home rule finishes - step 1 part 2
        '2021-03-29': [1.05, 0.00, 0.40, 0.50],
        '2021-04-01': [1.05, 0.00, 0.30, 0.50],
        #further relaxation measures - step 2
        '2021-04-12': [1.05, 0.00, 0.30, 0.40],
        '2021-04-19': [1.05, sbv, 0.30, 0.40],
        '2021-04-26': [1.05, sbv, 0.30, 0.40],
        '2021-05-03': [1.05, sbv, 0.30, 0.40],
        '2021-05-10': [1.05, sbv, 0.30, 0.40],
        #some further relaxation  - step 3
        '2021-05-17': [1.05, sbv, 0.30, 0.50],
        '2021-05-21': [1.05, sbv, 0.30, 0.50],
        #May half-term
        '2021-05-31': [1.05, 0.00, 0.30, 0.40],
        #slight relaxation after Spring half-term
        #but delay Step 3 until 19/07/2021
        '2021-06-07': [1.05, sbv, 0.30, 0.50],
        '2021-06-14': [1.05, sbv, 0.30, 0.50],
        '2021-06-21': [1.05, sbv, 0.30, 0.50],
        '2021-06-28': [1.05, sbv, 0.30, 0.50],
        '2021-07-05': [1.25, sbv, 0.30, 0.50],
        '2021-07-12': [1.25, sbv, 0.30, 0.50],
        '2021-07-19': [1.25, 0.00, 0.30, 0.50],
        '2021-07-26': [1.25, 0.00, 0.30, 0.50],
        '2021-08-02': [1.25, 0.00, 0.30, 0.50],
    })

    if not calibration:
        ##no schools until 8th March but assue 20% (1 in 5) in schools between 04/01-22/02;
        ##model transmission remaining at schools as 14% (to account for 30% reduction due to school measures)
        ## reopening schools on 8th March, society stage 1 29th March, society stage 2 12th April,
        ## society some more (stage 3) 17th May and everything (stage 4) 21st June 2021.
        ## Projecting until end of August 2021.
        if scenario == 'Roadmap_Step3':

            beta_scens = sc.odict({
                '2021-06-21': [1.05, sbv, 0.40, 0.80],
                '2021-06-28': [1.25, sbv, 0.40, 0.80],
                '2021-07-05': [1.25, sbv, 0.40, 0.80],
                '2021-07-12': [1.25, sbv, 0.40, 0.80],
                '2021-07-19': [1.25, 0.00, 0.40, 0.80],
                '2021-07-26': [1.25, 0.00, 0.40, 0.80],
                '2021-08-02': [1.25, 0.00, 0.40, 0.80],
            })

        elif scenario == 'Roadmap_delayed_Step3':
            beta_scens = sc.odict({
                '2021-06-21': [1.25, sbv, 0.30, 0.50],
                '2021-06-28': [1.25, sbv, 0.30, 0.50],
                '2021-07-05': [1.25, sbv, 0.30, 0.50],
                '2021-07-12': [1.25, sbv, 0.30, 0.50],
                '2021-07-19': [1.25, 0.00, 0.40, 0.80],
                '2021-07-26': [1.25, 0.00, 0.40, 0.80],
                '2021-08-02': [1.25, 0.00, 0.40, 0.80],
            })
        beta_dict = sc.mergedicts(beta_past, beta_scens)
    else:
        beta_dict = beta_past

    beta_days = list(beta_dict.keys())
    h_beta = cv.change_beta(days=beta_days,
                            changes=[c[0] for c in beta_dict.values()],
                            layers='h')
    s_beta = cv.change_beta(days=beta_days,
                            changes=[c[1] for c in beta_dict.values()],
                            layers='s')
    w_beta = cv.change_beta(days=beta_days,
                            changes=[c[2] for c in beta_dict.values()],
                            layers='w')
    c_beta = cv.change_beta(days=beta_days,
                            changes=[c[3] for c in beta_dict.values()],
                            layers='c')

    # Add B.1.1351 strain from August 2020; n_imports, rel_beta and rel_severe_beta from calibration
    b1351 = cv.variant('b1351',
                       days=np.arange(sim.day('2020-08-10'),
                                      sim.day('2020-08-20')),
                       n_imports=3000)
    b1351.p['rel_beta'] = 1.2
    b1351.p['rel_severe_prob'] = 0.4
    sim['variants'] += [b1351]

    # Add Alpha strain from October 2020; n_imports, rel_beta and rel_severe_beta from calibration
    b117 = cv.variant('b117',
                      days=np.arange(sim.day('2020-10-20'),
                                     sim.day('2020-10-30')),
                      n_imports=3000)
    b117.p['rel_beta'] = 1.8
    b117.p['rel_severe_prob'] = 0.4
    sim['variants'] += [b117]

    # Add Delta strain starting middle of April 2021; n_imports, rel_beta and rel_severe_beta from calibration
    b16172 = cv.variant('b16172',
                        days=np.arange(sim.day('2021-04-15'),
                                       sim.day('2021-04-20')),
                        n_imports=4000)
    b16172.p['rel_beta'] = 2.9
    b16172.p['rel_severe_prob'] = 0.2
    sim['variants'] += [b16172]

    interventions = [h_beta, w_beta, s_beta, c_beta]

    # ADD TEST AND TRACE INTERVENTIONS
    tc_day = sim.day(
        '2020-03-16'
    )  #intervention of some testing (tc) starts on 16th March and we run until 1st April when it increases
    te_day = sim.day(
        '2020-04-01'
    )  #intervention of some testing (te) starts on 1st April and we run until 1st May when it increases
    tt_day = sim.day(
        '2020-05-01'
    )  #intervention of increased testing (tt) starts on 1st May
    tti_day = sim.day(
        '2020-06-01'
    )  #intervention of tracing and enhanced testing (tti) starts on 1st June
    tti_day_july = sim.day(
        '2020-07-01'
    )  #intervention of tracing and enhanced testing (tti) at different levels starts on 1st July
    tti_day_august = sim.day(
        '2020-08-01'
    )  #intervention of tracing and enhanced testing (tti) at different levels starts on 1st August
    tti_day_sep = sim.day('2020-09-01')
    tti_day_oct = sim.day('2020-10-01')
    tti_day_nov = sim.day('2020-11-01')
    tti_day_dec = sim.day('2020-12-01')
    tti_day_jan = sim.day('2021-01-01')
    tti_day_feb = sim.day('2021-02-01')
    tti_day_march = sim.day('2021-03-08')
    tti_day_june21 = sim.day('2021-06-20')
    tti_day_july21 = sim.day('2021-07-19')
    tti_day_august21 = sim.day('2021-08-02')
    tti_day_sep21 = sim.day('2021-09-07')

    s_prob_april = 0.012
    s_prob_may = 0.012
    s_prob_june = 0.04769
    s_prob_july = 0.04769
    s_prob_august = 0.04769
    s_prob_sep = 0.07769
    s_prob_oct = 0.07769
    s_prob_nov = 0.07769
    s_prob_dec = 0.07769
    s_prob_jan = 0.08769
    s_prob_march = 0.08769
    #for reopening in June
    #s_prob_june21 = 0.19769
    #for reopening in July
    s_prob_june21 = 0.08769
    #for reopening in July
    #s_prob_july21 = 0.195069
    s_prob_july21 = 0.08769
    s_prob_august21 = 0.08769
    s_prob_sep21 = 0.03769

    #0.114=70%; 0.149=80%; 0.205=90%

    if future_symp_test is None: future_symp_test = s_prob_jan
    t_delay = 1.0

    #isolation may-june
    iso_vals = [{k: 0.2 for k in 'hswc'}]
    #isolation july
    iso_vals1 = [{k: 0.4 for k in 'hswc'}]
    #isolation september
    iso_vals2 = [{k: 0.6 for k in 'hswc'}]
    #isolation october
    iso_vals3 = [{k: 0.6 for k in 'hswc'}]
    #isolation november
    iso_vals4 = [{k: 0.2 for k in 'hswc'}]
    #isolation december
    iso_vals5 = [{k: 0.5 for k in 'hswc'}]
    #isolation March 2021
    ####changed to 0.2 for fitting
    iso_vals6 = [{k: 0.5 for k in 'hswc'}]
    #isolation from 20 June 2021 reduced
    iso_vals7 = [{k: 0.7 for k in 'hswc'}]
    #isolation from 16 July 2021 increased
    ####chnaged to 0.2 for fitting
    iso_vals8 = [{k: 0.3 for k in 'hswc'}]
    #isolation from August 2021
    iso_vals9 = [{k: 0.5 for k in 'hswc'}]
    #isolation from Sep 2021
    iso_vals10 = [{k: 0.5 for k in 'hswc'}]

    #testing and isolation intervention
    interventions += [
        cv.test_prob(symp_prob=0.009,
                     asymp_prob=0.0,
                     symp_quar_prob=0.0,
                     start_day=tc_day,
                     end_day=te_day - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_april,
                     asymp_prob=0.0,
                     symp_quar_prob=0.0,
                     start_day=te_day,
                     end_day=tt_day - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_may,
                     asymp_prob=0.00076,
                     symp_quar_prob=0.0,
                     start_day=tt_day,
                     end_day=tti_day - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_june,
                     asymp_prob=0.00076,
                     symp_quar_prob=0.0,
                     start_day=tti_day,
                     end_day=tti_day_july - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_july,
                     asymp_prob=0.00076,
                     symp_quar_prob=0.0,
                     start_day=tti_day_july,
                     end_day=tti_day_august - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_august,
                     asymp_prob=0.0028,
                     symp_quar_prob=0.0,
                     start_day=tti_day_august,
                     end_day=tti_day_sep - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_sep,
                     asymp_prob=0.0028,
                     symp_quar_prob=0.0,
                     start_day=tti_day_sep,
                     end_day=tti_day_oct - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_oct,
                     asymp_prob=0.0028,
                     symp_quar_prob=0.0,
                     start_day=tti_day_oct,
                     end_day=tti_day_nov - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_nov,
                     asymp_prob=0.0063,
                     symp_quar_prob=0.0,
                     start_day=tti_day_nov,
                     end_day=tti_day_dec - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_dec,
                     asymp_prob=0.0063,
                     symp_quar_prob=0.0,
                     start_day=tti_day_dec,
                     end_day=tti_day_jan - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan,
                     asymp_prob=0.0063,
                     symp_quar_prob=0.0,
                     start_day=tti_day_jan,
                     end_day=tti_day_feb - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_jan,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_feb,
                     end_day=tti_day_march - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_march,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_march,
                     end_day=tti_day_june21 - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_june21,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_june21,
                     end_day=tti_day_july21 - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_july21,
                     asymp_prob=0.004,
                     symp_quar_prob=0.0,
                     start_day=tti_day_july21,
                     end_day=tti_day_august21 - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_august21,
                     asymp_prob=0.004,
                     symp_quar_prob=0.0,
                     start_day=tti_day_august21,
                     end_day=tti_day_sep21 - 1,
                     test_delay=t_delay),
        cv.test_prob(symp_prob=s_prob_sep21,
                     asymp_prob=0.008,
                     symp_quar_prob=0.0,
                     start_day=tti_day_sep21,
                     test_delay=t_delay),
        cv.contact_tracing(trace_probs={
            'h': 1,
            's': 0.8,
            'w': 0.8,
            'c': 0.1
        },
                           trace_time={
                               'h': 0,
                               's': 1,
                               'w': 1,
                               'c': 2
                           },
                           start_day='2020-06-01',
                           end_day='2023-07-12',
                           quar_period=10),
        #cv.contact_tracing(trace_probs={'h': 1, 's': 0.8, 'w': 0.8, 'c': 0.1},
        #                   trace_time={'h': 0, 's': 1, 'w': 1, 'c': 2},
        #                   start_day='2021-07-12', end_day='2021-07-20',
        #                   quar_period=10),
        #cv.contact_tracing(trace_probs={'h': 1, 's': 0.8, 'w': 0.8, 'c': 0.1},
        #                   trace_time={'h': 0, 's': 1, 'w': 1, 'c': 2},
        #                   start_day='2021-07-20', end_day='2022-07-19',
        #                   quar_period=10),
        #cv.contact_tracing(trace_probs={'h': 1, 's': 0.5, 'w': 0.5, 'c': 0.05},
        #                   trace_time={'h': 0, 's': 1, 'w': 1, 'c': 2},
        #                   start_day='2021-03-08',
        #                   quar_period=5),
        cv.dynamic_pars({'iso_factor': {
            'days': te_day,
            'vals': iso_vals
        }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_july,
                 'vals': iso_vals1
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_sep,
                 'vals': iso_vals2
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_oct,
                 'vals': iso_vals3
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_nov,
                 'vals': iso_vals4
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_dec,
                 'vals': iso_vals5
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_march,
                 'vals': iso_vals6
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_june21,
                 'vals': iso_vals7
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_july21,
                 'vals': iso_vals8
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_august21,
                 'vals': iso_vals9
             }}),
        cv.dynamic_pars(
            {'iso_factor':
             {
                 'days': tti_day_sep21,
                 'vals': iso_vals10
             }})
    ]
    #cv.dynamic_pars({'rel_crit_prob': {'days': tti_day_vac, 'vals': 1.2}}),
    #cv.dynamic_pars({'rel_severe_prob': {'days': tti_day_dec, 'vals': 0.7}}),
    #cv.dynamic_pars({'rel_death_prob': {'days': tti_day_dec, 'vals': 1.2}})]
    #cv.vaccine(days=[0,14], rel_sus=0.4, rel_symp=0.2, cumulative=[0.7, 0.3])]

    dose_pars = cvp.get_vaccine_dose_pars()['az']
    dose_pars['interval'] = 7 * 8
    variant_pars = cvp.get_vaccine_variant_pars()['az']
    az_vaccine = sc.mergedicts({'label': 'az_uk'},
                               sc.mergedicts(dose_pars, variant_pars))

    dose_pars = cvp.get_vaccine_dose_pars()['pfizer']
    dose_pars['interval'] = 7 * 8
    variant_pars = cvp.get_vaccine_variant_pars()['pfizer']
    pfizer_vaccine = sc.mergedicts({'label': 'pfizer_uk'},
                                   sc.mergedicts(dose_pars, variant_pars))

    # Loop over vaccination in different ages
    for age in vx_ages:
        vaccine = az_vaccine if (age > 40 and age < 65) else pfizer_vaccine
        subtarget = subtargets[vx_scen][age]
        vx_start_day = sim.day(vx_rollout[age]['start_day'])
        vx_end_day = vx_start_day + vx_duration
        days = np.arange(vx_start_day, vx_end_day)
        #vx = cv.vaccinate(vaccine=vaccine, subtarget=subtarget, days=days)
        vx = cv.vaccinate_prob(vaccine=vaccine, days=days, prob=0.01)
        interventions += [vx]

    analyzers = []

    # add daily age stats analyzer
    analyzers += [cv.daily_age_stats(edges=[0, 30, 65, 80, 100])]
    #analyzers +=  [cv.age_histogram(datafile='uk_stats_by_age.xlsx', edges=np.concatenate([np.linspace(0, 90, 19),np.array([100])]))]

    # Finally, update the parameters
    sim.update_pars(interventions=interventions, analyzers=analyzers)

    # Change death and critical probabilities
    #    interventions += [cv.dynamic_pars({'rel_death_prob':{'days':sim.day('2020-07-01'), 'vals':0.6}})]

    # Finally, update the parameters
    #sim.update_pars(interventions=interventions)
    for intervention in sim['interventions']:
        intervention.do_plot = False

    sim.initialize()

    return sim