def run_DynamicNSGAII(problems):

    for problem in problems:

        time_counter = TimeCounter(delay=1)
        time_counter.observable.register(problem[1])
        time_counter.start()

        max_evaluations = 25000
        algorithm = DynamicNSGAII(
            problem=problem[1],
            population_size=100,
            offspring_population_size=100,
            mutation=PolynomialMutation(probability=1.0 / problem[1].number_of_variables, distribution_index=20),
            crossover=SBXCrossover(probability=1.0, distribution_index=20),
            termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations),
        )

        algorithm.observable.register(observer=ProgressBarObserver(max=max_evaluations))
        algorithm.observable.register(observer=VisualizerObserver())
        algorithm.observable.register(observer=PlotFrontToFileObserver(problem[0] + "_dynamic_front_vis"))
        algorithm.observable.register(observer=WriteFrontToFileObserver(problem[0] + "_dynamic_front"))
        #algorithm.observable.register(observer=BasicObserver())

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

        non_dominated_solutions = get_non_dominated_solutions(front)

        # save to files
        print_function_values_to_file(front, 'FUN.DYNAMICNSGAII.' + problem[0])
        print_variables_to_file(front, 'VAR.DYNAMICNSGAII.' + problem[0])

        # Plot
        plot_front = Plot(title='Pareto front approximation', axis_labels=['x', 'y'])
        plot_front.plot(front, label='DynamicNSGAII-FDA2', filename='DYNAMICNSGAII-'+problem[0], format='png')
Exemple #2
0
from jmetal.algorithm.multiobjective.gde3 import DynamicGDE3
from jmetal.problem.multiobjective.fda import FDA2
from jmetal.util.observable import TimeCounter
from jmetal.util.observer import WriteFrontToFileObserver, PlotFrontToFileObserver
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == '__main__':
    problem = FDA2()

    time_counter = TimeCounter(delay=1)
    time_counter.observable.register(problem)
    time_counter.start()

    algorithm = DynamicGDE3(
        problem=problem,
        population_size=100,
        cr=0.5,
        f=0.5,
        termination_criterion=StoppingByEvaluations(max=500))

    algorithm.observable.register(
        observer=PlotFrontToFileObserver('dynamic_front_vis'))
    algorithm.observable.register(
        observer=WriteFrontToFileObserver('dynamic_front'))

    algorithm.run()
from jmetal.util.observer import PlotFrontToFileObserver, WriteFrontToFileObserver

from jmetal.algorithm.multiobjective.smpso import DynamicSMPSO
from jmetal.operator import PolynomialMutation
from jmetal.problem.multiobjective.fda import FDA2
from jmetal.util.archive import CrowdingDistanceArchive
from jmetal.util.observable import TimeCounter
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == '__main__':
    problem = FDA2()

    time_counter = TimeCounter(delay=15)
    time_counter.observable.register(problem)
    time_counter.start()

    max_evaluations = 25000
    algorithm = DynamicSMPSO(
        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=PlotFrontToFileObserver('dynamic_front_vis'))
    algorithm.observable.register(observer=WriteFrontToFileObserver('dynamic_front'))

    algorithm.run()
Exemple #4
0
from jmetal.algorithm.multiobjective.gde3 import DynamicGDE3
from jmetal.problem.multiobjective.fda import FDA2
from jmetal.util.observable import TimeCounter
from jmetal.util.observer import PlotFrontToFileObserver, WriteFrontToFileObserver
from jmetal.util.termination_criterion import StoppingByEvaluations

if __name__ == "__main__":
    problem = FDA2()

    time_counter = TimeCounter(delay=1)
    time_counter.observable.register(problem)
    time_counter.start()

    algorithm = DynamicGDE3(
        problem=problem,
        population_size=100,
        cr=0.5,
        f=0.5,
        termination_criterion=StoppingByEvaluations(max_evaluations=500),
    )

    algorithm.observable.register(
        observer=PlotFrontToFileObserver("dynamic_front_vis"))
    algorithm.observable.register(
        observer=WriteFrontToFileObserver("dynamic_front"))

    algorithm.run()