nevo.core.state

State Feature Extraction

This module computes state features that describe the current optimisation landscape and guide operator selection.

class StateFeatures(history_length=50)[source]

Bases: object

Extracts interpretable features from optimisation state.

Features: - diversity: Spread of solutions in search space [0, 1] - improvement_rate: Fraction of recent improvements [0, 1] - convergence: Fitness homogeneity indicator [0, 1]

__init__(history_length=50)[source]
Parameters:

history_length (int) – Number of recent timesteps to consider for improvement rate

compute(state)[source]

Compute 3D feature vector from current state.

Parameters:

state (Dict[str, Any]) – Current optimisation state containing: - memory_vectors: np.ndarray of shape (MU, D) - memory_fitness: np.ndarray of shape (MU,) - f_default_worst: float (sentinel value for invalid solutions)

Returns:

features – Feature vector [diversity, improvement_rate, convergence]

Return type:

np.ndarray

update_improvement_history(improved)[source]

Update improvement history.

Parameters:

improved (bool) – Whether the best solution improved this timestep

reset()[source]

Reset improvement history.

compute_fitness_weighted_centre(state)[source]

Compute fitness-weighted centroid from memory.

Uses rank-based weighting to emphasise better solutions.

Parameters:

state (Dict[str, Any]) – optimisation state containing memory

Returns:

centre – Fitness-weighted centroid in v-space

Return type:

np.ndarray