def main():
    results = []
    for i, p in enumerate(parameters_list):
        f = NAME_TO_FUNC[p["func"]]
        agents = f(**{k: v for k, v in p.items() if k != "func"})
        optimal = opt.budget_constraint_min_d1(agents)
        plot3d(agents, optimal_point=optimal, fname=f"figs/dataset_{i}.html")

        for _ in tqdm(range(N_SAMPLES)):
            agents = f(**{k: v for k, v in p.items() if k != "func"})
            optimal = opt.budget_constraint_min_d1(agents)
            mean = opt.mean(agents)
            this_row = copy.deepcopy(p)
            this_row["dataset_num"] = i
            this_row["title"] = get_title_from_params(p)
            this_row["optimal"] = optimal
            this_row["mean"] = mean
            this_row["optimal_sc"] = social_cost(agents, optimal, metrics.d_1)
            this_row["mean_sc"] = social_cost(agents, mean, metrics.d_1)
            this_row[
                "distortion"] = this_row["mean_sc"] / this_row["optimal_sc"]
            results.append(this_row)

    df = pd.DataFrame(results)
    df.to_csv("results/mean_approx.csv", index=False)
예제 #2
0
def plot_datasets():
    for i, agents, name in enumerate(DATASETS):
        optimal = opt.budget_constraint_min_d1(agents)
        plot3d(agents,
               optimal_point=optimal,
               fname=f"figs/dataset_sequential_{i}.html")
        print(distortion(agents, opt.mean(agents), optimal, metrics.d_1))
예제 #3
0
def main():
    rows = []
    for i, (agents, name) in enumerate(DATASETS):
        results = sequential_deliberation_many_times(
            agents, bargain.mean, metrics.d_1, NUM_ITERS,
            NUM_SAMPLES)  # list of results
        optimal = opt.budget_constraint_min_d1(agents)

        for r in results:
            rows.append([i, name, distortion(agents, r, optimal, metrics.d_1)])
    df = pd.DataFrame(rows, columns=['dataset_ind', 'title', 'distortion'])
    df.to_csv("results/sequential.csv", index=False)
예제 #4
0
def main():
    agents = get_d_dimensional_agents_summing_to_1_with_clusters(
        NUM_AGENTS, d=DIM, noise=0.04, n_clusters=2, weights=[0.2, 0.8]
    )

    optimal = opt.budget_constraint_min_d1(agents)

    intermediates = sequential_deliberation_list(
        agents, bargain.mean, metrics.d_1, T=NUM_ITERS
    )

    distortions = [distortion(agents, i, optimal, metrics.d_1) for i in intermediates]

    px.line(distortions).write_html("figs/line.html")
def main():
    results = []
    for i, p in enumerate(parameters_list):
        for _ in range(100):
            agents = get_d_dimensional_agents_summing_to_1_with_clusters(
                **{k: v
                   for k, v in p.items() if k != "func"})
            optimal = opt.budget_constraint_min_d1(agents)
            dist = distortion(agents, opt.mean(agents), optimal, metrics.d_1)
            print(dist)
            if dist > 1.4:
                print(agents)
                print(optimal)
                print(dist)
                plot3d(agents,
                       optimal_point=optimal,
                       fname=f"figs/high_distortion_agents.html")
                return
예제 #6
0
def sequential_deliberation_once():
    agents = get_d_dimensional_agents_summing_to_1_with_clusters(
        NUM_AGENTS, d=DIM, noise=0.04, n_clusters=2, weights=[0.2, 0.8])

    optimal = opt.budget_constraint_min_d1(agents)

    a_T = sequential_deliberation(agents,
                                  bargain.mean,
                                  metrics.d_1,
                                  T=NUM_ITERS)

    sc_opt = social_cost(agents, optimal, metrics.d_1)
    sc_mean = social_cost(agents, opt.mean(agents), metrics.d_1)
    sc_seq = social_cost(agents, a_T, metrics.d_1)

    print("Social cost of the optimal: ", sc_opt)
    print("Social cost of the mean: ", sc_mean)
    print("Social cost of the sequential mean: ", sc_seq)

    plot3d(agents, found_point=a_T, optimal_point=optimal)