示例#1
0
    def __init__(self,
                 params=sib.Params(),
                 window_length=14,
                 maxit0=10,
                 maxit1=10,
                 damp0=0,
                 damp1=0.5,
                 tol=1e-3,
                 memory_decay=1.0,
                 tau=None,
                 print_callback=lambda t, err, f: print(t, err)):

        self.description = "class for BP inference of openABM loop"
        self.authors = "Indaco Biazzo, Alessandro Ingrosso, Alfredo Braunstein"
        self.pseed = params.pseed
        self.prob_sus = params.psus / (1 - self.pseed)
        self.params = params
        self.window_length = window_length
        self.maxit0 = maxit0
        self.maxit1 = maxit1
        self.damp0 = damp0
        self.damp1 = damp1
        self.tol = tol
        self.window_length = window_length
        self.memory_decay = memory_decay
        self.print_callback = print_callback
        self.tau = tau
示例#2
0
    def run_sib_instance(self, inst, callback_fun=callback):
        mu = self.params["mu"]
        sib_pars = sib.Params(prob_r=sib.Gamma(mu=mu))
        sib_fg = sib.FactorGraph(sib_pars, self.contacts_sib,
                                 self.obs_all_sib[inst])

        sib.iterate(sib_fg, maxit=1000, tol=6e-6, callback=callback_fun)

        return sib_fg
                        intervention_options=intervention_options)

##### TRACING SCENARIO #######
scenario_trac = Scenario(model,
                         seed=seed + 1,
                         ranking_options=dict(ranking=RANKINGS["tracing"],
                                              tau=trac_tau),
                         observation_options=observation_options,
                         intervention_options=intervention_options)

pseed = 1e-4
psus = 0.52
mu_r = np.log(1 + mu)
pautoinf = args.pautoinf
bp_ranker = bp_ranker_class(params=sib.Params(prob_r=sib.Exponential(mu=mu_r),
                                              pseed=pseed,
                                              psus=psus,
                                              pautoinf=pautoinf),
                            maxit0=20,
                            maxit1=20,
                            tol=1e-3,
                            memory_decay=1e-5,
                            window_length=window_bp,
                            tau=tau_bp)
bp_ranker.init(N, T)
bp_ranker.__name__ = "bp"
scenario_bp = Scenario(
    model,
    seed=seed,
    ranking_options=dict(ranking=bp_ranker.step_scenario),
    observation_options=observation_options,
    intervention_options=intervention_options,