if __name__ == "__main__": problem = DTLZ2() problem.reference_front = read_solutions( filename="resources/reference_front/DTLZ2.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_evaluations=max_evaluations), ) algorithm.run() front = get_non_dominated_solutions(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}")
problem=problem, population_size=Configuration.population, reference_directions=UniformReferenceDirectionFactory( Configuration.goal_num, n_points=Configuration.population - 1), # offspring_population_size = Configuration.population, 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) # termination_criterion = StoppingByQualityIndicator(quality_indicator=HyperVolume, expected_value=1, # degree=0.9) # selection = BinaryTournamentSelection() ) """==========================调用算法模板进行种群进化=========================""" progress_bar = ProgressBarObserver(max=max_evaluations) algorithm.observable.register(progress_bar) algorithm.run() front = algorithm.get_result() """==================================输出结果==============================""" # Save results to file print_function_values_to_file( front, os.path.join(target_dir, '/FUN.' + algorithm.label)) print_variables_to_file( front, os.path.join(target_dir, '/VAR.' + algorithm.label)) print(f'Algorithm: ${algorithm.get_name()}') print(f'Problem: ${problem.get_name()}') print(f'Computing time: ${algorithm.total_computing_time}')
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_evaluations=max_evaluations)) progress_bar = ProgressBarObserver(max=max_evaluations) algorithm.observable.register(progress_bar) algorithm.run() bag += algorithm.get_result() print(len(bag)) print_solutions_to_file( bag, DIRECTORY_RESULTS + 'Solutions.bag.' + algorithm.label) ranking = FastNonDominatedRanking() ranking.compute_ranking(bag) front = ranking.get_subfront(0) print(len(front)) # Save results to file print_solutions_to_file(front, DIRECTORY_RESULTS + 'front0.' + algorithm.label) plot_front = Plot(title='Pareto front approximation', axis_labels=['x', 'y', 'z']) plot_front.plot(front, label='NSGAII-ZDT7',