Exemplo n.º 1
0
def Select(population, MSR, RV, BI_size, population_K ,nsol, new_msr, new_rv,new_bisize, new_K, generation,self_population,Zdt_definitions,PPlotter,PProblem,EEvolution,population_label,children_label):
    if (Zdt_definitions is None) and (PPlotter is None) and (PProblem is None) and (EEvolution is None):

        zdt_definitions = ZDT3Definitions()
        plotter = Plotter(zdt_definitions)
        problem = ZDT(zdt_definitions)
        evolution = Evolution(problem, 1, len(population))
        evolution.register_on_new_generation(plotter.plot_population_best_front)
        evolution.register_on_new_generation(collect_metrics)
    else:
        zdt_definitions=Zdt_definitions
        plotter=PPlotter
        problem=PProblem
        evolution=EEvolution


    new_pop,objectives,self_population,Final_label,K= evolution.evolve(population,MSR, RV, BI_size, population_K,nsol, new_msr, new_rv, new_bisize, new_K,generation,self_population,population_label,children_label)

    return new_pop,objectives,self_population,zdt_definitions,plotter,problem,evolution,Final_label,K
Exemplo n.º 2
0
    print("Generation: {}".format(generation_num + 1))


collected_metrics = {}


def collect_metrics(population, generation_num):
    pareto_front = population.fronts[0]
    metrics = ZDT3Metrics()
    hv = metrics.HV(pareto_front)
    hvr = metrics.HVR(pareto_front)
    collected_metrics[generation_num] = hv, hvr


pbr_props.show_info = True

pbr_definitions = PBRDefinitions()
plotter = Plotter(pbr_definitions)
problem = PBRCosts(pbr_definitions)
evolution = Evolution(problem, 50, 50)
evolution.register_on_new_generation(plotter.plot_population_best_front)
evolution.register_on_new_generation(print_generation)
evolution.register_on_new_generation(collect_metrics)
pareto_front = evolution.evolve()
plotter.write_report(pareto_front)

pbr_engine.close_aspen()

# plotter.plot_x_y(collected_metrics.keys(), map(lambda (hv, hvr): hvr, collected_metrics.values()), 'generation', 'HVR', 'HVR metric for PBR problem', 'hvr-pbr_problem')
print("--- Whole run: %s seconds ---" % (time.time() - start_time))
Exemplo n.º 3
0
def print_generation(population, generation_num):
    print("Generation: {}".format(generation_num))

def print_metrics(population, generation_num):
    pareto_front = population.fronts[0]
    metrics = ZDT3Metrics()
    hv = metrics.HV(pareto_front)
    hvr = metrics.HVR(pareto_front)
    print("HV: {}".format(hv))
    print("HVR: {}".format(hvr))

collected_metrics = {}
def collect_metrics(population, generation_num):
    pareto_front = population.fronts[0]
    metrics = ZDT3Metrics()
    hv = metrics.HV(pareto_front)
    hvr = metrics.HVR(pareto_front)
    collected_metrics[generation_num] = hv, hvr

zdt_definitions = ZDT3Definitions()
plotter = Plotter(zdt_definitions)
problem = ZDT(zdt_definitions)
evolution = Evolution(problem, 200, 200)
evolution.register_on_new_generation(plotter.plot_population_best_front)
evolution.register_on_new_generation(print_generation)
evolution.register_on_new_generation(print_metrics)
evolution.register_on_new_generation(collect_metrics)
pareto_front = evolution.evolve()

plotter.plot_x_y(collected_metrics.keys(), map(lambda (hv, hvr): hvr, collected_metrics.values()), 'generation', 'HVR', 'HVR metric for ZDT3 problem', 'hvr-zdt3')