Vector

class evolib.representation.vector.Vector[source]

Bases: ParaBase

A parameter vector representation used as an evolutionary module.

This class supports different structural interpretations of the parameter dimension (flat, tensor, net, etc.), bounds, mutation strategies, and crossover.

apply_config(cfg)[source]

Apply a configuration object to initialize this Vector.

Parameters:

cfg (Union[VectorComponentConfig, EvoNetComponentConfig]) – A VectorComponentConfig defining dimension, structure, initialization, and mutation/crossover strategies.

Return type:

None

crossover_with(partner)[source]

Perform crossover with another Vector instance.

The internal crossover function may produce either one or two offspring. Bounds are applied to clip the resulting parameter values.

Return type:

None

get_history()[source]

Return mutation-related values for logging.

Includes global tau, global mutation strength, and statistics on per-parameter strengths if applicable.

Return type:

dict[str, float]

get_status()[source]

Return a human-readable summary of the internal state.

Includes vector preview, mutation strength(s), tau, and crossover probability.

Return type:

str

mutate()[source]

Apply Gaussian mutation to the parameter vector.

Two modes are supported: - Per-parameter mutation strengths (mutation_strengths defined). - Global mutation strength with optional mutation probability.

Return type:

None

print_status()[source]

Convenience: print the formatted internal state string.

Return type:

None

update_mutation_parameters(generation, max_generations, diversity_ema=None)[source]

Update mutation parameters based on the chosen strategy.

Parameters:
  • generation (int) – Current generation index.

  • max_generations (int) – Maximum number of generations planned.

  • diversity_ema (float | None) – Exponential moving average of population diversity (required for adaptive-global strategies).

Return type:

None