saealib.Crossover

class saealib.Crossover[source]

Bases: ABC

Base class for crossover operators.

n_parents

Number of parents required per crossover call. Default is 2. Subclasses may override this class attribute if they require a different number of parents.

Type:

int

n_children

Number of offspring produced per crossover call. Default is 2. Subclasses may override this class attribute if they produce a different number of offspring.

Type:

int

Methods

__init__

crossover

Execute crossover.

Method Details

Crossover.__init__()
abstract Crossover.crossover(parent, rng=Generator(PCG64) at 0x7FECD0E5A500)[source]

Execute crossover.

Parameters:
  • parent (np.ndarray) – Parent individuals. shape = (n_parents, dim)

  • rng (np.random.Generator, optional) – Random number generator, by default np.random.default_rng()

Returns:

Offspring individuals. shape = (n_offspring, dim)

Return type:

np.ndarray