Commit 0069971f authored by David A.. Werner's avatar David A.. Werner
Browse files

Added property access to survival rates

parent 15d07009
......@@ -13,6 +13,24 @@ class GenerationInfo(namedtuple('GenerationInfo', ['generation_number', 'fitness
def max_fitness(self):
return max(self.fitness_values)
def child_survival_rate(self):
if self.num_matings is None:
return None
return float(self.surviving_children) / self.num_matings
def mutant_survival_rate(self):
if self.num_mutants is None:
return None
return float(self.surviving_mutants) / self.num_mutants
def parent_survival_rate(self):
if self.num_ancestors is None:
return None
return float(self.surviving_ancestors) / self.num_ancestors
class EvolutionParameters(object):
def __init__(self, max_population, num_matings, num_mutants, max_mutations, **kwargs):
self.max_population = max_population
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment