Changeset 1289 for framspy/evolalg/structures
- Timestamp:
- 01/15/24 05:43:37 (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/evolalg/structures/individual.py
r1272 r1289 3 3 4 4 class Individual: 5 only_positive_fitness = True # Note: when using diversification techniques (e.g. niching), setting this toFalse and allowing negative fitness values requires verifying/improving diversification formulas. Dividing fitness by similarity (or multiplying by diversity) may have undesired consequences when fitness can be both positive and negative (e.g. low similarity may make positive fitness values higher and negative fitness values lower, while the intention would be to improve fitness for low similarity).5 fitness_set_negative_to_zero = False # "static" field. Note: when using diversification techniques (e.g. niching or novelty), leaving this as False and allowing negative fitness values requires verifying/improving diversification formulas. Dividing fitness by similarity (or multiplying by diversity) may have undesired consequences when fitness can be both positive and negative (e.g. low similarity may make positive fitness values higher and negative fitness values lower, while the intention would be to improve fitness for low similarity). 6 6 7 7 def __init__(self): … … 29 29 fitness = evaluate(genotype) 30 30 if fitness is not BAD_FITNESS: # BAD_FITNESS indicates that the genotype was not valid or some other problem occurred during evaluation 31 if self.only_positive_fitness: 32 if fitness < 0: 33 fitness = 0 31 if Individual.fitness_set_negative_to_zero and fitness < 0: 32 fitness = 0 34 33 self.fitness = self.rawfitness = fitness 35 34
Note: See TracChangeset
for help on using the changeset viewer.