def first_estimations(distributions, strats, c_index, team):
    """
    """

    epoch = 1
    for s in strats:
        i = 0
        while i < settings.N:
            # n, z = get_rand()
            n, z = launch_simulation_with_strategy(s, team)
            distributions[str(s[0])].get_posterior(n, z)
            plot.plot_distributions_cluster(distributions, c_index, epoch, name)
            i += 1
            epoch += 1
def simulate_pairs(distributions, strats, cluster, cluster_index, d1, d2, epoch):
    """
    """

    r = 0
    while r < settings.N:
        epoch += 1
        s = strats[int(d1)]
        n, z = launch_simulation_with_strategy(s, cluster)
        distributions[d1].get_posterior(n, z)
        s = strats[int(d2)]
        n, z = launch_simulation_with_strategy(s, cluster)
        distributions[d2].get_posterior(n, z)
        plot.plot_distributions_cluster(distributions, cluster_index, epoch, name)
t_begin = time.clock()
storage = db.Database(settings.DATABASE)
cluster_dict = storage.build_cluster_dictionnary()
strats = storage.get_detailled_strategies()
l_team = settings.TEAM_PATH + " " + settings.TEAM_PARAM

# For each cluster
for c in cluster_dict:
    if c == 3:
        continue
    cluster = cluster_dict[c]
    for t in cluster[0]:
        team = t[2]
        name = t[1]
        distributions = init_distributions(strats)
        plot.plot_distributions_cluster(distributions, 0, 0, name)
        first_estimations(distributions, strats, c, team)
        strat_pairs = build_strategies_pairs(strats)
        strat_comparisons = init_strat_comparisons(strats)
        p = 0
        while p < len(strat_pairs):
            if len(strat_pairs) > 0:
                cp = strat_pairs[p]
                d1 = distributions[str(cp[0])]
                d2 = distributions[str(cp[1])]
                conclusion = fe.formation_evaluator(d1.prior, d2.prior)
                if conclusion == 0:
                    var_d1 = d1.get_variance()
                    var_d2 = d2.get_variance()
                    if var_d1 < var_d2:
                        conclusion = 1