alogos.systems.dsge.repair
¶
Repair function to correct modified genotypes for DSGE.
Functions¶
|
Repair a genotype after modification by other operators. |
Detailed object descriptions¶
- alogos.systems.dsge.repair.fix_genotype(grammar, genotype, parameters=None, raise_errors=True)[source]¶
Repair a genotype after modification by other operators.
Parts of the genotype repair procedure:
The genes and codons guide a derivation, which is constructed here step-by-step to see how far it works and correct where it fails.
Repair 1: If the derivation is not finished yet, but every codon of a gene was used, all choices following afterwards are made by adding random codons.
Repair 2: If the derivation comes to a point where an encountered codon value is invalid, it is replaced by a random valid codon.
Repair 3: If the derivation ends before all codons of a gene were used, each unused codon following afterwards is deleted.
If the derivation reaches max depth in a branch, only non-recursive options are used from there on. This can mean that existing codons have to be replaced if they stand for recursive options, or new random codons have to be added which stand for recursive options.
Notes
The maximum tree-depth restriction is enforced in following way:
It is considered in each branch of the tree separately, instead of looking at the depth of the entire tree.
It is enforced as a soft limit and therefore a tree can become a bit deeper than the max depth value. Whenever a branch reaches the max depth, recursive rules are no longer used in expansions, but the branch can still grow a bit by applying non-recursive rules.
The maximum expansion limit, which is not present in the original authors’ conception, is used in following way when the user provides it:
It is enforced as a hard limit, a tree can not have more expansions in it.
If it is hit, a repair error is raised.