Example #1
0
from jmetal.algorithm.multiobjective.nsgaiii import NSGAIII, UniformReferenceDirectionFactory
from jmetal.lab.visualization import Plot
from jmetal.operator import SBXCrossover, PolynomialMutation
from jmetal.problem import DTLZ1
from jmetal.util.observer import ProgressBarObserver
from jmetal.util.solutions import read_solutions
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == '__main__':
    problem = DTLZ1()
    problem.reference_front = read_solutions(
        filename='esources/reference_front/DTLZ1.3D.pf')

    max_evaluations = 25000

    algorithm = NSGAIII(
        problem=problem,
        population_size=92,
        reference_directions=UniformReferenceDirectionFactory(3, n_points=91),
        mutation=PolynomialMutation(probability=1.0 /
                                    problem.number_of_variables,
                                    distribution_index=20),
        crossover=SBXCrossover(probability=1.0, distribution_index=30),
        termination_criterion=StoppingByEvaluations(max=max_evaluations))

    algorithm.observable.register(observer=ProgressBarObserver(
        max=max_evaluations))

    algorithm.run()
    front = algorithm.get_result()
from jmetal.algorithm.multiobjective.smpso import SMPSO
from jmetal.lab.visualization import InteractivePlot, Plot
from jmetal.operator import PolynomialMutation
from jmetal.problem import DTLZ1
from jmetal.util.archive import CrowdingDistanceArchive
from jmetal.util.observer import ProgressBarObserver
from jmetal.util.solutions import print_function_values_to_file, print_variables_to_file
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == '__main__':
    problem = DTLZ1(number_of_objectives=5)

    max_evaluations = 25000
    algorithm = SMPSO(
        problem=problem,
        swarm_size=100,
        mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20),
        leaders=CrowdingDistanceArchive(100),
        termination_criterion=StoppingByEvaluations(max=max_evaluations)
    )

    algorithm.observable.register(observer=ProgressBarObserver(max=max_evaluations))

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

    label = algorithm.get_name() + "." + problem.get_name()

    # Plot front
    plot_front = Plot(plot_title='Pareto front approximation', reference_front=problem.reference_front,
                      axis_labels=problem.obj_labels)
Example #3
0
from jmetal.algorithm import NSGAII
from jmetal.problem import DTLZ1
from jmetal.operator import SBX, Polynomial, BinaryTournamentSelection
from jmetal.component import ProgressBarObserver, VisualizerObserver, RankingAndCrowdingDistanceComparator
from jmetal.util import FrontPlot, SolutionList


if __name__ == '__main__':
    problem = DTLZ1(rf_path='../../resources/reference_front/DTLZ1.pf')

    algorithm = NSGAII(
        problem=problem,
        population_size=100,
        max_evaluations=50000,
        mutation=Polynomial(probability=1.0 / problem.number_of_variables, distribution_index=20),
        crossover=SBX(probability=1.0, distribution_index=20),
        selection=BinaryTournamentSelection(comparator=RankingAndCrowdingDistanceComparator())
    )

    progress_bar = ProgressBarObserver(step=100, maximum=50000)
    visualizer = VisualizerObserver()
    algorithm.observable.register(observer=progress_bar)
    algorithm.observable.register(observer=visualizer)

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

    # Plot frontier to file
    pareto_front = FrontPlot(plot_title='NSGAII-DTLZ1', axis_labels=problem.obj_labels)
    pareto_front.plot(front, reference_front=problem.reference_front)
    pareto_front.to_html(filename='NSGAII-DTLZ1')