Пример #1
0
def permute_parameters(runs: int):

    populations = (50, 100, 200)
    generations = (50, 100)
    crossovers = (60, 80)
    mutations = (10, 20)

    ga = GA.CustomGA()

    times = []
    hits = []
    for pop in populations:
        for gen in generations:
            for cross in crossovers:
                for mut in mutations:
                    ga.populationSize = pop
                    ga.num_generations = gen
                    ga.birthRate = cross
                    ga.mutationRate = mut

                    before = time.time()
                    hits_rate = parallel_run(ga.run, runs)
                    after = time.time()

                    estimated_time = round(after - before, 2)
                    times.append(estimated_time)
                    hits.append(hits_rate)
    return hits, times