コード例 #1
0
        #                     crossover=SBXCrossover(probability=1, distribution_index=20),
        #                     # selection=RouletteWheelSelection(),
        #                     termination_criterion=StoppingEvaluator
        #                     # termination_criterion = StoppingByQualityIndicator(quality_indicator=HyperVolume, expected_value=1,
        #                     #                                                  degree=0.9)
        #                     # selection = BinaryTournamentSelection()
        #                     )

        algorithm = NSGAII(
            target_pattern=goal_selection_flag,
            target_value_threshold=target_values,
            problem=problem,
            population_size=Configuration.population,
            offspring_population_size=Configuration.population,
            population_evaluator=MultiprocessEvaluator(
                Configuration.ProcessNum),
            # population_evaluator=SequentialEvaluator(),
            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))
        """==========================调用算法模板进行种群进化========================="""
        progress_bar = ProgressBarObserver(max=max_evaluations)
        algorithm.observable.register(progress_bar)
        algorithm.run()
        front = algorithm.get_result()

        # Save results to file
        fun_name = 'FUN.' + str(round_index) + '_' + algorithm.label
コード例 #2
0
        Goal_num = Configuration.goal_num
        """===============================实例化问题对象============================"""
        problem = CarBehindAndInFront(Goal_num, Configuration)
        """=================================算法参数设置============================"""
        max_evaluations = population * search_round
        # print(max_evaluations)

        if Configuration.algorithm == "NSGA_II":
            algorithm = NSGAII(
                population_evaluator=MultiprocessEvaluator(
                    Configuration.ProcessNum),
                # population_evaluator=SequentialEvaluator(),
                problem=problem,
                population_size=Configuration.population,
                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=FitnessValue, expected_value=1, degree=0.9)
                # selection = BinaryTournamentSelection()
            )
        elif Configuration.algorithm == "NSGA_III" or Configuration.algorithm == "Brute_Froce":
            algorithm = NSGAIII(
                population_evaluator=MultiprocessEvaluator(
                    Configuration.ProcessNum),
                # population_evaluator=SequentialEvaluator(),
                problem=problem,
                population_size=Configuration.population,
                reference_directions=UniformReferenceDirectionFactory(