geneticengine.grammar.metahandlers.strings ========================================== .. py:module:: geneticengine.grammar.metahandlers.strings Attributes ---------- .. autoapisummary:: geneticengine.grammar.metahandlers.strings.T Classes ------- .. autoapisummary:: geneticengine.grammar.metahandlers.strings.StringSizeBetween geneticengine.grammar.metahandlers.strings.WeightedStringHandler Module Contents --------------- .. py:data:: T .. py:class:: StringSizeBetween(min, max, options=string.ascii_letters + string.digits) Bases: :py:obj:`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. .. py:attribute:: min .. py:attribute:: max .. py:attribute:: options :value: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',... .. py:method:: validate(v) .. py:method:: generate(random, grammar, base_type, rec, dependent_values, parent_values) .. py:method:: mutate(r, g, random_node, depth, base_type, current_node) .. py:method:: crossover(r, g, options, arg, list_type, current_node) .. py:method:: __class_getitem__(args) :classmethod: .. py:method:: __repr__() .. py:method:: iterate(base_type, combine_lists, rec, dependent_values) .. py:class:: WeightedStringHandler(matrix, alphabet) Bases: :py:obj:`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 .. py:attribute:: probability_matrix .. py:attribute:: alphabet .. py:method:: validate(v) .. py:method:: generate(random, grammar, base_type, rec, dependent_values, parent_values) .. py:method:: __repr__() .. py:method:: __class_getitem__(args) :classmethod: .. py:method:: iterate(base_type, combine_lists)