Esempio n. 1
0
def run_SPEA2(SIR_name, version, test_size):
    evaluator = evaluation.VEval(SIR_name, version, test_size)
    dim = test_size

    population = GA.initial_genes(dim, GLOB.POP)
    archive = []
    population_history = [population]
    archive_history = [archive]
    if GLOB.DEBUG:
        print('0', len(population))
    for i in range(GLOB.MAX_IT):
        #update
        union = population + archive
        GA.evaluate(union, evaluator)
        get_fitness(union)
        archive = select(union)
        population = GA.crossover(archive)[GLOB.POP + 1:]
        if GLOB.DEBUG:
            print(i, len(population))

        #save history
        population_history.append(population)
        archive_history.append(archive)

    first_pareto = get_first_pareto(archive)  #final result
    return first_pareto
Esempio n. 2
0
def run_TAEA(input_fname):
    modify = modifier.modify_testcase(input_fname)
    dim = modify.get_datasize()

    population = GA.initial_genes(dim, GLOB.POP)
    population_history = [population]
    CA, DA = [], [] #covergence archive, diversity archive
    GA.evaluate(population,modify)

    for i in range(GLOB.MAX_IT):
        collect_non_dominated(population,CA,DA)
        new_pop = GA.crossover(CA+DA)
        GA.evaluate(new_pop,modify)
Esempio n. 3
0
def run_NSGA3(input_fname):
    modify = modifier.modify_testcase(input_fname)
    dim = modify.get_datasize()
    reference = get_ref()

    population = GA.initial_genes(dim,GLOB.POP)
    population_history = [population]
    for i in range(GLOB.MAX_IT):
        new_pop = GA.crossover(population)
        GA.evaluate(new_pop,modify)
        pareto = GA.get_pareto(new_pop)
        new_pop = select(pareto)
        population = new_pop
        population_history.append(population)

    first_pareto = get_first_pareto(population) #final result
Esempio n. 4
0
def run_NSGA2(SIR_name, version, test_size):
    evaluator = evaluation.VEval(SIR_name, version, test_size)
    dim = test_size
    population = GA.initial_genes(dim, GLOB.POP, version)
    if GLOB.DEBUG:
        print('0', len(population))
    population_history = [population]
    for i in range(GLOB.MAX_IT):
        new_pop = GA.crossover(population, mr=1 / dim)
        GA.evaluate(new_pop, evaluator)
        pareto = GA.get_pareto(new_pop)
        new_pop = select(pareto)
        population = new_pop
        population_history.append(population)
        if GLOB.DEBUG:
            print(i, len(population))

    first_pareto = get_first_pareto(population)  #final result
    return first_pareto
Esempio n. 5
0
def run_TAEA(SIR_name, version, test_size):
    evaluator = evaluation.VEval(SIR_name, version, test_size)
    dim = test_size

    population = GA.initial_genes(dim, GLOB.POP,version)
    population_history = [population]
    CA, DA = [], [] #covergence archive, diversity archive
    GA.evaluate(population,evaluator)
    if GLOB.DEBUG:
        print('0', 0)

    for i in range(GLOB.MAX_IT):
        CA, DA = collect_non_dominated(population,CA,DA)
        #print(len(CA), len(DA))
        population = new_crossover(CA,DA,GLOB.CROSSOVER_RATE,1/test_size)
        GA.evaluate(population,evaluator)
        if GLOB.DEBUG:
            print(i,len(CA+DA), 'covergence archive size', len(CA), 'divergence archive size', len(DA))

    return CA+DA