Table of Contents

Interface IParameterOptimizer<TInput, TMetric>

Namespace
SignalSharp.Optimization
Assembly
SignalSharp.dll

Interface for a parameter optimization strategy. Implementations of this interface will define specific optimization algorithms.

public interface IParameterOptimizer<TInput, TMetric>

Type Parameters

TInput

The type of the input data provided to the objective function (e.g., ReadOnlySpan<TData>).

TMetric

The type of the objective metric returned by the objective function (e.g., SSE of type TData).

Methods

Optimize(TInput, IEnumerable<ParameterDefinition>, Func<TInput, IReadOnlyDictionary<string, double>, ObjectiveEvaluation<TMetric>>)

Optimizes a set of parameters for a given objective function, aiming to minimize the returned metric.

OptimizationResult<TMetric> Optimize(TInput inputData, IEnumerable<ParameterDefinition> parametersToOptimize, Func<TInput, IReadOnlyDictionary<string, double>, ObjectiveEvaluation<TMetric>> objectiveFunction)

Parameters

inputData TInput

The input data required by the objective function (e.g., time series signal).

parametersToOptimize IEnumerable<ParameterDefinition>

A collection of ParameterDefinition objects, describing each parameter's name, bounds, and optional initial guess.

objectiveFunction Func<TInput, IReadOnlyDictionary<string, double>, ObjectiveEvaluation<TMetric>>

A function delegate that, given the input data and a dictionary of current trial parameter values, computes and returns an ObjectiveEvaluation<TMetric>. The evaluation includes the metric value and, optionally, the gradient of the metric with respect to the parameters.

Returns

OptimizationResult<TMetric>

An OptimizationResult<TMetric> containing the best parameters found, the minimized metric value, and other optimization details.

OptimizeAsync(TInput, IEnumerable<ParameterDefinition>, Func<TInput, IReadOnlyDictionary<string, double>, ObjectiveEvaluation<TMetric>>, CancellationToken)

Asynchronously optimizes a set of parameters for a given objective function with cancellation support.

Task<OptimizationResult<TMetric>> OptimizeAsync(TInput inputData, IEnumerable<ParameterDefinition> parametersToOptimize, Func<TInput, IReadOnlyDictionary<string, double>, ObjectiveEvaluation<TMetric>> objectiveFunction, CancellationToken cancellationToken)

Parameters

inputData TInput

The input data required by the objective function (e.g., time series signal).

parametersToOptimize IEnumerable<ParameterDefinition>

A collection of ParameterDefinition objects, describing each parameter's name, bounds, and optional initial guess.

objectiveFunction Func<TInput, IReadOnlyDictionary<string, double>, ObjectiveEvaluation<TMetric>>

A function delegate that, given the input data and a dictionary of current trial parameter values, computes and returns an ObjectiveEvaluation<TMetric>. The evaluation includes the metric value and, optionally, the gradient of the metric with respect to the parameters.

cancellationToken CancellationToken

Token to cancel the optimization process.

Returns

Task<OptimizationResult<TMetric>>

An OptimizationResult<TMetric> containing the best parameters found, the minimized metric value, and other optimization details.

Remarks

Cancellation stops the search and surfaces as an OperationCanceledException rather than returning a partial result as if the search had completed.

Exceptions

OperationCanceledException

Thrown when the operation is cancelled through cancellationToken.

ArgumentNullException

Thrown when parametersToOptimize or objectiveFunction is null.

ArgumentException

Thrown when parameter names are duplicated.