class SolutionSpaceCheckStrategy
Permutation goes represented as permutation from [0, … l] indexes
Public Class Methods
new()
click to toggle source
# File lib/gimuby/genetic/solution/check_strategy/solution_space_check_strategy.rb, line 6 def initialize @default_min = nil @default_max = nil @mins = {} @maxs = {} end
Public Instance Methods
check(solution_representation)
click to toggle source
# File lib/gimuby/genetic/solution/check_strategy/solution_space_check_strategy.rb, line 13 def check(solution_representation) solution_representation.each_index do |index| value = solution_representation[index] if value.class == Array value = check(value) else min = get_min(index) unless min.nil? if value < min value = min end end max = get_max(index) unless max.nil? if value > max value = max end end end solution_representation[index] = value end solution_representation end
set_max(max, index = nil)
click to toggle source
# File lib/gimuby/genetic/solution/check_strategy/solution_space_check_strategy.rb, line 49 def set_max(max, index = nil) if index.nil? @default_max = max else @maxs[index] = max end end
set_min(min, index = nil)
click to toggle source
# File lib/gimuby/genetic/solution/check_strategy/solution_space_check_strategy.rb, line 41 def set_min(min, index = nil) if index.nil? @default_min = min else @mins[index] = min end end
Protected Instance Methods
get_max(index)
click to toggle source
# File lib/gimuby/genetic/solution/check_strategy/solution_space_check_strategy.rb, line 67 def get_max(index) max = @default_max if @maxs.has_key?(index) max = @maxs[index] end max end
get_min(index)
click to toggle source
# File lib/gimuby/genetic/solution/check_strategy/solution_space_check_strategy.rb, line 59 def get_min(index) min = @default_min if @mins.has_key?(index) min = @mins[index] end min end