def main():
    run_many.build()

    command = './main {} {}'

    pool = multiprocessing.Pool(12)


    def make_candidate(*args):
        def gen():
            while True:
                tasks = [
                    (command.format(*args), random.randrange(1, 1000000000))
                    for _ in range(N)]
                results = list(pool.imap(run_many.worker, tasks))
                for result in results:
                    yield result['adjusted_score'] * 100

        return args, gen()

    #candidates = dict(map(make_candidate, [(0.85, 0.65), (2, 1)]))
    candidates = []
    for _ in range(50):
        candidates.append(make_candidate(
            random.uniform(0.5, 1),
            random.uniform(0.4, 0.9),
            ))
        candidates.append(make_candidate(
            random.uniform(1.5, 2.5),
            random.uniform(0.7, 1.8),
            ))


    thompson_tournament(dict(candidates))
def main():
    run_many.build()

    with open('data/seeds_by_bucket.json') as fin:
        seeds_by_bucket = json.load(fin)
    seeds_by_bucket = {tuple(k): v for k, v in seeds_by_bucket}

    pool = multiprocessing.Pool(12)

    candidate_labels = [(2, 1, 1), (0.643, 0.689, 1)]
    for _ in range(50):
        candidate_labels.append((
            round(0.001 * random.randrange(600, 2000), 3),
            round(0.001 * random.randrange(600, 2000), 3),
            round(0.001 * random.randrange(500, 2000), 3),
            ))

    opt = Optimizer(seeds_by_bucket, candidate_labels)
    while True:
        print('*' * 50)
        opt.show()
        opt.advance(pool.imap)