Пример #1
0
from jmetal.algorithm.multiobjective.nsgaii import NSGAII
from jmetal.operator import SBXCrossover, PolynomialMutation
from jmetal.problem import ZDT2
from jmetal.util.comparator import GDominanceComparator
from jmetal.util.solution import print_function_values_to_file, print_variables_to_file, read_solutions
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == '__main__':
    problem = ZDT2()
    problem.reference_front = read_solutions(
        filename='resources/reference_front/ZDT2.pf')

    reference_point = [0.2, 0.5]

    max_evaluations = 25000
    algorithm = NSGAII(
        problem=problem,
        population_size=100,
        offspring_population_size=100,
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        crossover=SBXCrossover(probability=1.0, distribution_index=20),
        dominance_comparator=GDominanceComparator(reference_point),
        termination_criterion=StoppingByEvaluations(max=max_evaluations))

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

    # Save results to file
    print_function_values_to_file(front, 'FUN.' + algorithm.label)
Пример #2
0
from jmetal.algorithm import NSGAII
from jmetal.component.comparator import RankingAndCrowdingDistanceComparator
from jmetal.operator import NullMutation, SBX, BinaryTournamentSelection, Polynomial
from jmetal.problem import ZDT1, ZDT2
from jmetal.component.quality_indicator import HyperVolume
from jmetal.util.laboratory import Experiment

# Configure experiment
problem_list = [ZDT1(), ZDT2()]
algorithm_list = []

for problem in problem_list:
    algorithm_list.append(
        ('NSGAII_A',
         NSGAII(problem=problem,
                population_size=100,
                max_evaluations=25000,
                mutation=NullMutation(),
                crossover=SBX(probability=1.0, distribution_index=20),
                selection=BinaryTournamentSelection(
                    comparator=RankingAndCrowdingDistanceComparator()))))
    algorithm_list.append(
        ('NSGAII_B',
         NSGAII(problem=problem,
                population_size=100,
                max_evaluations=25000,
                mutation=Polynomial(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
                crossover=SBX(probability=1.0, distribution_index=20),
                selection=BinaryTournamentSelection(
                        mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables,
                                                    distribution_index=20),
                        leaders=CrowdingDistanceArchive(100),
                        termination_criterion=StoppingByEvaluations(max=max_evaluations)
                    ),
                    algorithm_tag='SMPSO',
                    problem_tag=problem_tag,
                    run=run,
                )
            )

    return jobs


if __name__ == '__main__':
    # Configure the experiments
    jobs = configure_experiment(problems={'ZDT1': ZDT1(), 'ZDT2': ZDT2(), 'ZDT3': ZDT3()}, n_run=31)

    # Run the study
    output_directory = 'data'

    experiment = Experiment(output_dir=output_directory, jobs=jobs)
    experiment.run()

    # Generate summary file
    generate_summary_from_experiment(
        input_dir=output_directory,
        reference_fronts='/home/user/jMetalPy/resources/reference_front',
        quality_indicators=[GenerationalDistance(), EpsilonIndicator(), HyperVolume([1.0, 1.0])]
    )
Пример #4
0
                        leaders=CrowdingDistanceArchive(100),
                        termination_criterion=StoppingByEvaluations(
                            max=max_evaluations)),
                    algorithm_tag='SMPSO',
                    problem_tag=problem_tag,
                    run=run,
                ))

    return jobs


if __name__ == '__main__':
    # Configure the experiments
    jobs = configure_experiment(problems={
        'ZDT1': ZDT1(),
        'ZDT2': ZDT2(),
        'ZDT3': ZDT3()
    },
                                n_run=31)

    # Run the study
    output_directory = 'data'

    experiment = Experiment(output_dir=output_directory, jobs=jobs)
    experiment.run()

    # Generate summary file
    generate_summary_from_experiment(
        input_dir=output_directory,
        reference_fronts='/home/user/jMetalPy/resources/reference_front',
        quality_indicators=[
Пример #5
0
                        termination_criterion=StoppingByEvaluations(
                            max_evaluations=max_evaluations),
                    ),
                    algorithm_tag="SMPSO",
                    problem_tag=problem_tag,
                    run=run,
                ))

    return jobs


if __name__ == "__main__":
    # Configure the experiments
    jobs = configure_experiment(problems={
        "ZDT1": ZDT1(),
        "ZDT2": ZDT2(),
        "ZDT3": ZDT3()
    },
                                n_run=25)

    # Run the study
    output_directory = "data"

    experiment = Experiment(output_dir=output_directory, jobs=jobs)
    experiment.run()

    # Generate summary file
    generate_summary_from_experiment(
        input_dir=output_directory,
        reference_fronts="resources/reference_front",
        quality_indicators=[