Class: Evolvable::MinimizeGoal

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

Overview

Prioritizes instances with lesser values.

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

Direct Known Subclasses

Goal::Minimize

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



14
15
16
# File 'lib/evolvable/minimize_goal.rb', line 14

def evaluate(evolvable)
  -evolvable.value
end

#met?(evolvable) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/evolvable/minimize_goal.rb', line 18

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

#valueObject



10
11
12
# File 'lib/evolvable/minimize_goal.rb', line 10

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