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)]

class geneticengine.grammar.metahandlers.ints.IntList(elements)

IntList([a_1, .., a_n]) restricts ints to be an element from the list.

[a_1, .., a_n].

The range can be dynamically altered before the grammar extraction

Int.__init__.__annotations__[“value”] = Annotated[int, IntList[a_1, .., a_n]]

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)

class geneticengine.grammar.metahandlers.floats.FloatList(elements)

FloatList([a_1, .., a_n]) restricts floats to be an element from the list [a_1, .., a_n].

The range can be dynamically altered before the grammar extraction

Float.__init__.__annotations__[“value”] = Annotated[float, FloatList[a_1, .., a_n]]

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.

class geneticengine.grammar.metahandlers.lists.ListSizeBetweenWithoutListOperations(min, max)

ListSizeBetweenWithoutListOperations(a,b) restricts lists to be of length between a and b.

The list of options can be dynamically altered before the grammar extraction

Set.__annotations__[“set”] = Annotated[List[Type], ListSizeBetweenWithoutListOperations(c,d)]

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])