45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/petri_dish/configuration.rb', line 45
def validate!
raise ArgumentError, "logger must respond to :info" unless logger.respond_to?(:info)
raise ArgumentError, "max_generations must be greater than 0" unless max_generations > 0
raise ArgumentError, "population_size must be greater than 0" unless population_size > 0
raise ArgumentError, "mutation_rate must be between 0 and 1" unless mutation_rate >= 0 && mutation_rate <= 1
raise ArgumentError, "elitism_rate must be between 0 and 1" unless elitism_rate >= 0 && elitism_rate <= 1
raise ArgumentError, "genetic_material must be an Array" unless genetic_material.is_a?(Array)
raise ArgumentError, "target_genes must be an Array" unless target_genes.is_a?(Array)
raise ArgumentError, "fitness_function must respond to :call" unless fitness_function.respond_to?(:call)
raise ArgumentError, "parents_selection_function must respond to :call" unless parents_selection_function.respond_to?(:call)
raise ArgumentError, "crossover_function must respond to :call" unless crossover_function.respond_to?(:call)
raise ArgumentError, "mutation_function must respond to :call" unless mutation_function.respond_to?(:call)
raise ArgumentError, "end_condition_function must respond to :call" unless end_condition_function.respond_to?(:call)
raise ArgumentError, "highest_fitness_callback must respond to :call" unless highest_fitness_callback.respond_to?(:call)
raise ArgumentError, "max_generation_reached_callback must respond to :call" unless max_generation_reached_callback.respond_to?(:call)
raise ArgumentError, "next_generation_callback must respond to :call" unless next_generation_callback.respond_to?(:call)
raise ArgumentError, "end_condition_reached_callback must respond to :call" unless end_condition_reached_callback.respond_to?(:call)
end
|