Exemple #1
0
        instance='BB20019',
        path='../resources',
        score_list=[SumOfPairs(),
                    PercentageOfTotallyConservedColumns()])

    # creates the algorithm
    max_evaluations = 25000
    reference_point = [-0.6, 11000]

    algorithm = NSGAII(
        problem=problem,
        population_size=100,
        offspring_population_size=100,
        mutation=ShiftClosedGapGroups(probability=0.3),
        crossover=SPXMSA(probability=0.7),
        dominance_comparator=GDominanceComparator(reference_point),
        termination_criterion=StoppingByEvaluations(
            max_evaluations=max_evaluations))

    algorithm.observable.register(observer=ProgressBarObserver(
        max=max_evaluations))
    algorithm.observable.register(observer=PlotFrontToFileObserver(
        output_directory='fronts_zdt1'))

    algorithm.run()
    front = algorithm.get_result()

    # plot front
    plot_front = Plot(title='Pareto front approximation',
                      axis_labels=['%SOP', '%TC'])
    plot_front.plot(front, label='NSGAII-BB20019', filename='NSGAII-BB20019')
if __name__ == '__main__':
    problem = ZDT2()
    problem.reference_front = read_solutions(
        filename='../../resources/reference_front/{}.pf'.format(
            problem.get_name()))

    max_evaluations = 25000

    algorithm = GDE3(
        problem=problem,
        population_size=100,
        cr=0.5,
        f=0.5,
        termination_criterion=StoppingByEvaluations(max=max_evaluations),
        dominance_comparator=GDominanceComparator([0.5, 0.5]))

    algorithm.observable.register(observer=ProgressBarObserver(
        max=max_evaluations))
    algorithm.observable.register(observer=VisualizerObserver(
        reference_point=([0.5, 0.5])))

    algorithm.run()
    front = algorithm.get_result()

    # Save results to file
    print_function_values_to_file(
        front, 'FUN.' + algorithm.get_name() + "." + problem.get_name())
    print_variables_to_file(
        front, 'VAR.' + algorithm.get_name() + "." + problem.get_name())