Beispiel #1
0
def cost_of_random_solutions(people_in, tables_in, days):
    """
    Computes the average cost of 100 random solutions
    """
    config.build_smart = False
    costs = 0
    for _ in range(100):
        people = deepcopy(people_in)
        tables = deepcopy(tables_in)
        solution = build_guess(people, tables, days)
        costs += solution.cost
    avg_cost = costs / 100.0
    config.build_smart = True
    return avg_cost
Beispiel #2
0
def main(input_data):
    people = deepcopy(input_data.people)
    tables = deepcopy(input_data.tables)

    # for initializing axes of graph
    baseline_cost = cost_of_random_solutions(people, tables, input_data.days)
    dummy_solution = DummySolution(baseline_cost)
    yield (dummy_solution, dummy_solution.dummy_T)

    init_solution = build_guess(people, tables, input_data.days)
    best_solution = deepcopy(init_solution)
    print_init_cost(init_solution.cost)

    if config.anneal:
        for (solution, T) in anneal(init_solution):
            print_progress(solution, T)
            yield solution, T
    else:
        yield best_solution, None