Class ExplorationStrategyBase<T>
- Namespace
- AiDotNet.ReinforcementLearning.Policies.Exploration
- Assembly
- AiDotNet.dll
Abstract base class for exploration strategy implementations. Provides common functionality for noise generation and action clamping.
public abstract class ExplorationStrategyBase<T> : IExplorationStrategy<T>
Type Parameters
TThe numeric type used for calculations.
- Inheritance
-
ExplorationStrategyBase<T>
- Implements
- Derived
- Inherited Members
Fields
NumOps
Numeric operations helper for type-agnostic calculations.
protected static readonly INumericOperations<T> NumOps
Field Value
- INumericOperations<T>
Methods
BoxMullerSample(Random)
Generates a standard normal random sample using the Box-Muller transform.
protected T BoxMullerSample(Random random)
Parameters
randomRandomRandom number generator.
Returns
- T
A sample from the standard normal distribution N(0, 1).
ClampAction(Vector<T>, double, double)
Clamps all elements of an action vector to a specified range. Compatible with net462 (does not use Math.Clamp).
protected Vector<T> ClampAction(Vector<T> action, double min = -1, double max = 1)
Parameters
actionVector<T>The action vector to clamp.
mindoubleThe minimum value (default: -1.0).
maxdoubleThe maximum value (default: 1.0).
Returns
- Vector<T>
A new vector with clamped values.
GetExplorationAction(Vector<T>, Vector<T>, int, Random)
Modifies or replaces the policy's action for exploration.
public abstract Vector<T> GetExplorationAction(Vector<T> state, Vector<T> policyAction, int actionSpaceSize, Random random)
Parameters
stateVector<T>The current state.
policyActionVector<T>The action suggested by the policy.
actionSpaceSizeintThe number of possible actions.
randomRandomRandom number generator for stochastic exploration.
Returns
- Vector<T>
The action to take after applying exploration.
Reset()
Resets internal state (e.g., for new episodes or training sessions).
public virtual void Reset()
Update()
Updates internal parameters (e.g., epsilon decay, noise reduction). Called after each training step.
public abstract void Update()
ValidateActionSize(int, int, string)
Validates that an action vector has the expected size.
protected void ValidateActionSize(int expected, int actual, string paramName)
Parameters
expectedintThe expected action size.
actualintThe actual action size.
paramNamestringThe parameter name for error reporting.
Exceptions
- ArgumentException
Thrown when action size doesn't match expected size.