Ignore:
Timestamp:
01/15/24 05:43:37 (4 months ago)
Author:
Maciej Komosinski
Message:

fitness_set_negative_to_zero boolean (a.k.a. "only positive fitness", needed for novelty and niching diversity control) becomes a command-line flag instead of a hardcoded value

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/evolalg/structures/individual.py

    r1272 r1289  
    33
    44class Individual:
    5     only_positive_fitness = True # Note: when using diversification techniques (e.g. niching), setting this to 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).
     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).
    66
    77    def __init__(self):
     
    2929        fitness = evaluate(genotype)
    3030        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
    3433        self.fitness = self.rawfitness = fitness
    3534
Note: See TracChangeset for help on using the changeset viewer.