Class: Evopop::Candidate
- Inherits:
-
Object
- Object
- Evopop::Candidate
- Defined in:
- lib/evopop/candidate.rb
Overview
Public: Represents a candidate in the population.Evopop::Candidates are abstracted as a simple data structure which contains the DNA and fitness over the fitness function.
Instance Attribute Summary collapse
-
#dna ⇒ Object
Returns the value of attribute dna.
-
#fitness ⇒ Object
Returns the value of attribute fitness.
Instance Method Summary collapse
- #compose_parent_dna(c0, c1) ⇒ Object
-
#initialize(dna) ⇒ Candidate
constructor
Simple initialization of candidate object.
Constructor Details
#initialize(dna) ⇒ Candidate
Simple initialization of candidate object.
11 12 13 |
# File 'lib/evopop/candidate.rb', line 11 def initialize(dna) @dna = dna end |
Instance Attribute Details
#dna ⇒ Object
Returns the value of attribute dna.
8 9 10 |
# File 'lib/evopop/candidate.rb', line 8 def dna @dna end |
#fitness ⇒ Object
Returns the value of attribute fitness.
8 9 10 |
# File 'lib/evopop/candidate.rb', line 8 def fitness @fitness end |
Instance Method Details
#compose_parent_dna(c0, c1) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/evopop/candidate.rb', line 15 def compose_parent_dna(c0, c1) # Compose the dna of the first child from the first chunk of the # first candidate and the second chunk of the second candidate # dna0_left = c0.dna.take(ordinal) # dna1_right = c1.dna.drop(ordinal) end |