class TspSolution
Attributes
permutation[RW]
Public Class Methods
new(permutation = nil)
click to toggle source
Calls superclass method
Solution::new
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 9 def initialize(permutation = nil) @check_strategy = PermutationCheckStrategy.new() @new_generation_strategy = CrossOverNewGenerationStrategy.new() @mutation_strategy = PermutationMutationStrategy.new() super(permutation) check end
Public Instance Methods
evaluate()
click to toggle source
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 19 def evaluate get_tsp.get_permutation_distance(@permutation) end
get_solution_representation()
click to toggle source
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 23 def get_solution_representation @permutation.clone end
set_solution_representation(representation)
click to toggle source
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 27 def set_solution_representation(representation) @permutation = representation.clone end
Protected Instance Methods
get_not_randomized_permutation()
click to toggle source
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 38 def get_not_randomized_permutation _ = *(0..get_tsp.get_number_of_points - 1) end
get_tsp()
click to toggle source
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 42 def get_tsp $dependencies.tsp end
init_representation()
click to toggle source
# File lib/gimuby/problem/tsp/tsp_solution.rb, line 33 def init_representation @permutation = get_not_randomized_permutation @permutation = @permutation.shuffle end