Changeset 1146 for framspy/evolalg


Ignore:
Timestamp:
08/03/21 14:00:12 (3 years ago)
Author:
Maciej Komosinski
Message:

Cosmetic

Location:
framspy/evolalg
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • framspy/evolalg/base/union_step.py

    r1139 r1146  
    1212            self.steps = [steps]
    1313
     14    def init(self):
     15        for s in self.steps:
     16            if isinstance(s, Step):
     17                s.init()
     18
    1419    def call(self, population):
    1520        super(UnionStep, self).call(population)
  • framspy/evolalg/examples/niching_novelty.py

    r1145 r1146  
    141141
    142142
     143def func_raw(ind): setattr(ind, "fitness", ind.fitness_raw)
     144
     145
     146def func_novelty(ind): setattr(ind, "fitness", ind.dissim)
     147
     148
     149def func_knn_novelty(ind): setattr(ind, "fitness", ind.dissim)
     150
     151
    143152def func_niching(ind): setattr(ind, "fitness", ind.fitness_raw * (1 + ind.dissim))
    144 
    145 
    146 def func_raw(ind): setattr(ind, "fitness", ind.fitness_raw)
    147 
    148 
    149 def func_novelty(ind): setattr(ind, "fitness", ind.dissim)
    150 
    151 
    152 def func_knn_novelty(ind): setattr(ind, "fitness", ind.dissim)
    153153
    154154
     
    180180    new_generation_stages = [FramsCrossAndMutate(frams_lib, cross_prob=0.2, mutate_prob=0.9)]
    181181
    182     # Steps after new population is created. Executed exacly once per generation.
     182    # Steps after new population is created. Executed exactly once per generation.
    183183    generation_modifications = []
    184184
     
    245245        generation_modifications.append(raw)
    246246
    247     if parsed_args.fit == Fitness.niching:
     247    if parsed_args.fit == Fitness.niching: # TODO reduce redundancy in the four cases below: dictionary?
    248248        niching = UnionStep([
    249249            dissim,
     
    297297
    298298    # -------------------------------------------------
    299     # End stages: this will execute exacly once after all generations.
     299    # End stages: this will execute exactly once after all generations.
    300300    end_stages = [
    301301        replace_with_hof,
  • framspy/evolalg/examples/standard.py

    r1140 r1146  
    88# TODO add comments to all examples in this directory
    99# TODO add to standard.py and steadystate.py evaluating each genotype in HOF N (configurable, default 20) times when the evolution ends, as it is in niching_novelty.py
    10 # TODO "--debug" mode, indent nested steps (pre++, post-- of a static counter?) and print their arguments so it is easy to see what happens during evolution
     10# TODO "-debug" mode, indent nested steps (pre++, post-- of a static counter?) and print their arguments so it is easy to see what happens during evolution
    1111
    1212
     
    8080    ])
    8181
    82     fitness_remove = UnionStep(
     82    fitness_remove = UnionStep(  # evaluate performance and fitness, rename some of the fields, and remove some performance fields that we get from Framsticks, but we don't need them here
    8383        [
    8484        FitnessStep(frams_lib, fields={"velocity": "fitness", "data->recording": "recording"},
    8585                    fields_defaults={"velocity": None, "data->recording": None})  # custom definitions and handling
    8686        if EVAL_LIFESPAN_BEHAVIOR else
    87         FitnessStep(frams_lib, fields={parsed_args.opt: "fitness", }, fields_defaults={parsed_args.opt: None})
     87        FitnessStep(frams_lib, fields={parsed_args.opt: "fitness"}, fields_defaults={parsed_args.opt: None})
    8888        ]
    8989        +
  • framspy/evolalg/statistics/statistics_deap.py

    r1139 r1146  
    2626        if self.verbose:
    2727            print(self.logbook.stream)
     28
     29    def compile(self, data):
     30        return self.stats.compile(data)
     31
     32
Note: See TracChangeset for help on using the changeset viewer.