Domain update
Can set the domain to either a range or a list of values.
This commit is contained in:
@ -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()
|
||||
|
||||
Reference in New Issue
Block a user