Class: Wallace::Species::PermutationSpecies

Inherits:
Wallace::Species show all
Defined in:
lib/species/permutation_species.rb

Instance Attribute Summary

Attributes inherited from Wallace::Species

#id

Instance Method Summary collapse

Methods inherited from Wallace::Species

#finish!, #valid?

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