Beispiel #1
0
def naive_vs_bitset_seqscout():
    time_xp = 10

    for i, (data, target, enable_i) in enumerate(datasets):
        seq_scout(data,
                  target,
                  time_budget=time_xp,
                  enable_i=enable_i,
                  vertical=False,
                  iterations_limit=2**30)
        seq_scout(data,
                  target,
                  time_budget=time_xp,
                  enable_i=enable_i,
                  vertical=True,
                  iterations_limit=2**30)
Beispiel #2
0
def number_iterations_optima():
    iterations_limit = 100

    # if we want to average
    nb_launched = 5

    data_final = {'cost': [], 'iterations': [], 'dataset_name': []}
    for j, (data, target, enable_i) in enumerate(datasets[:-1]):
        for i in range(nb_launched):
            # we reset the count of iterations
            seqscout.global_var.ITERATION_NUMBER = 0

            result_ucb_opti = seq_scout(data,
                                        target,
                                        enable_i=enable_i,
                                        time_budget=TIME_BUDGET_XP,
                                        iterations_limit=iterations_limit,
                                        vertical=False)

            if len(result_ucb_opti) < TOP_K:
                print("Too few seqscout: {}".format(len(result_ucb_opti)))

            iterations = 1000

            additional_iterations = seqscout.global_var.ITERATION_NUMBER - iterations_limit

            for i in range(10):
                data_add_generic(data_final,
                                 cost=additional_iterations / iterations,
                                 iterations=iterations,
                                 dataset_name=datasets_names[j])
                iterations += 2000

    df = pd.DataFrame(data=data_final)

    sns.set(rc={'figure.figsize': (8, 6.5)})

    plt.clf()
    ax = sns.lineplot(data=df, x='iterations', y='cost', hue='dataset_name')

    plt.savefig('./number_iterations_optima/it_optima.png')
    df.to_pickle('./number_iterations_optima/result')

    if SHOW:
        plt.show()
Beispiel #3
0
def optimizer(data, target, alg_name, time_budget, iteration_limit, enable_i):
    if alg_name == 'misere':
        results = misere(data,
                         target,
                         time_budget=time_budget,
                         iterations_limit=iteration_limit)
    elif alg_name == 'BeamSearch':
        results = beam_search(data,
                              target,
                              time_budget=time_budget,
                              iterations_limit=iteration_limit,
                              enable_i=enable_i)
    elif alg_name == 'SeqScout':
        results = seq_scout(data,
                            target,
                            time_budget=time_budget,
                            iterations_limit=iteration_limit,
                            enable_i=enable_i)
    elif alg_name == 'MCTSExtent':
        results = launch_mcts(data,
                              target,
                              time_budget=time_budget,
                              iterations_limit=iteration_limit)
    else:
        print('Error algo name')
        return

    sorted_patterns = PrioritySet(theta=THETA)
    for result in results:
        sorted_patterns.add(result[1], result[0])

    results_post_opti = optimize_pattern(results, extract_items(data), data,
                                         [], target, TOP_K, sorted_patterns,
                                         enable_i)

    return results, results_post_opti