Class: Evopop::Candidate

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#dnaObject

Returns the value of attribute dna.



8
9
10
# File 'lib/evopop/candidate.rb', line 8

def dna
  @dna
end

#fitnessObject

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