Class: Wallace::Fitness::RawFitness
- Inherits:
-
Wallace::Fitness
- Object
- Wallace::Fitness
- Wallace::Fitness::RawFitness
- Defined in:
- lib/fitness/raw_fitness.rb
Overview
The raw fitness model uses a single numeric type to describe the fitness of a given individual. Ordering of fitnesses, and thus of individuals, is achieved via ordering on these simple numeric types.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Allow the fitness value to be read but not changed.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
Compares this raw fitness to another.
-
#initialize(value) ⇒ RawFitness
constructor
Constructs a new raw fitness.
Constructor Details
#initialize(value) ⇒ RawFitness
Constructs a new raw fitness.
Parameters:
-
value, the raw fitness value.
13 14 15 |
# File 'lib/fitness/raw_fitness.rb', line 13 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Allow the fitness value to be read but not changed.
7 8 9 |
# File 'lib/fitness/raw_fitness.rb', line 7 def value @value end |
Instance Method Details
#<=>(other) ⇒ Object
Compares this raw fitness to another.
Parameters:
-
other, the fitness to compare against.
Warning: It is assumed that a RawFitness object is provided for comparison.
24 25 26 27 28 |
# File 'lib/fitness/raw_fitness.rb', line 24 def <=>(other) return -1 if other.value.is_a? Float and other.value.nan? return 1 if @value.is_a? Float and @value.nan? return @value <=> other.value end |