Class: FunctionBasedSolution
- Defined in:
- lib/gimuby/genetic/solution/function_based_solution.rb
Direct Known Subclasses
FoxholesSolution, RastriginSolution, RosenbrockSolution, SchafferSolution, SphereSolution, StepSolution
Instance Attribute Summary
Attributes inherited from Solution
#check_strategy, #mutation_strategy, #new_generation_strategy
Instance Method Summary collapse
- #evaluate ⇒ Object
- #get_solution_representation ⇒ Object
-
#initialize(x_values = nil) ⇒ FunctionBasedSolution
constructor
A new instance of FunctionBasedSolution.
- #set_solution_representation(x_values) ⇒ Object
Methods inherited from Solution
#get_fitness, #mutate, #reproduce, #reset_fitness_state
Constructor Details
#initialize(x_values = nil) ⇒ FunctionBasedSolution
Returns a new instance of FunctionBasedSolution.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gimuby/genetic/solution/function_based_solution.rb', line 11 def initialize(x_values = nil) super(x_values) @check_strategy = SolutionSpaceCheckStrategy.new @check_strategy.set_min(get_x_value_min) @check_strategy.set_max(get_x_value_max) @new_generation_strategy = CombinedNewGenerationStrategy.new @new_generation_strategy.add_strategy(ParentRangeNewGenerationStrategy.new) @new_generation_strategy.add_strategy(CrossOverNewGenerationStrategy.new) @new_generation_strategy.add_strategy(AverageNewGenerationStrategy.new) @mutation_strategy = SolutionSpaceMutationStrategy.new @mutation_strategy.set_min(get_x_value_min) @mutation_strategy.set_max(get_x_value_max) end |
Instance Method Details
#evaluate ⇒ Object
28 29 30 |
# File 'lib/gimuby/genetic/solution/function_based_solution.rb', line 28 def evaluate raise NotImplementedError end |
#get_solution_representation ⇒ Object
32 33 34 |
# File 'lib/gimuby/genetic/solution/function_based_solution.rb', line 32 def get_solution_representation @x_values.clone end |
#set_solution_representation(x_values) ⇒ Object
36 37 38 |
# File 'lib/gimuby/genetic/solution/function_based_solution.rb', line 36 def set_solution_representation(x_values) @x_values = x_values.clone end |