Clearified some code and how to use i.

This commit is contained in:
Daniel Wilczak
2020-09-21 14:21:32 -04:00
parent 4f3857ca06
commit 170e1e36e4
3 changed files with 70 additions and 12 deletions

View File

@ -5,6 +5,10 @@ import EasyGA
def user_gene_function():
return random.randint(1, 100)
# The user defined Fitness Function
def user_fitness_function():
pass
# Standard user size requirements
Population_size = 10
Chromosome_length = 10
@ -13,5 +17,15 @@ Chromosome_length = 10
ga = EasyGA.GA(Population_size, Chromosome_length,user_gene_function)
ga.initialize()
# Looking at the first chromosome in the population
# Looking to print the first Chromosome
ga.population.chromosomes[0].print_chromosome()
# Looking to print one gene in chromosome 0
ga.population.chromosomes[0].genes[0].print_value()
# Looking to get the data of a chromosome
my_chromosome = ga.population.chromosomes[0].get_chromosome()
print(f"my_chromosome: {my_chromosome}")
# Looking to get the data of one gene in the chromosome
my_gene = ga.population.chromosomes[0].genes[0].get_value()
print(f"my_gene: {my_gene}")