예제 #1
0
def readRunMeanFitness(runPath):

  # Read the run file to get update and mean fitness lists
  runData = avida.read_data(runPath, ['update', 'ave_fitness'])
  updates = runData['update']
  fitnesses = runData['ave_fitness']

  # Convert data to dictionary {update: fitness}
  fitnessData = {}
  for update, fitness in zip(updates, fitnesses):
    fitnessData[update] = fitness

  return fitnessData
예제 #2
0
def readPopulation(runPath, z = False):

  # Read population file
  popData = avida.read_data(runPath, ['num_cpus', 'sequence'], z)
  numbers = popData['num_cpus']
  sequences = popData['sequence']

  # Create genotypes based on the sequences and their number
  genotypes = []
  for number, sequence in zip(numbers, sequences):
    for n in range(int(number)):
      genotypes.append(Genotype(sequence))

  return genotypes
예제 #3
0
def readRunGenotypes(runPath, auto_ancestor = False, ancestor = None):

  # Read the run file to get update and sequence lists
  runData = avida.read_data(runPath, ['update', 'dom_sequence'])
  updates = runData['update']
  sequences = runData['dom_sequence']

  # Convert data to dictionary {update: genotype}
  genotypes = {}
  for update, sequence in zip(updates, sequences):
    genotypes[update] = Genotype(sequence, ancestor)

  # Set the first genotype (min update) as the ancestor
  if auto_ancestor:
    ancestor = genotypes[min(updates)]
    for update in updates:
      genotypes[update].ancestor = ancestor

  return genotypes