nevo.operators¶
Base Classes¶
Base Operator Interface¶
This module defines the base interface for all optimisation operators in NEVO. Each operator implements a specific search strategy (exploration or exploitation).
- class Operator(name, operator_type='exploration', short_name=None, complexity=5)[source]¶
Bases:
ABCAbstract base class for optimisation operators.
Each operator must implement: - generate_population(): Create candidate solutions - get_parameters(): Return operator-specific parameters
Operators can be either: - EXPLORATION: Global search, diversity promotion - EXPLOITATION: Local refinement, convergence
Complexity levels (1-10): - 1-3: Simple random-based operators - 4-6: Memory-based operators - 7-10: Physics/swarm-based operators
- __init__(name, operator_type='exploration', short_name=None, complexity=5)[source]¶
Initialize operator.
- abstractmethod generate_population(centre, state, population_size)[source]¶
Generate a population of candidate solutions.
- Parameters:
- Returns:
candidates – Population of shape (population_size, dimensions) All values should be in [-1, 1] (v-space)
- Return type:
np.ndarray
- get_parameters()[source]¶
Get operator-specific parameters.
- Returns:
params – Dictionary of parameter names and values
- Return type:
Dict[str, Any]
- class ExplorationOperator(name, short_name=None, complexity=5)[source]¶
Bases:
OperatorBase class for exploration operators (global search).
Standard Operators¶
Standard Optimisation Operators¶
This module implements common metaheuristic operators adapted for neuromorphic optimisation.
- class LevyFlight(alpha=0.3, beta=1.5, gamma=0.1)[source]¶
Bases:
ExplorationOperatorLévy Flight Operator
Heavy-tailed random walk for escaping local minima. Uses Mantegna’s algorithm to generate Lévy-distributed steps.
Best used when: stuck in local optima, need global exploration.
The update rule is:
\[x_{\text{new}} = x_c + \alpha L_{\beta} + \gamma (x_{\text{best}} - x_c)\]where \(\alpha\) is the step size, \(L_{\beta}\) is a Lévy-distributed step (Mantegna’s algorithm, exponent \(\beta\)), and \(\gamma\) controls the direction bias towards \(x_{\text{best}}\).
- class DifferentialEvolution(F=0.8, CR=0.9)[source]¶
Bases:
ExplorationOperatorDifferential Evolution Operator (DE/rand/1/bin)
Uses memory diversity to generate directed exploration. Creates new solutions by combining existing memory solutions.
Best used when: memory has diversity, exploring promising regions.
The update rule (DE/rand/1/bin) is:
\[x_{\text{new}} = x_a + F (x_b - x_c)\]where \(x_a, x_b, x_c\) are distinct memory solutions, \(F\) is the mutation factor, and binomial crossover is applied with probability \(CR\).
- class ParticleSwarm(w=0.7, c1=1.5, c2=1.5)[source]¶
Bases:
ExploitationOperatorParticle Swarm Optimisation Operator
Velocity-based exploitation with attraction to personal and global bests. Maintains velocity state for smooth convergence.
Best used when: improving and converging, exploitation phase.
The update equations are:
\[\begin{split}v_i &= w v_i + c_1 r_1 (p_{\text{best}} - x_i) + c_2 r_2 (g_{\text{best}} - x_i) \\ x_{\text{new}} &= x_i + v_i\end{split}\]where \(w\) is the inertia weight and \(c_1, c_2\) are the cognitive and social coefficients.
- class SpiralOptimisation(r_base=0.995)[source]¶
Bases:
ExploitationOperatorSpiral Optimisation Operator
Anisotropic convergence using logarithmic spirals in 2D planes. Each plane has independent rotation and convergence parameters.
Best used when: highly converged, fine-tuning phase
The update rule is:
\[\begin{split}x_{new} = x_{best} + r^{\theta} \begin{bmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \end{bmatrix} (x_i - x_{best})\end{split}\]where \(r\) is the convergence rate and \(\theta\) is the rotation angle.
- class RandomSearch(scale=0.5, distribution='uniform')[source]¶
Bases:
ExplorationOperatorRandom Search Operator
Simple uniform random sampling around the centre. Useful for initial exploration or when other operators stagnate.
Best used when: no prior information, need baseline exploration.
The update rule is:
\[x_{\text{new}} = x_c + \delta\]where \(\delta\) is sampled from a uniform or Gaussian distribution with scale parameter \(s\).
- class LocalRandomWalk(probability=0.75, scale=0.1)[source]¶
Bases:
ExploitationOperatorLocal Random Walk Operator (from Cuckoo Search)
Small-scale local exploration with probability-based activation. Generates subtle perturbations for fine-tuning solutions.
Best used when: near optimum, need local refinement.
The update rule is:
\[x_{\text{new}} = x_c + s \, \Delta\]where \(s\) is the step size scale and \(\Delta\) is a difference vector from two randomly selected memory solutions.
- class GravitationalSearch(gravity=1.0, alpha=0.02)[source]¶
Bases:
ExplorationOperatorGravitational Search Algorithm Operator
Mass-based attraction dynamics where better solutions have more mass. Solutions are attracted towards heavier (better) solutions.
Best used when: need directed exploration, moderate diversity.
The update rule is:
\[x_{\text{new}} = x_i + a_i\]where \(a_i\) is the acceleration from gravitational forces of all other solutions, weighted by their masses (derived from fitness).
- class FireflyAlgorithm(alpha=0.2, beta=1.0, gamma=1.0)[source]¶
Bases:
ExplorationOperatorFirefly Algorithm Operator
Light-based attraction where brighter (better) fireflies attract others. Combines attraction with randomisation for balanced exploration.
Best used when: need attraction-based exploration, moderate convergence.
The update rule is:
\[x_{\text{new}} = x_i + \beta(r)(x_j - x_i) + \alpha \epsilon\]where \(\beta(r) = \beta_0 e^{-\gamma r^2}\) is the distance-based attractiveness, \(\alpha\) is the randomisation parameter, and \(\epsilon\) is a random perturbation.
- class CentralForce(gravity=2.0, alpha=2.0)[source]¶
Bases:
ExplorationOperatorCentral Force Optimisation Operator
Physics-inspired operator using gravitational attraction towards the global best solution with inverse-square law dynamics.
Best used when: need strong directional bias, exploitation-exploration balance
The mathematical expression for this operator is given by: x_{new} = x_{i} + F_{c}
where: - ( x_{new} ) is the new candidate solution. - ( x_{i} ) is the current position of the solution. - ( F_{c} ) is the central force vector directed towards the global best solution, calculated using an inverse power law based on distance.
- class GeneticCrossover(crossover='blend', alpha=0.5)[source]¶
Bases:
ExplorationOperatorGenetic Algorithm Crossover Operator
Recombination of memory solutions using various crossover strategies. Creates new solutions by combining genetic material from parents.
Best used when: memory has good diversity, want to combine good features
The mathematical expression for this operator is given by: x_{new} = Crossover(x_{parent1}, x_{parent2})
where: - ( x_{new} ) is the new candidate solution. - ( x_{parent1}, x_{parent2} ) are two parent solutions selected from memory.
- class GeneticMutation(mutation_rate=0.2, scale=0.3, distribution='gaussian')[source]¶
Bases:
ExploitationOperatorGenetic Algorithm Mutation Operator
Random perturbation of solutions with configurable mutation rate. Introduces diversity by modifying individual genes.
Best used when: need local refinement, fine-tuning solutions
The mathematical expression for this operator is given by: x_{new} = x_{i} + m
where: - ( x_{new} ) is the new candidate solution. - ( x_{i} ) is the current position of the solution. - ( m ) is a mutation vector where each gene is altered with a certain probability according to the mutation rate and distribution.
Note: With high mutation rates (>0.5) and large scales (>0.5), this operator behaves more like exploration. Default parameters favour exploitation.
- class SimulatedAnnealing(initial_temp=1.0, cooling_rate=0.995)[source]¶
Bases:
ExploitationOperatorSimulated Annealing Operator
Temperature-based local search with decreasing randomness. Allows uphill moves early, becomes greedy over time.
Best used when: need controlled exploitation, avoiding local minima
The mathematical expression for this operator is given by: x_{new} = x_{centre} + T cdot delta + b
where: - ( x_{new} ) is the new candidate solution. - ( x_{centre} ) is the current centre solution. - ( T ) is the current temperature controlling perturbation scale. - ( delta ) is a random perturbation vector. - ( b ) is a bias vector towards the global best solution, increasing as temperature decreases.
- class TabuSearch(tabu_tenure=10, neighbourhood_size=0.2)[source]¶
Bases:
ExploitationOperatorTabu Search Operator
Memory-based local search that avoids recently visited regions. Maintains a tabu list to prevent cycling.
Best used when: stuck in local optima, need diversification
The mathematical expression for this operator is given by: x_{new} = x_{centre} + delta
where: - ( x_{new} ) is the new candidate solution. - ( x_{centre} ) is the current centre solution. - ( delta ) is a random perturbation vector. - The candidate solutions are checked against a tabu list to avoid revisiting recent solutions.
- class NeuromorphicExplorationEnsemble(n_neurons=150, tau_synapse=0.005, max_rates=(100, 200), intercepts=(-1.0, 1.0), use_numpy_fallback=False)[source]¶
Bases:
ExplorationOperatorNengo LIF-based exploration using fast spiking neural populations.
This operator builds Nengo neural networks inside the optimiser’s model with LIF neurons, fast synaptic filtering, and NEF decoding.
IMPORTANT: Unlike other operators, this creates Nengo Ensembles that are integrated into the main Nengo simulation loop.
- __init__(n_neurons=150, tau_synapse=0.005, max_rates=(100, 200), intercepts=(-1.0, 1.0), use_numpy_fallback=False)[source]¶
Initialize operator.
- class NeuromorphicExploitationEnsemble(n_neurons=200, tau_synapse=0.02, max_rates=(50, 100), intercepts=(-0.5, 0.5), trust_radius=0.2, use_numpy_fallback=False)[source]¶
Bases:
ExploitationOperatorNengo LIF-based exploitation using slow spiking neural populations.
This operator builds Nengo neural networks inside the optimiser’s model with LIF neurons, slow synaptic filtering for attractor dynamics.
IMPORTANT: Unlike other operators, this creates Nengo Ensembles that are integrated into the main Nengo simulation loop.
- __init__(n_neurons=200, tau_synapse=0.02, max_rates=(50, 100), intercepts=(-0.5, 0.5), trust_radius=0.2, use_numpy_fallback=False)[source]¶
Initialize operator.
- class CoordinateDescent(k_frac=None, scale=0.1)[source]¶
Bases:
ExploitationOperatorCoordinate Descent Operator
Perturbs a randomly chosen sparse subset of dimensions per candidate, keeping all other coordinates fixed at the global best value.
Particularly effective for separable and block-separable high-dimensional functions where variable interactions are limited.
Best used when: D > 50, function is separable or near-separable.
The update rule is:
\[x_k^{\text{new}} = x_k^{\text{best}} + \sigma \epsilon_k, \quad k \in \mathcal{K}\]where \(\mathcal{K}\) is a random subset of \(k\) coordinates, \(\sigma\) is the step size, and \(\epsilon_k \sim \mathcal{N}(0,1)\).
- class RandomEmbedding(effective_dim=10, scale=0.3, refresh_every=100)[source]¶
Bases:
ExplorationOperatorRandom Embedding Operator
Embeds the search in a low-dimensional subspace using a random orthogonal projection. Exploits the observation that many real-world high-dimensional problems have low effective dimensionality.
Based on the REMEDA principle: a random linear embedding of dimension \(d_{\text{eff}} \ll D\) preserves near-optimal solutions when the intrinsic dimension of the problem is low.
Best used when: D > 100, problem has low intrinsic dimensionality.
The update rule is:
\[x_{\text{new}} = x_c + A z, \quad z \sim \mathcal{N}(0, \sigma^2 I_{d})\]where \(A \in \mathbb{R}^{D \times d}\) is a random orthonormal matrix and \(d = d_{\text{eff}}\) is the effective dimensionality.
- __init__(effective_dim=10, scale=0.3, refresh_every=100)[source]¶
- Parameters:
effective_dim (int) – Low-dimensional subspace size (5–20 recommended for high-D problems).
scale (float) – Step size in the embedded subspace (0.1-0.5 recommended).
refresh_every (int) – Re-draw the random projection after this many
generate_populationcalls, so the search periodically explores different subspaces.
- class CovarianceAdaptation(elite_frac=0.3, scale=0.5, max_full_cov_dim=50)[source]¶
Bases:
ExploitationOperatorCovariance Adaptation Operator (simplified CMA-ES style)
Estimates the covariance of the elite memory solutions and samples new candidates from the induced Gaussian distribution. Automatically adapts the step distribution to the local problem geometry.
For
D ≤ max_full_cov_dima full covariance matrix is used (accurate but O(D²) memory). ForD > max_full_cov_dimonly the diagonal variance is estimated (linear memory, still captures per-dimension scaling).Best used when: memory is well populated, problem has non-separable structure.
The update rule is:
\[x_{\text{new}} \sim \mathcal{N}(\mu_{\text{elite}},\, \sigma^2 C_{\text{elite}})\]where \(\mu_{\text{elite}}\) and \(C_{\text{elite}}\) are the mean and (optionally diagonal) covariance of the top-
elite_fracmemory solutions.
Registry¶
Operator Registry¶
Central registry for all available operators.