예제 #1
0
파일: prepare.py 프로젝트: DLT1412/hawks
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
예제 #2
0
 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