metaheuristic_designer.initializers.seed_initializer module#
Initializers that insert predefined solutions into the population.
- class SeededInitializer(default_init, solutions, insert_prob=0.1, population_size=None, rng=None)[source]#
Bases:
CompositeInitializerInitializer that inserts a predefined solution with a given probability.
With probability insert_prob, a randomly chosen solution from the provided set is used; otherwise a random individual is generated by the fallback initializer.
- Parameters:
- default_initInitializer
Fallback initializer for random individuals.
- solutionsPopulation, Iterable[VectorLike] or MatrixLike
Set of predefined solutions to draw from.
- insert_probfloat, optional
Probability of using a predefined solution (default 0.1).
- rngRNGLike, optional
Random number generator.
- Parameters:
default_init (Initializer)
solutions (Population | Iterable[VectorLike] | MatrixLike)
insert_prob (float)
population_size (int)
rng (Optional[RNGLike])
Methods
generate_individual()Generate an individual from one of the initializers chosen at random.
generate_population([n_individuals])Generate a population from individuals chosen at random from the initializers.
generate_random()Generate a random individual from one initializers chosen at random.
get_state()Return a minimal dictionary identifying this initializer.
- class FixedSeededInitializer(default_init, solutions, n_to_insert=None, population_size=None, rng=None)[source]#
Bases:
FixedCompositeInitializerInitializer that inserts a fixed number of predefined solutions.
The first n_to_insert individuals generated are taken from the solution set (cycled if necessary); the remaining are created by the fallback initializer.
- Parameters:
- default_initInitializer
Fallback initializer for random individuals.
- solutionsPopulation, Iterable[VectorLike] or MatrixLike
Set of predefined solutions to draw from.
- n_to_insertint, optional
Exact number of predefined solutions to insert. Defaults to the size of the solution set.
- rngRNGLike, optional
Random number generator.
- Parameters:
default_init (Initializer)
solutions (Population | Iterable[VectorLike] | MatrixLike)
n_to_insert (int)
population_size (int)
rng (Optional[RNGLike])
Methods
generate_individual()Generate an individual from one of the initializers chosen deterministically.
generate_population([n_individuals])Generate a population from individuals chosen at random from the initializers.
generate_random()Generate a random individual from one of the initializers chosen deterministically.
get_state()Return a minimal dictionary identifying this initializer.