metaheuristic_designer.initializers.extended_initializer module#

Initializer for genotypes that contain both a solution and extra parameters.

class ExtendedInitializer(solution_init, param_init_dict, encoding, rng=None)[source]#

Bases: Initializer

Initializer that combines a solution initializer with one or more parameter initializers.

This is used with ParameterExtendingEncoding to produce genotypes that store extra information (e.g., velocity for PSO, mutation strengths for self-adaptation).

Parameters:
solution_initInitializer

Initializer for the solution part of the genotype.

param_init_dictdict

Mapping of parameter names to their corresponding initializers.

encodingParameterExtendingEncoding

The extended encoding that defines the parameter layout.

rngRNGLike, optional

Random number generator.

Parameters:

Methods

generate_individual()

Generate an individual (by default identical to generate_random()).

generate_population([n_individuals])

Create a new random population that included adaptive parameters.

generate_random()

Generate a random genotype vector with solution and parameter parts.

get_state()

Return a minimal dictionary identifying this initializer.

generate_random()[source]#

Generate a random genotype vector with solution and parameter parts.

Returns:
ndarray

A 1-D array with the solution followed by the extra parameters.

generate_individual()[source]#

Generate an individual (by default identical to generate_random()).

Returns:
ndarray

A 1-D array with the solution and parameter parts.

generate_population(n_individuals=None)[source]#

Create a new random population that included adaptive parameters.

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.