Renamed parent selection subclasses to rank/fitness
This commit is contained in:
@ -53,7 +53,7 @@ class attributes:
|
||||
self.make_gene = create_gene
|
||||
|
||||
# Methods for accomplishing Parent-Selection -> Crossover -> Survivor_Selection -> Mutation
|
||||
self.parent_selection_impl = Parent_Selection.Tournament.with_replacement
|
||||
self.parent_selection_impl = Parent_Selection.Rank.tournament
|
||||
self.crossover_individual_impl = Crossover_Methods.Individual.single_point
|
||||
self.crossover_population_impl = Crossover_Methods.Population.random_selection
|
||||
self.survivor_selection_impl = Survivor_Selection.fill_in_best
|
||||
|
||||
@ -2,9 +2,9 @@ import random
|
||||
|
||||
class Parent_Selection:
|
||||
|
||||
class Tournament:
|
||||
class Rank:
|
||||
|
||||
def with_replacement(ga):
|
||||
def tournament(ga):
|
||||
"""
|
||||
Will make tournaments of size tournament_size and choose the winner (best fitness) from the tournament and use it as a parent for the next generation
|
||||
The total number of parents selected is determined by parent_ratio, an attribute to the GA object.
|
||||
@ -46,9 +46,9 @@ class Parent_Selection:
|
||||
break
|
||||
|
||||
|
||||
class Roulette:
|
||||
class Fitness:
|
||||
|
||||
def roulette_selection(ga):
|
||||
def roulette(ga):
|
||||
"""Roulette selection works based off of how strong the fitness is of the
|
||||
chromosomes in the population. The stronger the fitness the higher the probability
|
||||
that it will be selected. Using the example of a casino roulette wheel.
|
||||
@ -95,7 +95,7 @@ class Parent_Selection:
|
||||
break
|
||||
|
||||
|
||||
def stochastic_selection(ga):
|
||||
def stochastic(ga):
|
||||
"""Stochastic roulette selection works based off of how strong the fitness is of the
|
||||
chromosomes in the population. The stronger the fitness the higher the probability
|
||||
that it will be selected. Instead of dividing the fitness by the sum of all fitnesses
|
||||
|
||||
Reference in New Issue
Block a user