Class: Wallace::Species::PermutationSpecies
- Inherits:
-
Wallace::Species
- Object
- Wallace::Species
- Wallace::Species::PermutationSpecies
- Defined in:
- lib/species/permutation_species.rb
Instance Attribute Summary
Attributes inherited from Wallace::Species
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ PermutationSpecies
constructor
Constructs a new permutation species.
-
#spawn(rng) ⇒ Object
Spawns a new permutation of this species list of values.
Methods inherited from Wallace::Species
Constructor Details
#initialize(opts = {}) ⇒ PermutationSpecies
Constructs a new permutation species.
Parameters:
-
opts, hash of keyword options used by this method. -> id, the unique identifier for this species. -> values, the list of values to be permuted.
9 10 11 12 |
# File 'lib/species/permutation_species.rb', line 9 def initialize(opts = {}) super(opts) @values = opts[:values] end |
Instance Method Details
#spawn(rng) ⇒ Object
Spawns a new permutation of this species list of values.
Parameters:
-
rng, random number generation to use during process.
18 19 20 |
# File 'lib/species/permutation_species.rb', line 18 def spawn(rng) Wallace::Individual.new(self, @values.shuffle(random: rng)) end |