Added comments
This commit is contained in:
@ -7,7 +7,11 @@ class Initialization_Methods:
|
|||||||
"""Initialization examples that are used as defaults and examples"""
|
"""Initialization examples that are used as defaults and examples"""
|
||||||
|
|
||||||
def random_initialization(ga):
|
def random_initialization(ga):
|
||||||
"""Takes the initialization inputs and returns a population with the given parameters."""
|
"""Takes the initialization inputs and
|
||||||
|
- creates a new population
|
||||||
|
- fills population with chromosomes
|
||||||
|
- fills chromosomes with genes
|
||||||
|
"""
|
||||||
|
|
||||||
# Using the chromosome_impl to set every index inside of the chromosome
|
# Using the chromosome_impl to set every index inside of the chromosome
|
||||||
if ga.chromosome_impl != None:
|
if ga.chromosome_impl != None:
|
||||||
|
|||||||
@ -20,7 +20,9 @@ class Mutation_Methods:
|
|||||||
"""Methods for mutating a single chromosome"""
|
"""Methods for mutating a single chromosome"""
|
||||||
|
|
||||||
def whole_chromosome(ga, chromosome):
|
def whole_chromosome(ga, chromosome):
|
||||||
"""Makes a completely random chromosome"""
|
"""Makes a completely random chromosome.
|
||||||
|
Fills chromosome with new genes.
|
||||||
|
"""
|
||||||
|
|
||||||
# Using the chromosome_impl to set every index inside of the chromosome
|
# Using the chromosome_impl to set every index inside of the chromosome
|
||||||
if ga.chromosome_impl != None:
|
if ga.chromosome_impl != None:
|
||||||
@ -42,7 +44,7 @@ class Mutation_Methods:
|
|||||||
|
|
||||||
|
|
||||||
def single_gene(ga, chromosome):
|
def single_gene(ga, chromosome):
|
||||||
"""Makes a completely random chromosome"""
|
"""Changes a random gene in the chromosome and resets the fitness."""
|
||||||
chromosome.set_fitness(None)
|
chromosome.set_fitness(None)
|
||||||
|
|
||||||
# Using the chromosome_impl
|
# Using the chromosome_impl
|
||||||
|
|||||||
Reference in New Issue
Block a user