Class: Evolvable::Goal
- Inherits:
-
Object
- Object
- Evolvable::Goal
- Defined in:
- lib/evolvable/goal.rb
Overview
The goal for a population can be specified via assignment - population.goal = Evolvable::Goal::Equalize.new
- or by passing an evaluation object when initializing a population.
You can intialize the Evolvable::Evaluation
object with any goal object like this:
You can implement custom goal object like so:
or more succinctly like this:
Direct Known Subclasses
Defined Under Namespace
Classes: Equalize, Maximize, Minimize
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #evaluate(_evolvable) ⇒ Object
-
#initialize(value: nil) ⇒ Goal
constructor
A new instance of Goal.
- #met?(_evolvable) ⇒ Boolean
Constructor Details
#initialize(value: nil) ⇒ Goal
Returns a new instance of Goal.
38 39 40 |
# File 'lib/evolvable/goal.rb', line 38 def initialize(value: nil) @value = value if value end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
42 43 44 |
# File 'lib/evolvable/goal.rb', line 42 def value @value end |
Instance Method Details
#evaluate(_evolvable) ⇒ Object
44 45 46 |
# File 'lib/evolvable/goal.rb', line 44 def evaluate(_evolvable) raise Errors::UndefinedMethod, "#{self.class.name}##{__method__}" end |
#met?(_evolvable) ⇒ Boolean
48 49 50 |
# File 'lib/evolvable/goal.rb', line 48 def met?(_evolvable) raise Errors::UndefinedMethod, "#{self.class.name}##{__method__}" end |