Ignore:
Timestamp:
04/23/21 01:08:00 (4 years ago)
Author:
Maciej Komosinski
Message:

Invalid genotypes are now removed immediately from the population and new ones are generated to keep population size constant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • framspy/evolalg/examples/standard.py

    r1131 r1133  
    44import numpy as np
    55
    6 #TODO add new example: steadystate.py (analogous to standard.py) OR include steadysteate as a mode in this example or in niching_novelty.py
    7 #TODO extend both standard.py and steadystate.py to support >1 criteria (using DEAP's selNSGA2() and selSPEA2())
    8 #TODO add comments to all examples in this directory
    9 #TODO add to standard.py and steadystate.py evaluating each genotype in HOF N (configurable, default 10) times when the evolution ends instead of evaluating the last population as it is now in niching_novelty.py
    10 #TODO protect all examples against invalid genotypes (fill population until all genotypes are conrrectly evaluated). And maybe remove invalid.py if it overlaps with (is a subset of) other examples
    11 #TODO "debug" mode, displaying Step-based class names and their arguments so it is easy to see what happens during evolution
     6# TODO add new example: steadystate.py (analogous to standard.py) OR include steadysteate as a mode in this example or in niching_novelty.py
     7# TODO extend both standard.py and steadystate.py to support >1 criteria (using DEAP's selNSGA2() and selSPEA2())
     8# TODO add comments to all examples in this directory
     9# TODO add to standard.py and steadystate.py evaluating each genotype in HOF N (configurable, default 10) times when the evolution ends instead of evaluating the last population as it is now in niching_novelty.py
     10# TODO "debug" mode, displaying Step-based class names and their arguments so it is easy to see what happens during evolution
    1211
    13 from evolalg.base.lambda_step import LambdaStep
     12
     13from FramsticksLib import FramsticksLib
     14from evolalg.base.union_step import UnionStep
    1415from evolalg.experiment import Experiment
    1516from evolalg.fitness.fitness_step import FitnessStep
    1617from evolalg.mutation_cross.frams_cross_and_mutate import FramsCrossAndMutate
    1718from evolalg.population.frams_population import FramsPopulation
    18 from evolalg.repair.multistep import MultistepRepair
    1919from evolalg.repair.remove.field import FieldRemove
    2020from evolalg.selection.tournament import TournamentSelection
    2121from evolalg.statistics.halloffame_stats import HallOfFameStatistics
    2222from evolalg.statistics.statistics_deap import StatisticsDeap
    23 from evolalg.base.union_step import UnionStep
    2423from evolalg.utils.population_save import PopulationSave
    25 from evolalg.utils.stable_generation import StableGeneration
    26 from FramsticksLib import FramsticksLib
    2724
    2825
    2926
    30 EVAL_LIFESPAN_BEHAVIOR = False  # if False, standard evaluation criteria can be used as fitness as defined by the -opt parameter. If True, it is assumed that the expdef provides custom dictionary fields in evaluation and they need to be handled specifically in python source code below (this could be parametrized in command-line too, but the syntax would be complex)
     27EVAL_LIFESPAN_BEHAVIOR = False  # if False, standard evaluation criteria can be used as fitness as defined by the -opt parameter. If True, it is assumed that the expdef provides custom dictionary fields in evaluation, and they need to be handled specifically in python source code below (this could be parametrized in command-line too, but the syntax would be complex).
    3128
    3229
     
    6057
    6158def print_population_count(pop):
    62     print("Current:", len(pop))
     59    print("Current popsize:", len(pop))
    6360    return pop  # Each step must return a population
    6461
     
    8582                    fields_defaults={"velocity": None, "data->recording": None})  # custom definitions and handling
    8683        if EVAL_LIFESPAN_BEHAVIOR else
    87         FitnessStep(frams_lib, fields={parsed_args.opt: "fitness", }, fields_defaults={})
     84        FitnessStep(frams_lib, fields={parsed_args.opt: "fitness", }, fields_defaults={parsed_args.opt: None})
    8885        ]
    8986        +
    90         ([FieldRemove("recording", None)] if EVAL_LIFESPAN_BEHAVIOR else [])
     87        ([FieldRemove("recording", None)] if EVAL_LIFESPAN_BEHAVIOR else [FieldRemove("fitness", None)])
    9188        +
    9289        [print_population_count]  # Stages can also be any Callable
Note: See TracChangeset for help on using the changeset viewer.