Domain update

Can set the domain to either a range or a list of values.
This commit is contained in:
SimpleArt
2020-09-24 23:51:21 -04:00
parent 4daec6574d
commit 5c5d6920b2
5 changed files with 18 additions and 30 deletions

View File

@ -3,18 +3,12 @@ import EasyGA
# Create the Genetic algorithm
ga = EasyGA.GA()
#Creating a gene with no fitness
gene1 = ga.make_gene("Im a gene")
gene2 = ga.make_gene("Im also a gene")
#Creating a Chromosome with no genes
chromosome = ga.make_chromosome()
chromosome.add_gene(gene1)
chromosome.add_gene(gene2)
# Creating a populaiton
populaiton = ga.make_population()
populaiton.add_chromosome(chromosome)
# input domain
#ga.domain = range(3, 10)
ga.domain = ['left', 'right']
print(gene1)
print(chromosome)
print(populaiton)
populaiton.print_all()
# initialize random population
ga.initialize()
# Print population
ga.population.print_all()