alogos.systems.cfggpst.mapping
¶
Forward and reverse mapping functions for CFG-GP-ST.
Functions¶
|
Map a CFG-GP-ST genotype to a string phenotype. |
|
Map a string phenotype (or derivation tree) to a CFG-GP-ST genotype. |
Detailed object descriptions¶
- alogos.systems.cfggpst.mapping.forward(grammar, genotype, parameters=None, raise_errors=True, return_derivation_tree=False, verbose=False)[source]¶
Map a CFG-GP-ST genotype to a string phenotype.
- Parameters:
grammar (
Grammar
)genotype (
Genotype
or data that can be converted to it)parameters (
dict
orParameterCollection
, optional) – No keyword-value pairs are considered by this function. This argument is only available to have a consistent interface.raise_errors (
bool
, optional) – Possible values:True
: A mapping error will be raised if a derivation is not finished within a limit provided in the parameters.False
: A partial derivation is allowed. In this case, the returned string will contain unexpanded nonterminal symbols. Therefore it is not a valid phenotype, i.e. not a string of the grammar’s language but a so-called sentential form.
return_derivation_tree (
bool
, optional) – IfTrue
, not only the phenotype is returned but additionally also the derivation tree.verbose (
bool
, optional) – IfTrue
, output about steps of the mapping process is printed.
- Returns:
- Raises:
MappingError – If
raise_errors
isTrue
and the mapping process can not generate a full derivation before reaching a limit provided in the parameters.
- alogos.systems.cfggpst.mapping.reverse(grammar, phenotype_or_derivation_tree, parameters=None, return_derivation_tree=False)[source]¶
Map a string phenotype (or derivation tree) to a CFG-GP-ST genotype.
- Parameters:
grammar (
Grammar
)phenotype_or_derivation_tree (
str
orDerivationTree
)parameters (
dict
orParameterCollection
, optional) – No keyword-value pairs are considered by this function. This argument is only available to have a consistent interface.return_derivation_tree (
bool
, optional) – IfTrue
, not only the genotype is returned but additionally also the derivation tree.
- Returns:
- Raises:
MappingError – If the reverse mapping fails because the string does not belong to the grammar’s language or the derivation tree does not represent a valid derivation.