MetaHandlers Library
Here are a few MetaHandlers provided by GeneticEngine
Ints
- class geneticengine.grammar.metahandlers.ints.IntRange(min, max)
IntRange(a,b) restricts ints to be between a and b.
The range can be dynamically altered before the grammar extraction Int.__init__.__annotations__[“value”] = Annotated[int, IntRange(c,d)]
Floats
- class geneticengine.grammar.metahandlers.floats.FloatRange(min, max)
FloatRange(a,b) restricts floats to be between a and b.
- The range can be dynamically altered before the grammar extraction:
Float.__annotations__[“value”] = Annotated[float, FloatRange(c,d)].
- Parameters:
min (float)
max (float)
Lists
- class geneticengine.grammar.metahandlers.lists.ListSizeBetween(min, max)
ListSizeBetween(a,b) restricts lists to be of length between a and b and implements a special list mutation.
- The list of options can be dynamically altered before the grammar extraction
Set.__annotations__[“set”] = Annotated[List[Type], ListSizeBetween(c,d)].
- The special list mutation entails three different alterations to the list in question: deletion of a random element;
addition of a random element; and replacement of a random element.
Strings
Vars
- class geneticengine.grammar.metahandlers.vars.VarRange(options)
VarRange([a, b, c]) represents the alternative between a, b, and c.
The list of options can be dynamically altered before the grammar extraction with something like Var.__init__.__annotations__[“name”] = Annotated[str, VarRange([d, e, f])]. The option list must not be empty.
- Parameters:
options (list[T])