Class: TspSolution
- Defined in:
- lib/gimuby/problem/tsp/tsp_solution.rb
Instance Attribute Summary collapse
-
#permutation ⇒ Object
Returns the value of attribute permutation.
Attributes inherited from Solution
#check_strategy, #mutation_strategy, #new_generation_strategy
Instance Method Summary collapse
- #evaluate ⇒ Object
- #get_solution_representation ⇒ Object
-
#initialize(permutation = nil) ⇒ TspSolution
constructor
A new instance of TspSolution.
- #set_solution_representation(representation) ⇒ Object
Methods inherited from Solution
#get_fitness, #mutate, #reproduce, #reset_fitness_state
Constructor Details
#initialize(permutation = nil) ⇒ TspSolution
Returns a new instance of TspSolution.
9 10 11 12 13 14 15 |
# 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 |
Instance Attribute Details
#permutation ⇒ Object
Returns the value of attribute permutation
17 18 19 |
# File 'lib/gimuby/problem/tsp/tsp_solution.rb', line 17 def permutation @permutation end |
Instance Method Details
#evaluate ⇒ Object
19 20 21 |
# File 'lib/gimuby/problem/tsp/tsp_solution.rb', line 19 def evaluate get_tsp.get_permutation_distance(@permutation) end |
#get_solution_representation ⇒ Object
23 24 25 |
# File 'lib/gimuby/problem/tsp/tsp_solution.rb', line 23 def get_solution_representation @permutation.clone end |
#set_solution_representation(representation) ⇒ Object
27 28 29 |
# File 'lib/gimuby/problem/tsp/tsp_solution.rb', line 27 def set_solution_representation(representation) @permutation = representation.clone end |