Changeset 1133 for framspy/evolalg/examples/standard.py
- Timestamp:
- 04/23/21 01:08:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/evolalg/examples/standard.py
r1131 r1133 4 4 import numpy as np 5 5 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 12 11 13 from evolalg.base.lambda_step import LambdaStep 12 13 from FramsticksLib import FramsticksLib 14 from evolalg.base.union_step import UnionStep 14 15 from evolalg.experiment import Experiment 15 16 from evolalg.fitness.fitness_step import FitnessStep 16 17 from evolalg.mutation_cross.frams_cross_and_mutate import FramsCrossAndMutate 17 18 from evolalg.population.frams_population import FramsPopulation 18 from evolalg.repair.multistep import MultistepRepair19 19 from evolalg.repair.remove.field import FieldRemove 20 20 from evolalg.selection.tournament import TournamentSelection 21 21 from evolalg.statistics.halloffame_stats import HallOfFameStatistics 22 22 from evolalg.statistics.statistics_deap import StatisticsDeap 23 from evolalg.base.union_step import UnionStep24 23 from evolalg.utils.population_save import PopulationSave 25 from evolalg.utils.stable_generation import StableGeneration26 from FramsticksLib import FramsticksLib27 24 28 25 29 26 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)27 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). 31 28 32 29 … … 60 57 61 58 def print_population_count(pop): 62 print("Current :", len(pop))59 print("Current popsize:", len(pop)) 63 60 return pop # Each step must return a population 64 61 … … 85 82 fields_defaults={"velocity": None, "data->recording": None}) # custom definitions and handling 86 83 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}) 88 85 ] 89 86 + 90 ([FieldRemove("recording", None)] if EVAL_LIFESPAN_BEHAVIOR else [ ])87 ([FieldRemove("recording", None)] if EVAL_LIFESPAN_BEHAVIOR else [FieldRemove("fitness", None)]) 91 88 + 92 89 [print_population_count] # Stages can also be any Callable
Note: See TracChangeset
for help on using the changeset viewer.