metaheuristic_designer.initializers.latin_hypercube_initializer module#

Initializer that implements Latin Hypercube Sampling as an initialization technique.

class LatinHypercubeInitializer(dimension, lower_bound, upper_bound, population_size=1, encoding=None, dtype=<class 'float'>, rng=None)[source]#

Bases: Initializer

Initializer that generates individuals using the Latin Hypercube Sampling (LHS) technique, in which values are drawn from a stratified uniform distribution that more efficiently samples the search space than naive uniform sampling.

Parameters:
dimensionint

Length of the genotype vector.

lower_boundfloat or array

Lower bound(s) of the distribution. If an array is given, it must have length dimension.

upper_boundfloat or array

Upper bound(s) of the distribution. Must match the shape of lower_bound.

population_sizeint, optional

Number of individuals to generate (default 1).

encodingEncoding, optional

Encoding that will be passed to each individual.

dtypetype, optional

Desired NumPy dtype of the generated vectors (default float).

rngRNGLike, optional

Random number generator.

Methods

generate_individual()

Generate a single individual.

generate_population([n_individuals])

Create a fully formed population of n_individuals individuals.

generate_random()

Generate a single random genotype vector (1-D array).

get_state()

Return a minimal dictionary identifying this initializer.

generate_random()[source]#

Generate a single random genotype vector (1-D array).

Returns:
VectorLike

A newly generated genotype vector (1-D array).

generate_population(n_individuals=None)[source]#

Create a fully formed population of n_individuals individuals.

Return type:

Population

Parameters:
objfunc: ObjectiveFunc

Objective function that will be propagated to each individual.

n_individual: int, optional

Number of individuals to generate

Returns:
generated_population: Population

Newly generated population.

Parameters:

n_individuals (int | None)