コード例 #1
0
ファイル: fixtures.py プロジェクト: kpv15/genetic_algorithm
def populations(individuals_lists):
    first_list, second_list, third_list, ones_list, zeros_list = individuals_lists
    first = make_population(*first_list)
    second = make_population(*second_list)
    third = make_population(*third_list)
    ones = make_population(*ones_list)
    zeros = make_population(*zeros_list)
    return first, second, third, ones, zeros
コード例 #2
0
ファイル: fixtures.py プロジェクト: kpv15/genetic_algorithm
def big_populations(individuals):
    first, second, third, ones, zeros = individuals

    def _make_population(individual):
        return make_population(*([individual for _ in range(25)] + [ones for _ in range(25)] + [zeros for _ in range(25)]))

    first_population = _make_population(first)
    second_population = _make_population(second)
    third_population = _make_population(third)
    ones_population = make_population(*([ones for _ in range(50)] + [first for _ in range(25)]))
    zeros_population = make_population(*([zeros for _ in range(50)] + [first for _ in range(25)]))

    return first_population, second_population, third_population, ones_population, zeros_population
コード例 #3
0
ファイル: fixtures.py プロジェクト: kpv15/genetic_algorithm
def small_population_and_individuals():
    first, second, ones = Individual(), Individual(), Individual()
    first["x"] = make_chromosome(np.asarray([1, 0, 1, 0, 1, 0, 1, 0]))
    second["x"] = make_chromosome(np.asarray([0, 1, 0, 1, 0, 1, 0, 0]))
    ones["x"] = make_chromosome(np.asarray([1, 1, 1, 1, 1, 1, 1, 1]))
    population = make_population(first, second)
    return population, first, second, ones
コード例 #4
0
ファイル: selection.py プロジェクト: kpv15/genetic_algorithm
 def invoke(self, population: Population) -> Population:
     preprocessed_list = self._preprocess_fitness_list(population)
     subpopulation = []
     for i in range(self["count"]):
         subpopulation.append(self._select(population, preprocessed_list))
     return make_population(*subpopulation)
コード例 #5
0
ファイル: selection.py プロジェクト: kpv15/genetic_algorithm
 def get_elite_as_population(self) -> Population:
     return make_population(*self["elite"])
コード例 #6
0
ファイル: fixtures.py プロジェクト: kpv15/genetic_algorithm
 def _make_population(individual):
     return make_population(*([individual for _ in range(25)] + [ones for _ in range(25)] + [zeros for _ in range(25)]))