Changeset 1060 for framspy/FramsticksEvolution.py
- Timestamp:
- 01/24/21 13:29:42 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksEvolution.py
r1057 r1060 14 14 15 15 def frams_evaluate(frams_cli, individual): 16 genotype = individual[0] # [0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.16 genotype = individual[0] # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str. 17 17 data = frams_cli.evaluate([genotype]) 18 18 # print("Evaluated '%s'" % genotype, 'evaluation is:', data) … … 22 22 default_evaluation_data = evaluation_data[""] 23 23 fitness = [default_evaluation_data[crit] for crit in OPTIMIZATION_CRITERIA] 24 except (KeyError, TypeError) as e: # the evaluation may have failed for invalid genotypes (or some other reason)25 fitness = [-1] * len(OPTIMIZATION_CRITERIA) 24 except (KeyError, TypeError) as e: # the evaluation may have failed for an invalid genotype (such as X[@][@] with "Don't simulate genotypes with warnings" option) or for some other reason 25 fitness = [-1] * len(OPTIMIZATION_CRITERIA) # fitness of -1 is intended to discourage further propagation of this genotype via selection ("this one is very poor") 26 26 print("Error '%s': could not evaluate genotype '%s', returning fitness %s" % (str(e), genotype, fitness)) 27 27 return fitness … … 29 29 30 30 def frams_crossover(frams_cli, individual1, individual2): 31 geno1 = individual1[0] # [0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.32 geno2 = individual2[0] # [0] because we can't (?) have a simple str as a deap genotype/individual, only list of str.31 geno1 = individual1[0] # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str. 32 geno2 = individual2[0] # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str. 33 33 individual1[0] = frams_cli.crossOver(geno1, geno2) 34 34 individual2[0] = frams_cli.crossOver(geno1, geno2) … … 37 37 38 38 def frams_mutate(frams_cli, individual): 39 individual[0] = frams_cli.mutate( individual[0])39 individual[0] = frams_cli.mutate([individual[0]])[0] # individual[0] because we can't (?) have a simple str as a deap genotype/individual, only list of str. 40 40 return individual, 41 41
Note: See TracChangeset
for help on using the changeset viewer.