Example #1
0
                        label='Mean')
    axes[1, 1].legend()

    #plt.figure(figsize=(8,6))
    for i, n_p in enumerate(n_pop):
        axes[2, 1].errorbar(range(o),
                            mean_time[i, :],
                            std_time[i, :],
                            label='Pop size = ' + str(n_p))
        axes[2, 1].set_xticks(range(o))
        axes[2, 1].set_xticklabels(n_offspring)
    axes[2, 1].errorbar(range(o),
                        np.mean(mean_time, axis=0),
                        np.mean(std_time, axis=0),
                        linestyle='--',
                        linewidth=2,
                        label='Mean')
    axes[2, 1].legend()


KP_instance = KPSolver("instances/kp/kp-n279.txt")
TSP_instance = TSPSolver("instances/tsp/tsp-a280.txt")
TTP_inst = TTPInstance("instances/ttp/ttp-a280-n279.txt")
TTP_instance = TTPSolver(TTP_inst)

n_pop = [5, 10, 20, 50, 100]
n_offspring = [10, 20, 50, 100, 200]

#data = EA_paramters_tuning(TTP_instance,n_pop=n_pop,n_offspring=n_offspring,problem = 'TTP',initial_strategy = 'random',local_search=True,verbose = True, repeat= 10)
plot(data, n_pop, n_offspring)
Example #2
0
        sub_data.append((solution.score, time() - start))
        """


        data.append(sub_data)

    # If you add a strategy, please add its label here:
    strategies_labels = ("independent", "local_search", "annealing") #, "hybrid_EA/20/20")

    data = np.array(data).transpose(1, 0, 2)
    return strategies_labels, data


for instance_uri in instances_uris:
    try:
        instance = TTPSolver(TTPInstance(instance_uri))
    except:
        continue
    name = instance_uri.split("/")[-1]
    # Get a array of size (n_strategies x n_repeat x 2)
    # The dimension of size 3 is for (length, time duration)
    # The dimension of size n_repeat is for average and standard deviation purpose

    strategies_labels, data = try_strategies(instance)

    plt.boxplot(data[:, :, 0].T)
    plt.xticks(range(1, len(strategies_labels) + 1), strategies_labels, rotation=45)
    plt.title("score for: " + name)
    plt.savefig("./experiment_data/overall_analysis/ttp/" + name + ".score.png",  bbox_inches='tight')
    plt.clf()