Example #1
0
def trial(trials, bins, items, ants, evaporation_rate, bpp2):
    """
    Trials function. Performs n ACO trials
    :param trials: amount of trials
    :param bins: amount of bins
    :param items: amount of items
    :param ants: amount of ants
    :return: a list with minimal fitness, index of the best path,
    best path, bins and execution time.
    """
    overall_output = []
    for i in range(trials):
        b = BinPackingProblem(bins, items, 1, items, bpp2)
        aco = ACO(b, ants, evaporation_rate)
        aco.iterate()
        min_fit, min_index = aco.get_min_fitness()
        best_path = aco.get_best_path()
        b.path_to_bin(best_path)
        output_trial = [
            min_fit, min_index, best_path,
            b.get_bins(),
            aco.get_exec_time()
        ]
        overall_output.append(output_trial)
    return overall_output