Example #1
0
if __name__ == '__main__':
    problem = DTLZ2()
    problem.reference_front = read_solutions(
        filename='../../resources/reference_front/DTLZ2.3D.pf'.format(
            problem.get_name()))

    max_evaluations = 150000

    algorithm = MOEAD(
        problem=problem,
        population_size=300,
        crossover=DifferentialEvolutionCrossover(CR=1.0, F=0.5, K=0.5),
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        aggregative_function=Tschebycheff(
            dimension=problem.number_of_objectives),
        neighbor_size=20,
        neighbourhood_selection_probability=0.9,
        max_number_of_replaced_solutions=2,
        weight_files_path='../../resources/MOEAD_weights',
        termination_criterion=StoppingByEvaluations(max=max_evaluations))

    algorithm.observable.register(observer=ProgressBarObserver(
        max=max_evaluations))
    algorithm.observable.register(observer=VisualizerObserver(
        reference_front=problem.reference_front, display_frequency=1000))

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

    label = algorithm.get_name() + "." + problem.get_name()
Example #2
0
def get_algorithm_instance(algo_name):
    algos = {
        'smpso':
        SMPSO(problem=objective_function,
              swarm_size=swarm_size,
              mutation=PolynomialMutation(probability=mutation_probability,
                                          distribution_index=20),
              leaders=CrowdingDistanceArchive(100),
              termination_criterion=StoppingByEvaluations(
                  max_evaluations=max_evaluations)),
        'omopso':
        OMOPSO(problem=objective_function,
               swarm_size=swarm_size,
               epsilon=0.0075,
               uniform_mutation=UniformMutation(
                   probability=mutation_probability, perturbation=0.5),
               non_uniform_mutation=NonUniformMutation(
                   mutation_probability,
                   perturbation=0.5,
                   max_iterations=int(max_evaluations / swarm_size)),
               leaders=CrowdingDistanceArchive(100),
               termination_criterion=StoppingByEvaluations(
                   max_evaluations=max_evaluations)),
        'nsgaii':
        NSGAII(problem=objective_function,
               population_size=30,
               offspring_population_size=30,
               mutation=PolynomialMutation(probability=mutation_probability,
                                           distribution_index=20),
               crossover=SBXCrossover(probability=1.0, distribution_index=20),
               termination_criterion=StoppingByEvaluations(
                   max_evaluations=max_evaluations)),
        'spea2':
        SPEA2(problem=objective_function,
              population_size=30,
              offspring_population_size=30,
              mutation=PolynomialMutation(probability=mutation_probability,
                                          distribution_index=20),
              crossover=SBXCrossover(probability=1.0, distribution_index=20),
              termination_criterion=StoppingByEvaluations(
                  max_evaluations=max_evaluations)),
        'moead':
        MOEAD(
            problem=objective_function,
            population_size=30,
            crossover=DifferentialEvolutionCrossover(CR=1.0, F=0.5, K=0.5),
            mutation=PolynomialMutation(probability=mutation_probability,
                                        distribution_index=20),
            aggregative_function=Tschebycheff(
                dimension=objective_function.number_of_objectives),
            neighbor_size=5,
            neighbourhood_selection_probability=0.9,
            max_number_of_replaced_solutions=2,
            weight_files_path='resources/MOEAD_weights',
            termination_criterion=StoppingByEvaluations(max_evaluations=700)),
        'ibea':
        IBEA(problem=objective_function,
             kappa=1.0,
             population_size=30,
             offspring_population_size=30,
             mutation=PolynomialMutation(probability=mutation_probability,
                                         distribution_index=20),
             crossover=SBXCrossover(probability=1.0, distribution_index=20),
             termination_criterion=StoppingByEvaluations(max_evaluations))
    }
    return algos[algo_name]