def configure_experiment(problems: dict, n_run: int): jobs = [] max_evaluations = 25000 for run in range(n_run): for problem_tag, problem in problems.items(): jobs.append( Job( 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), termination_criterion=StoppingByEvaluations( max_evaluations=max_evaluations), ), algorithm_tag="NSGAII", problem_tag=problem_tag, run=run, )) jobs.append( Job( algorithm=GDE3( problem=problem, population_size=100, cr=0.5, f=0.5, termination_criterion=StoppingByEvaluations( max_evaluations=max_evaluations), ), algorithm_tag="GDE3", problem_tag=problem_tag, run=run, )) jobs.append( Job( 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_evaluations=max_evaluations), ), algorithm_tag="SMPSO", problem_tag=problem_tag, run=run, )) return jobs
from jmetal.algorithm.multiobjective.gde3 import GDE3 from jmetal.problem import ZDT1 from jmetal.util.solution import ( print_function_values_to_file, print_variables_to_file, read_solutions, ) from jmetal.util.termination_criterion import StoppingByKeyboard if __name__ == "__main__": problem = ZDT1() problem.reference_front = read_solutions( filename="resources/reference_front/ZDT1.pf") algorithm = GDE3(problem=problem, population_size=100, cr=0.5, f=0.5, termination_criterion=StoppingByKeyboard()) algorithm.run() front = algorithm.get_result() # Save results to file print_function_values_to_file(front, "FUN." + algorithm.label) print_variables_to_file(front, "VAR." + algorithm.label) print(f"Algorithm: {algorithm.get_name()}") print(f"Problem: {problem.get_name()}") print(f"Computing time: {algorithm.total_computing_time}")
from jmetal.util.solutions.comparator import GDominanceComparator from jmetal.util.termination_criterion import StoppingByEvaluations if __name__ == "__main__": problem = ZDT2() problem.reference_front = read_solutions( filename="resources/reference_front/{}.pf".format(problem.get_name())) max_evaluations = 25000 reference_point = [0.2, 0.5] algorithm = GDE3( problem=problem, population_size=100, cr=0.5, f=0.5, termination_criterion=StoppingByEvaluations( max_evaluations=max_evaluations), dominance_comparator=GDominanceComparator(reference_point), ) algorithm.observable.register( observer=VisualizerObserver(reference_front=problem.reference_front, reference_point=reference_point)) algorithm.run() front = algorithm.get_result() # Plot front plot_front = Plot(plot_title="Pareto front approximation", reference_front=problem.reference_front,
from jmetal.algorithm.multiobjective.gde3 import GDE3 from jmetal.problem.singleobjective.unconstrained import Rastrigin from jmetal.util.observer import PrintObjectivesObserver from jmetal.util.solution_list import print_function_values_to_file, print_variables_to_file from jmetal.util.termination_criterion import StoppingByEvaluations if __name__ == '__main__': problem = Rastrigin(10) algorithm = GDE3( problem=problem, population_size=100, cr=0.5, f=0.5, termination_criterion=StoppingByEvaluations(50000) ) algorithm.observable.register(observer=PrintObjectivesObserver(1000)) 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()) print('Algorithm (continuous problem): ' + algorithm.get_name()) print('Problem: ' + problem.get_name()) print('Computing time: ' + str(algorithm.total_computing_time))
from examples.multiobjective.zdt1_modified import ZDT1Modified from jmetal.algorithm.multiobjective.gde3 import GDE3 from jmetal.util.evaluator import SparkEvaluator from jmetal.util.solution import print_function_values_to_file, print_variables_to_file from jmetal.util.termination_criterion import StoppingByEvaluations if __name__ == '__main__': problem = ZDT1Modified() algorithm = GDE3(problem=problem, population_size=10, cr=0.5, f=0.5, termination_criterion=StoppingByEvaluations(max=100), population_evaluator=SparkEvaluator()) 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()) print('Algorithm (continuous problem): ' + algorithm.get_name()) print('Problem: ' + problem.get_name()) print('Computing time: ' + str(algorithm.total_computing_time))
def configure_experiment(problems: dict, n_run: int): jobs = [] num_processes = config.num_cpu population = 10 generations = 10 max_evaluations = population * generations for run in range(n_run): for problem_tag, problem in problems.items(): reference_point = FloatSolution([0, 0], [1, 1], problem.number_of_objectives, ) reference_point.objectives = np.repeat(1, problem.number_of_objectives).tolist() jobs.append( Job( algorithm=NSGAIII( problem=problem, population_size=population, mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20), crossover=SBXCrossover(probability=1.0, distribution_index=20), population_evaluator=MultiprocessEvaluator(processes=num_processes), termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations), reference_directions=UniformReferenceDirectionFactory(4, n_points=100), ), algorithm_tag='NSGAIII', problem_tag=problem_tag, run=run, ) ) jobs.append( Job( algorithm=GDE3( problem=problem, population_size=population, population_evaluator=MultiprocessEvaluator(processes=num_processes), termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations), cr=0.5, f=0.5, ), algorithm_tag='GDE3', problem_tag=problem_tag, run=run, ) ) jobs.append( Job( algorithm=SPEA2( problem=problem, population_size=population, mutation=PolynomialMutation(probability=1.0 / problem.number_of_variables, distribution_index=20), crossover=SBXCrossover(probability=1.0, distribution_index=20), population_evaluator=MultiprocessEvaluator(processes=num_processes), termination_criterion=StoppingByEvaluations(max_evaluations=max_evaluations), offspring_population_size=population, ), algorithm_tag='SPEA2', problem_tag=problem_tag, run=run, ) ) return jobs