Class: Rastrigin
- Inherits:
-
Object
- Object
- Rastrigin
- Defined in:
- lib/gimuby/problem/rastrigin/rastrigin.rb
Overview
Instance Method Summary collapse
-
#evaluate(x_values) ⇒ Object
Float.
Instance Method Details
#evaluate(x_values) ⇒ Object
Returns Float.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gimuby/problem/rastrigin/rastrigin.rb', line 6 def evaluate(x_values) a = get_a value = a * x_values.length x_values.each do |x_i| cos_arg = 2.0 * Math::PI * x_i sum_term_1 = (x_i ** 2.0) sum_term_2 = a * Math::cos(cos_arg) value += sum_term_1 - sum_term_2 end value end |