Class: Foxholes
- Inherits:
-
Object
- Object
- Foxholes
- Defined in:
- lib/gimuby/problem/foxholes/foxholes.rb
Overview
Implementation according to www.sfu.ca/~ssurjano/shekel.html www.zsd.ict.pwr.wroc.pl/files/docs/functions.pdf
Constant Summary collapse
- @@x_value_min =
-65536
- @@x_value_max =
65536
Instance Method Summary collapse
- #evaluate(x_values) ⇒ Object
-
#initialize ⇒ Foxholes
constructor
A new instance of Foxholes.
Constructor Details
#initialize ⇒ Foxholes
Returns a new instance of Foxholes.
12 13 14 |
# File 'lib/gimuby/problem/foxholes/foxholes.rb', line 12 def initialize ensure_holes_coordinates end |
Instance Method Details
#evaluate(x_values) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/gimuby/problem/foxholes/foxholes.rb', line 16 def evaluate(x_values) sum = 0.0 get_number_holes.times do |j| hole_coordinate = @holes_coordinates[j] sub_sum = 0.10 hole_coordinate.each_index do |i| sub_sum += (x_values[i].to_f - hole_coordinate[i]) ** 2 end sum += 1.0 / sub_sum end sum end |