Class: Evolvable::GeneSpace
- Inherits:
-
Object
- Object
- Evolvable::GeneSpace
- Defined in:
- lib/evolvable/gene_space.rb
Overview
The gene space defines the structure of an evolvable's genome. It acts as a blueprint that describes what kinds of genes each evolvable instance should have—and how many.
At runtime, Evolvable::GeneSpace is responsible for interpreting this blueprint, constructing genomes, and managing gene configurations. You typically won’t need to interact with GeneSpace directly.
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#evolvable_class ⇒ Object
Returns the value of attribute evolvable_class.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config: {}, evolvable_class: nil) ⇒ GeneSpace
constructor
A new instance of GeneSpace.
- #merge_gene_space(val) ⇒ Object
- #merge_gene_space!(val) ⇒ Object
- #new_genome ⇒ Object
Constructor Details
#initialize(config: {}, evolvable_class: nil) ⇒ GeneSpace
Returns a new instance of GeneSpace.
29 30 31 32 |
# File 'lib/evolvable/gene_space.rb', line 29 def initialize(config: {}, evolvable_class: nil) @evolvable_class = evolvable_class @config = normalize_config(config) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
34 35 36 |
# File 'lib/evolvable/gene_space.rb', line 34 def config @config end |
#evolvable_class ⇒ Object
Returns the value of attribute evolvable_class.
34 35 36 |
# File 'lib/evolvable/gene_space.rb', line 34 def evolvable_class @evolvable_class end |
Class Method Details
.build(config, evolvable_class = nil) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/evolvable/gene_space.rb', line 19 def build(config, evolvable_class = nil) if config.is_a?(GeneSpace) config.evolvable_class = evolvable_class if evolvable_class config else new(config: config, evolvable_class: evolvable_class) end end |
Instance Method Details
#merge_gene_space(val) ⇒ Object
40 41 42 43 |
# File 'lib/evolvable/gene_space.rb', line 40 def merge_gene_space(val) val = val.config if val.is_a?(self.class) @config.merge normalize_config(val) end |
#merge_gene_space!(val) ⇒ Object
45 46 47 48 |
# File 'lib/evolvable/gene_space.rb', line 45 def merge_gene_space!(val) val = val.config if val.is_a?(self.class) @config.merge! normalize_config(val) end |