Module: EvoSynth::Problems::FloatBenchmarkFuntions
- Defined in:
- lib/evosynth/problems/float_benchmark_functions.rb
Overview
This module contains some multi-dimensional Benchmarkfunctions. You simply set the number of dimensions by the length of the given (Float) array.
Class Method Summary collapse
-
.ackley(xs) ⇒ Object
Ackley (Ackley 1987).
-
.double_sum(xs) ⇒ Object
Double Sum function (Schwefel 1977).
-
.griewank(xs) ⇒ Object
Griewank (Törn & Zilinskas 1989).
-
.rastgrin(xs) ⇒ Object
Rastgrin (Törn & Zilinskas 1989).
-
.rosenbrock(xs) ⇒ Object
Rosenbrock (De Jong 1975).
-
.sinus_sum(xs) ⇒ Object
Sinus Sum function (Schwefel 1995).
-
.sphere(xs) ⇒ Object
Sphere function (Rechenberg 1973 and De Jong 1975).
Class Method Details
.ackley(xs) ⇒ Object
Ackley (Ackley 1987)
global minimum: f(x) = 0 at x(i) = 0, i = 1..n
81 82 83 84 85 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 81 def FloatBenchmarkFuntions.ackley(xs) quad_sum = xs.inject(0.0) { |sum, x| sum += x**2 } cos_sum = xs.inject(0.0) { |sum, x| sum += Math.cos(2 * Math::PI * x) } 20 + Math::E - 20 * Math.exp(-0.2 * Math.sqrt( (1.0 / xs.size) * quad_sum )) - Math.exp( (1.0 / xs.size) * cos_sum ) end |
.double_sum(xs) ⇒ Object
Double Sum function (Schwefel 1977)
global minimum: f(x) = 0 at x(i) = 0, i = 1..n
45 46 47 48 49 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 45 def FloatBenchmarkFuntions.double_sum(xs) xs.inject(0.0) do |sum, i| sum += xs[0..i].inject(0.0) { |sum, x| sum += x } end end |
.griewank(xs) ⇒ Object
Griewank (Törn & Zilinskas 1989)
global minimum: f(x) = 0 at x(i) = 0, i = 1..n
91 92 93 94 95 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 91 def FloatBenchmarkFuntions.griewank(xs) product = 1.0 xs.each_with_index { |x, i| product *= Math.cos x / Math.sqrt(i+1) } 1 + xs.inject(0.0) { |sum, x| sum += x**2 / (400 * xs.size) } - product end |
.rastgrin(xs) ⇒ Object
Rastgrin (Törn & Zilinskas 1989)
global minimum: f(x) = 0 at x(i) = 0, i = 1..n
63 64 65 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 63 def FloatBenchmarkFuntions.rastgrin(xs) 10 * xs.size + xs.inject(0.0) { |sum, x| sum += x**2 - 10 * Math.cos(2 * Math::PI * x) } end |
.rosenbrock(xs) ⇒ Object
Rosenbrock (De Jong 1975)
global minimum: f(x) = 0 at x(i) = 1, i = 1..n
71 72 73 74 75 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 71 def FloatBenchmarkFuntions.rosenbrock(xs) (0..xs.size - 2).inject(0.0) do |sum, i| sum += 100 * (xs[i]**2 - xs[i+1])**2 + (1 - xs[i])**2 end end |
.sinus_sum(xs) ⇒ Object
Sinus Sum function (Schwefel 1995)
global minimum: f(x) = 0 at x(i) = 420.9687, i = 1..n
37 38 39 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 37 def FloatBenchmarkFuntions.sinus_sum(xs) 418.98289 * xs.size + xs.inject(0.0) { |sum, x| sum += -x * Math.sin(Math.sqrt(x.abs)) } end |
.sphere(xs) ⇒ Object
Sphere function (Rechenberg 1973 and De Jong 1975)
global minimum: f(x) = 0 at x(i) = 0, i = 1..n
55 56 57 |
# File 'lib/evosynth/problems/float_benchmark_functions.rb', line 55 def FloatBenchmarkFuntions.sphere(xs) xs.inject(0.0) { |sum, x| sum += x**2 } end |