def main():
    for x in range(12, 15):
        agents, tasks = generate_painter(x, x, 3)
        for p in [0, 0.05, 0.1, 0.15, 0.2]:
            results = []
            for n in range(10):
                # We give back m tasks in a giveback phase, and each iteration we assign one task,
                # so for m agents we should have a giveback probability < 1/m
                auctioneer = Local_Auctioneer(deepcopy(agents), deepcopy(tasks), p)#1 / ( * len(agents)))
                local_schedule = auctioneer.optimize_schedule()
                local_pr = auctioneer.assignment_probability(local_schedule)

                global_auctioneer = Auctioneer(deepcopy(agents), deepcopy(tasks), p)
                global_schedule = global_auctioneer.optimize_schedule()
                global_pr = auctioneer.assignment_probability(global_schedule)

                #print(",".join([str(x) for x in (x, p, local_pr, global_pr)]))
                results += [(local_pr, global_pr)]

            local_results, global_results = zip(*results)

            local_mean = np.mean(local_results)
            global_mean = np.mean(global_results)

            # https://stackoverflow.com/questions/15033511/compute-a-confidence-interval-from-sample-data
            local_min_ci, local_max_ci = st.t.interval(0.95, len(local_results) - 1, loc=np.mean(local_results), scale=st.sem(local_results))
            global_min_ci, global_max_ci = st.t.interval(0.95, len(global_results) - 1, loc=np.mean(global_results), scale=st.sem(global_results))

            A = [x, p, local_mean, global_mean, local_min_ci, local_max_ci, global_min_ci, global_max_ci]

            print(",".join([str(z) for z in A]))
def main():
    agents, tasks = generate_painter(X, Y, 3)

    # We give back m tasks in a giveback phase, and each iteration we assign one task,
    # so for m agents we should have a giveback probability < 1/m
    auctioneer = Auctioneer(agents, tasks, 0.25)  #1 / ( * len(agents)))

    schedule = auctioneer.optimize_schedule()

    Agent.print_schedule(X, Y, auctioneer, schedule)
Beispiel #3
0
def main():
    agents, tasks = generate_painter(X, Y, 3)

    # nFeas = The number of feasible 1-moves
    # Given a schedule, we can move tasks equal to the number of agents.
    # Using the result by Osman, we set alpha = n * Nfeas, gamma = n
    alpha = math.factorial(X * Y)
    # The number of iterations is n

    annealer = Annealer(agents, tasks, 2500, 100, 0.1, 1)

    schedule = annealer.optimize_schedule()

    Agent.print_schedule(X, Y, annealer, schedule)
def one_X(X):
    Y = X
    agents, tasks = generate_painter(X, Y, parameters["num_agents"])

    # https://stackoverflow.com/questions/5442910/python-multiprocessing-pool-map-for-multiple-arguments
    results = []
    temps = eval(parameters["temps"])
    for t in temps:
        results += [one_temp(t, agents, tasks)]
    # https://stackoverflow.com/questions/12974474/how-to-unzip-a-list-of-tuples-into-individual-lists
    means, min_cis, max_cis, mean_times = zip(*results)

    with open("anneal_data/{}.csv".format(X), "w") as f:
        for i in range(len(temps)):
            f.write("{},{},{},{},{}\n".format(temps[i], means[i], min_cis[i],
                                              max_cis[i], mean_times[i]))
def one_X(X):
    Y = X
    agents, tasks = generate_painter(X, Y, parameters["num_agents"])
    # The probability of running a giveback phase should not be greater than
    # 1 / |Agents|. Otherwise, it will take a VERY long time to finish, and
    # probabilistically might never finish at all!

    max_pr = 1 / (len(agents) + parameters["pr_epsilon"])

    # Over some range of max_pr
    splits = range(0, parameters["num_splits"] + 1)

    # https://stackoverflow.com/questions/5442910/python-multiprocessing-pool-map-for-multiple-arguments
    results = []
    for s in splits:
        #print(s)
        results += [one_split(max_pr, s, agents, tasks)]
    # https://stackoverflow.com/questions/12974474/how-to-unzip-a-list-of-tuples-into-individual-lists
    means, min_cis, max_cis, mean_times = zip(*results)

    with open("data/{}.csv".format(X), "w") as f:
        for i in range(len(splits)):
            f.write("{},{},{},{},{}\n".format(splits[i], means[i], min_cis[i], max_cis[i], mean_times[i]))
import numpy as np
import scipy.stats as st

from Base.problem_generator import generate_painter

import sys

#X_arg = int(sys.argv[1])

# The X-Y size of our grid of tasks
X = 12

NUM_TESTS = 10
NUM_SPLITS = 20

agents, tasks = generate_painter(X, X, 3)


def main():
    # The probability of running a giveback phase should not be greater than
    # 1 / |Agents|. Otherwise, it will take a VERY long time to finish, and
    # probabilistically might never finish at all!

    # Create a randomly generated schedule and judge it
    s = random_schedule(agents, tasks)

    auctioneer = Auctioneer(None, None, None)
    results = []
    for i in range(100):
        results += [
            auctioneer.assignment_probability(random_schedule(agents, tasks))