metaheuristic_designer.initializers.uniform_initializer module#
Initializer that samples from a uniform distribution.
- class UniformInitializer(dimension, lower_bound, upper_bound, population_size=1, encoding=None, dtype=<class 'float'>, rng=None)[source]#
Bases:
InitializerInitializer that generates individuals with values drawn from a uniform distribution.
- 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 a single individual.
generate_population([n_individuals])Create a fully formed population of n_individuals individuals.
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_individual()[source]#
Generate a single individual.
By default simply delegates to
generate_random(). Returns a newly generated individual (a 1-D array).Override this method if your initializer needs to distinguish between a randomly initialize individual and a solution generated with another strategy (See SeedProbInitializer).
- Returns:
- Any
A newly generated individual.