Class: Pso::Schwefel

Inherits:
Function show all
Defined in:
lib/pso/functions/schwefel.rb

Instance Method Summary collapse

Instance Method Details

#f(vector) ⇒ Object



6
7
8
9
# File 'lib/pso/functions/schwefel.rb', line 6

def f(vector)
  alpha = 418.982887
  vector.map { |n| -n * Math.sin(Math.sqrt(n.to_f.abs))}.sum + alpha * vector.size
end