Updated tournament selection
On small populations, there is now a lower bound on the tournament size.
This commit is contained in:
@ -1,17 +1,14 @@
|
||||
import EasyGA
|
||||
import random
|
||||
|
||||
|
||||
# Create the Genetic algorithm
|
||||
ga = EasyGA.GA()
|
||||
|
||||
ga.population_size = 15
|
||||
ga.chromosome_length = 10
|
||||
ga.generation_goal = 100
|
||||
ga.gene_impl = [random.randint,1,10]
|
||||
|
||||
|
||||
ga.gene_impl = [random.randrange,1,100]
|
||||
|
||||
# Run Everything
|
||||
ga.evolve()
|
||||
|
||||
# Print the current population
|
||||
print(f"Current Generation: {ga.current_generation}")
|
||||
ga.population.print_all()
|
||||
ga.population.print_all()
|
||||
Reference in New Issue
Block a user