Class: Semantic::AttrGrDepthFirst
- Inherits:
-
Mapper::DepthFirst
- Object
- Mapper::Base
- Mapper::Generator
- Mapper::DepthFirst
- Semantic::AttrGrDepthFirst
- Defined in:
- ../lib/attribute_grammar.rb
Overview
This mapper class implements the modified version of the attribute grammar described in: www.cs.bham.ac.uk/~wbl/biblio/gecco2004/WGEW003.pdf and ncra.ucd.ie/downloads/pub/thesisExtGEwithAGs-CRC.pdf
If there is the boolean p._valid attribute defined for the nonterminal symbol expansion, the expansion is considered only if the value of such attribute is ‘true’.
The implementation differs from the original thesis in this aspect: There is no “rollback phase” of semantic attributes processing when the invalid node expansion is reached (ie node._valid==false). Invalid expansions are simply ignored beforehand, no codons are wasted (in another words there are no introns due to the semantic restrictions present in the genotype string.
See the AttributeGrammar class for detailed description of the semantic YAML file. See the Mapper::DepthFirst class for detailed description of the mapper behavior.
Instance Attribute Summary (collapse)
-
- (Object) attributes
readonly
Semantic attributes hash.
Attributes inherited from Mapper::Generator
Attributes inherited from Mapper::Base
#codon, #complexity, #consume_trivial_codons, #grammar, #mapped_count, #track_support, #track_support_on, #used_length, #wraps_to_fading, #wraps_to_fail
Instance Method Summary (collapse)
-
- (Object) generate(recursivity, required_depth)
See Mapper::DepthFirst#generate.
-
- (AttrGrDepthFirst) initialize(grammar)
constructor
See Mapper::DepthFirst#new.
-
- (Object) phenotype(genome)
See Mapper::DepthFirst#phenotype.
Methods included from Mapper::ConstantsNoSupport
#modify_expansion_base, #modify_expansion_generate
Methods inherited from Mapper::Generator
#generate_full, #generate_grow
Constructor Details
- (AttrGrDepthFirst) initialize(grammar)
See Mapper::DepthFirst#new
48 49 50 51 52 53 |
# File '../lib/attribute_grammar.rb', line 48 def initialize( grammar ) super grammar @functions = grammar.semantic_functions clear end |
Instance Attribute Details
- (Object) attributes (readonly)
Semantic attributes hash. It maps AttrKey identification to the attribute values. Mainly for debugging and logging purposes.
57 58 59 |
# File '../lib/attribute_grammar.rb', line 57 def attributes @attributes end |
Instance Method Details
- (Object) generate(recursivity, required_depth)
See Mapper::DepthFirst#generate
66 67 68 69 |
# File '../lib/attribute_grammar.rb', line 66 def generate( recursivity, required_depth ) clear super( recursivity, required_depth ) end |
- (Object) phenotype(genome)
See Mapper::DepthFirst#phenotype
60 61 62 63 |
# File '../lib/attribute_grammar.rb', line 60 def phenotype genome clear super( genome ) end |