Solvers

The solvers module defines the abstract interfaces and concrete implementations used to perform the optimisation process within the Neuroptimiser framework.

The solver architecture is designed following the modular structure described in the Architecture section. It integrates multiple neuromorphic heuristic units to drive the search process asynchronously.

Abstract Solver

The base class providing the general interface for solver implementations.

class AbstractSolver[source]

Bases: ABC

Abstract base class for any solver in the Neuro Optimiser framework. This class defines the basic structure and methods that any solver should implement. It includes methods for setting up the problem, validating configuration parameters, and running the optimisation process.

__init__() None[source]
property config_params: dict
static generate_experiment_name(prefix='Exp') str[source]

Generates a unique experiment name based on the current date and time.

get_default_config() dict[source]

Returns the default configuration parameters for the solver.

reset_random_seed(seed: int | None = None) None[source]

Resets the random seed for reproducibility.

results: dict = None
abstract solve(obj_func, exp_name: str, num_iterations: int | None = None, search_space: ndarray | None = None) tuple[float, ndarray][source]

Abstract method to solve the optimisation problem.

validate_config_params(config_params: dict) dict[source]

Validates the configuration parameters for the solver.

Parameters:

config_params (dict) – The configuration parameters to validate.

static validate_params(schema: dict, params: dict) dict[source]

Validates the parameters against the provided schema.

Parameters:
  • schema (dict) – The schema to validate against.

  • params (dict) – The parameters to validate.

Returns:

The validated parameters.

NeurOptimiser

The concrete solver implementation integrating neuromorphic heuristic units, local dynamics, and spike-driven transitions.

class NeurOptimiser[source]

Bases: AbstractSolver

Neuro Optimiser is the main class for the Neuro Optimiser framework. It inherits from the AbstractSolver class and implements the solve method, and sets up the model for the optimisation process.

Parameters:
  • config_params (dict) – Configuration parameters for the Neuro Optimiser.

  • core_params (dict|list[dict]) – Parameters for the spiking core of the nheuristic units.

  • selector_params (dict) – Parameters for the high-level selection unit.

__init__(config_params: dict | None = None, core_params: dict | list[dict] | None = None, selector_params: dict | None = None) None[source]
get_default_params() tuple[list[dict], dict][source]

Returns the default parameters for the Neuro Optimiser.

Returns:

A tuple containing: - A list of dictionaries, each representing the parameters of a Neuromorphic Heuristic Unit (NHU). - A dictionary for the high-level selector parameters (currently not implemented).

Return type:

tuple[list[dict], dict]

Example

>>> solver = NeurOptimiser()
>>> core_params, selector_params = solver.get_default_params()
>>> print(core_params)
>>> # Output:
>>> # [{'noise_std': 0.1, 'thr_k': 0.05, 'thr_min': 1e-06, 'coeffs': 'random', 'thr_alpha': 1.0, 'name': 'linear', 'is_bounded': False, 'hs_operator': 'fixed', 'max_steps': 100, 'spk_alpha': 0.25, 'spk_cond': 'fixed', 'thr_max': 1.0, 'ref_mode': 'pg', 'thr_mode': 'diff_pg', 'seed': None, 'hs_variant': 'fixed', 'approx': 'rk4', 'alpha': 1.0, 'dt': 0.01}]
>>> print(selector_params)
>>> # Output:
>>> # {}
solve(obj_func, exp_name: str | None = None, num_iterations: int | None = None, search_space: ndarray | None = None, debug_mode: bool = False) Tuple[float, ndarray][source]

Solve the optimisation problem using the Neuro Optimiser framework.

Parameters:
  • obj_func (callable) – The objective function to be optimised.

  • exp_name (str, optional) – Name of the experiment. Defaults to None.

  • num_iterations (int, optional) – Number of iterations for the optimisation process. Defaults to None.

  • search_space (np.ndarray, optional) – Search space for the optimisation. Defaults to None.

  • debug_mode (bool, optional) – If True, enables debug mode with additional logging and monitoring. Defaults to False.

Returns:

A tuple containing the best position found and its corresponding fitness value.

Return type:

Tuple[float, np.ndarray]