Table of Contents

Class CMAESOptimizer<T, TInput, TOutput>

Namespace
AiDotNet.Optimizers
Assembly
AiDotNet.dll

Implements the Covariance Matrix Adaptation Evolution Strategy (CMA-ES) optimization algorithm.

public class CMAESOptimizer<T, TInput, TOutput> : OptimizerBase<T, TInput, TOutput>, IOptimizer<T, TInput, TOutput>, IModelSerializer

Type Parameters

T

The numeric type used for calculations (e.g., float, double).

TInput
TOutput
Inheritance
OptimizerBase<T, TInput, TOutput>
CMAESOptimizer<T, TInput, TOutput>
Implements
IOptimizer<T, TInput, TOutput>
Inherited Members
Extension Methods

Remarks

CMA-ES is a powerful optimization algorithm for non-linear, non-convex optimization problems. It is particularly effective for problems with up to about 100 dimensions and is known for its robustness and ability to handle complex fitness landscapes.

For Beginners: CMA-ES is like an advanced search algorithm that tries to find the best solution by learning from previous attempts. It's especially good at solving complex problems where the relationship between inputs and outputs isn't straightforward.

Constructors

CMAESOptimizer(IFullModel<T, TInput, TOutput>, CMAESOptimizerOptions<T, TInput, TOutput>?, IEngine?)

Initializes a new instance of the CMAESOptimizer class.

public CMAESOptimizer(IFullModel<T, TInput, TOutput> model, CMAESOptimizerOptions<T, TInput, TOutput>? options = null, IEngine? engine = null)

Parameters

model IFullModel<T, TInput, TOutput>

The model to optimize.

options CMAESOptimizerOptions<T, TInput, TOutput>

The options for configuring the CMA-ES algorithm.

engine IEngine

Remarks

For Beginners: This constructor sets up the CMA-ES optimizer with its initial configuration. You can customize various aspects of how it works, or use default settings.

Methods

Deserialize(byte[])

Deserializes a byte array to restore the state of the CMA-ES optimizer.

public override void Deserialize(byte[] data)

Parameters

data byte[]

The byte array containing the serialized state of the optimizer.

Remarks

For Beginners: This method loads a previously saved state of the optimizer. It's like restoring a saved game, allowing you to continue from where you left off or use a shared optimizer state.

Exceptions

InvalidOperationException

Thrown when deserialization of optimizer options fails.

GetOptions()

Gets the current options of the CMA-ES optimizer.

public override OptimizationAlgorithmOptions<T, TInput, TOutput> GetOptions()

Returns

OptimizationAlgorithmOptions<T, TInput, TOutput>

The current optimization algorithm options.

Remarks

For Beginners: This method allows you to retrieve the current settings of the CMA-ES optimizer. You can use this to check or save the current configuration.

InitializeAdaptiveParameters()

Initializes the adaptive parameters used in the CMA-ES algorithm.

protected override void InitializeAdaptiveParameters()

Remarks

For Beginners: This method sets up the initial state for the optimizer, including the population, mean, covariance matrix, and step size.

Optimize(OptimizationInputData<T, TInput, TOutput>)

Performs the main optimization process using the CMA-ES algorithm.

public override OptimizationResult<T, TInput, TOutput> Optimize(OptimizationInputData<T, TInput, TOutput> inputData)

Parameters

inputData OptimizationInputData<T, TInput, TOutput>

The input data for the optimization process.

Returns

OptimizationResult<T, TInput, TOutput>

The result of the optimization process.

Remarks

For Beginners: This is the heart of the CMA-ES algorithm. It iteratively improves the solution by generating new populations, evaluating their fitness, and updating the distribution parameters. The process continues until it reaches the maximum number of generations or meets the stopping criteria.

Serialize()

Serializes the current state of the CMA-ES optimizer into a byte array.

public override byte[] Serialize()

Returns

byte[]

A byte array representing the serialized state of the optimizer.

Remarks

For Beginners: This method saves the current state of the optimizer into a format that can be stored or transmitted. This is useful for saving progress or sharing the optimizer's state.

UpdateOptions(OptimizationAlgorithmOptions<T, TInput, TOutput>)

Updates the options for the CMA-ES optimizer.

protected override void UpdateOptions(OptimizationAlgorithmOptions<T, TInput, TOutput> options)

Parameters

options OptimizationAlgorithmOptions<T, TInput, TOutput>

The new options to be set.

Remarks

For Beginners: This method allows you to change the settings of the CMA-ES optimizer during runtime. It checks to make sure you're providing the right kind of options specific to the CMA-ES algorithm.

Exceptions

ArgumentException

Thrown when the provided options are not of the correct type.