def individual(self): bounds = {'x0': [0.0, 20.0], 'x1': [0.0, 20.0]} ind = Individual(bounds) ind.position = np.array([10.0, 10.0]) return ind
def test_termination_check(self, ga): bounds = {'x0': [0.0, 10.0], 'x1': [0.0, 10.0]} best = Individual(bounds) best.fitness = 0.0001 ga.best_individual = best tm = ErrorTerminationManager(ga, 0.0, 1e-3) ret_bool = tm.termination_check() assert ret_bool
def population(): population = [] for i in range(1, 5 + 1): bounds = { 'x0': [0.0, 10.0], 'x1': [0.0, 10.0] } _ind = Individual(bounds) _ind.fitness = i population.append(_ind) return population
def parent_a(): bounds = { 'x0': [0.0, 10.0], 'x1': [0.0, 10.0] } return Individual(bounds)
def soga(self): bounds = {'x0': [0.0, 10.0], 'x1': [0.0, 10.0]} soga = SOGA(bounds, n_individuals=30, n_iterations=100) soga.initialise_population() soga.best_individual = Individual(bounds) soga.best_individual.fitness = 0.5 for idx, individual in enumerate(soga.population): individual.fitness = 5.0 return soga
def individual(self): ind = Individual({'x0': [0.0, 10.0], 'x1': [0.0, 10.0]}) ind.position = np.array([2.0, 7.0]) return ind
def fully_populate_with_random_individuals(self): while self.size < ga_configs.configs['max_population_size']: g = create_random_genes() i = Individual(g) self._individuals.append(i)