Class: Schaffer

Inherits:
Object
  • Object
show all
Defined in:
lib/gimuby/problem/schaffer/schaffer.rb

Overview

Instance Method Summary collapse

Instance Method Details

#evaluate(values) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/gimuby/problem/schaffer/schaffer.rb', line 6

def evaluate(values)
  x_values = values.clone
  x = x_values.shift
  y = x_values.shift
  sqrt_arg = x**2 + y**2
  sin_arg = Math.sqrt(sqrt_arg)
  numerator = Math.sin(sin_arg) ** 2 - 0.5
  denominator_part = 0.001 * ( x ** 2 + y ** 2 )
  denominator = (1 + denominator_part)**2
  0.5 + numerator/denominator
end