コード例 #1
0
ファイル: baselines.py プロジェクト: wctaiwan/pomcp-diffusion
def run_once():
    model = DiffusionModel(n, m, ep, p, q)
    while not model.has_stabilized():
        observed_infected, resistant = model.get_observed_infected(), model.get_resistant()
        if model.has_stabilized(observed_infected, resistant):
            # Observed model has stabilized; take no action for one round
            target = None
        else:
            if strategy == 1:
                target = random.choice(tuple(observed_infected))
            elif strategy == 2:
                target = get_best_target(model, observed_infected, resistant)
            else:
                target = random.choice(tuple(set(range(n)).difference(resistant)))
        model.step(target)
    return model.get_value()
コード例 #2
0
ファイル: pomcp.py プロジェクト: wctaiwan/pomcp-diffusion
def run_once():
    model = DiffusionModel(n, m, ep, p, q)
    search_tree = {}
    nsim_total = 0
    while not model.has_stabilized():
        best_target, nsim = search(model, search_tree)
        model.step(best_target)
        nsim_total += nsim
    return model.get_value(), nsim_total