Class: MetaheuristicAlgorithms::FireflyAlgorithm::Firefly
- Inherits:
-
Object
- Object
- MetaheuristicAlgorithms::FireflyAlgorithm::Firefly
- Defined in:
- lib/metaheuristic_algorithms/firefly_algorithm.rb
Overview
Note: May be able to use Struct for this purpose, moving update_light_intensity method to FireflyAlgorithm class.
Instance Attribute Summary collapse
-
#light_intensity ⇒ Object
Returns the value of attribute light_intensity.
-
#location_coordinates ⇒ Object
Returns the value of attribute location_coordinates.
Instance Method Summary collapse
- #deep_clone ⇒ Object
-
#initialize(function_wrapper, location_coordinates, light_intensity) ⇒ Firefly
constructor
A new instance of Firefly.
- #update_light_intensity ⇒ Object
Constructor Details
#initialize(function_wrapper, location_coordinates, light_intensity) ⇒ Firefly
Returns a new instance of Firefly.
16 17 18 19 20 |
# File 'lib/metaheuristic_algorithms/firefly_algorithm.rb', line 16 def initialize(function_wrapper, location_coordinates, light_intensity) @function_wrapper = function_wrapper @location_coordinates = location_coordinates @light_intensity = light_intensity end |
Instance Attribute Details
#light_intensity ⇒ Object
Returns the value of attribute light_intensity.
14 15 16 |
# File 'lib/metaheuristic_algorithms/firefly_algorithm.rb', line 14 def light_intensity @light_intensity end |
#location_coordinates ⇒ Object
Returns the value of attribute location_coordinates.
13 14 15 |
# File 'lib/metaheuristic_algorithms/firefly_algorithm.rb', line 13 def location_coordinates @location_coordinates end |
Instance Method Details
#deep_clone ⇒ Object
26 27 28 29 30 |
# File 'lib/metaheuristic_algorithms/firefly_algorithm.rb', line 26 def deep_clone clone_object = self.clone clone_object.location_coordinates = self.location_coordinates.clone clone_object end |
#update_light_intensity ⇒ Object
22 23 24 |
# File 'lib/metaheuristic_algorithms/firefly_algorithm.rb', line 22 def update_light_intensity @light_intensity = @function_wrapper.objective_function_value(@location_coordinates).to_f end |