geneticengine.grammar.metahandlers.strings
Module Contents
Classes
StringSizeBetween(a,b) restricts strings to be of length between a and b |
|
This metahandler restricts the creation of string nodes so that the |
- class geneticengine.grammar.metahandlers.strings.StringSizeBetween(min, max, options=string.ascii_letters + string.digits)
Bases:
geneticengine.grammar.metahandlers.base.MetaHandlerGenerator
StringSizeBetween(a,b) restricts strings to be of length between a and b and implements a special list mutation.
- The range can be dynamically altered before the grammar extraction
X.__annotations__[“y”] = Annotated[List[Type], ListSizeBetween(c,d)].
- The special string 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.
- generate(r, g, rec, new_symbol, depth, base_type, ctx)
- Parameters:
depth (int)
ctx (dict[str, str])
- mutate(r, g, random_node, depth, base_type, current_node, method=pi_grow_method)
- Parameters:
depth (int)
- crossover(r, g, options, arg, list_type, current_node)
- Parameters:
- classmethod __class_getitem__(args)
- __repr__()
- class geneticengine.grammar.metahandlers.strings.WeightedStringHandler(matrix, alphabet)
Bases:
geneticengine.grammar.metahandlers.base.MetaHandlerGenerator
This metahandler restricts the creation of string nodes so that the output complies with a given alphabet and a matrix of probabilities for each position.
Each row on the matrix should reflect the probability of each character in that position. Thus, the number of cols in the input matrix should be the same as the number of characters in the alphabet.
This refinement will return a string with a size == nrows in the matrix
- generate(r, g, rec, newsymbol, depth, base_type, context)
- Parameters:
depth (int)
context (dict[str, str])
- __repr__()
- classmethod __class_getitem__(args)