Commit 24af9984 authored by David A.. Werner's avatar David A.. Werner
Browse files

Population is now sized based on evolution parameter values

parent 21b69633
......@@ -32,10 +32,14 @@ class EvolutionSimulator(object):
def __init__(self, population, evolution_parameters=None, random_number_generator=None, random_seed=None, pool=None):
"""Population can be array of manducas or tuple of (f, num_pop), where each call to f()
produces a member of the population"""
if isinstance(population, tuple):
self.population = [population[0]() for _ in range(population[1])]
if evolution_parameters is None:
self.evolution_parameters = copy.copy(self.__class__.default_evolution_parameters)
else:
self.evolution_parameters = copy.copy(evolution_parameters)
if isinstance(population, list):
self.population = population
else:
self.population = [population() for _ in range(self.evolution_parameters.max_population)]
n_before = len(self.population)
self.population = list(set(self.population))
n_after = len(self.population)
......@@ -43,10 +47,6 @@ class EvolutionSimulator(object):
self._children = []
self._mutants = []
self.history = []
if evolution_parameters is None:
self.evolution_parameters = copy.copy(self.__class__.default_evolution_parameters)
else:
self.evolution_parameters = copy.copy(evolution_parameters)
if random_number_generator is None:
self.random_number_generator = np.random.RandomState()
else:
......
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