Class: Evolvable::MaximizeGoal

Inherits:
Goal
  • Object
show all
Defined in:
lib/evolvable/maximize_goal.rb

Overview

Prioritizes instances with greater values. This is the default.

The default goal value is Float::INFINITY, but it can be reassigned to any numeric value.

Direct Known Subclasses

Goal::Maximize

Instance Method Summary collapse

Methods inherited from Goal

#initialize

Constructor Details

This class inherits a constructor from Evolvable::Goal

Instance Method Details

#evaluate(evolvable) ⇒ Object



15
16
17
# File 'lib/evolvable/maximize_goal.rb', line 15

def evaluate(evolvable)
  evolvable.value
end

#met?(evolvable) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/evolvable/maximize_goal.rb', line 19

def met?(evolvable)
  evolvable.value >= value
end

#valueObject



11
12
13
# File 'lib/evolvable/maximize_goal.rb', line 11

def value
  @value ||= Float::INFINITY
end