def __init__( self, problem: MOProblem, selection_operator: Type[SelectionBase] = None, population_size: int = None, population_params: Dict = None, initial_population: Population = None, a_priori: bool = False, interact: bool = False, n_iterations: int = 10, n_gen_per_iter: int = 100, total_function_evaluations: int = 0, lattice_resolution: int = None, use_surrogates: bool = False, ): super().__init__( a_priori=a_priori, interact=interact, n_iterations=n_iterations, n_gen_per_iter=n_gen_per_iter, total_function_evaluations=total_function_evaluations, selection_operator=selection_operator, use_surrogates=use_surrogates, ) if lattice_resolution is None: lattice_res_options = [49, 13, 7, 5, 4, 3, 3, 3, 3] if problem.n_of_objectives < 11: lattice_resolution = lattice_res_options[ problem.n_of_objectives - 2] else: lattice_resolution = 3 self.reference_vectors = ReferenceVectors(lattice_resolution, problem.n_of_objectives) if initial_population is not None: # Population should be compatible. self.population = initial_population # TODO put checks here. elif initial_population is None: if population_size is None: population_size = self.reference_vectors.number_of_vectors self.population = Population(problem, population_size, population_params, use_surrogates) self._function_evaluation_count += population_size self._ref_vectors_are_focused: bool = False
def __init__( self, problem: MOProblem, population_size: int = None, population_params: Dict = None, initial_population: Population = None, lattice_resolution: int = None, n_iterations: int = 10, n_gen_per_iter: int = 100, total_function_evaluations: int = 0, use_surrogates: bool = False, ): a_priori: bool = True interact: bool = True if problem.ideal is None or problem.nadir is None: msg = ( f"The problem instance should contain the information about ideal and " f"nadir point.") raise eaError(msg) BaseEA.__init__( self=self, a_priori=a_priori, interact=interact, n_iterations=n_iterations, n_gen_per_iter=n_gen_per_iter, total_function_evaluations=total_function_evaluations, use_surrogates=use_surrogates, ) scalarization_methods = [ StomASF(ideal=problem.ideal * problem._max_multiplier), # PointMethodASF( # nadir=problem.nadir * problem._max_multiplier, # ideal=problem.ideal * problem._max_multiplier, # ), AugmentedGuessASF( nadir=problem.nadir * problem._max_multiplier, ideal=problem.ideal * problem._max_multiplier, indx_to_exclude=[], ), ] if lattice_resolution is None: lattice_res_options = [49, 13, 7, 5, 4, 3, 3, 3, 3] if len(scalarization_methods) < 11: lattice_resolution = lattice_res_options[ len(scalarization_methods) - 2] else: lattice_resolution = 3 reference_vectors = ReferenceVectors( lattice_resolution=lattice_resolution, number_of_objectives=len(scalarization_methods), ) population_size = reference_vectors.number_of_vectors population = Population(problem, population_size, population_params) self.reference_vectors = reference_vectors self.scalarization_methods = scalarization_methods if initial_population is not None: # Population should be compatible. self.population = initial_population # TODO put checks here. elif initial_population is None: if population_size is None: population_size = self.reference_vectors.number_of_vectors self.population = Population(problem, population_size, population_params, use_surrogates) self._function_evaluation_count += population_size self._ref_vectors_are_focused: bool = False
_, pref_int_rvea = int_rvea.iterate(pref_int_rvea) _, pref_int_nsga = int_nsga.iterate(pref_int_nsga) # build initial composite front cf = generate_composite_front(int_rvea.population.objectives, int_nsga.population.objectives) # the following two lines for getting pareto front by using pymoo framework problemR = get_problem(problem_name.lower(), n_var, n_obj) ref_dirs = get_reference_directions("das-dennis", n_obj, n_partitions=12) pareto_front = problemR.pareto_front(ref_dirs) # creates uniformly distributed reference vectors reference_vectors = ReferenceVectors(lattice_resolution, n_obj) # learning phase for i in range(L): data_row[["problem", "num_obj", "iteration", "num_gens"]] = [ problem_name, n_obj, i + 1, gen, ] # After this class call, solutions inside the composite front are assigned to reference vectors base = baseADM(cf, reference_vectors) # generates the next reference point for the next iteration in the learning phase response = gp.generateRP4learning(base)