def setup_ga(ga_params, constraint_params, objective_params, dataset_obj): # Validate the constraints parameters Genotype.validate_constraints(constraint_params) # Setup the objective parameters objective_dict, ga_params = _setup_objectives(objective_params, ga_params) # Create the DEAP toolbox and generate the initial population toolbox, initial_pop = ga.main_setup( objective_dict, dataset_obj, ga_params, constraint_params ) return objective_dict, ga_params, toolbox, initial_pop
def setup_ga(self, dataset_obj, config): # Validate the constraints parameters Genotype.validate_constraints(config["constraints"]) # Setup the objective parameters objective_dict = self._setup_objectives(config) # Create the DEAP toolbox and generate the initial population toolbox, initial_pop = ga.main_setup( objective_dict=objective_dict, dataset_obj=dataset_obj, ga_params=config["ga"], constraint_params=config["constraints"] ) # Set the DEAP toolbox as an attr self.deap_toolbox = toolbox # Return the objective dict and the initial population return objective_dict, initial_pop