Table of Contents

Class PrioritizedReplayBuffer<T>

Namespace
AiDotNet.ReinforcementLearning.ReplayBuffers
Assembly
AiDotNet.dll

Prioritized experience replay buffer for reinforcement learning.

public class PrioritizedReplayBuffer<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
PrioritizedReplayBuffer<T>
Inherited Members

Remarks

Prioritized replay samples important experiences more frequently based on TD error. Uses sum tree data structure for efficient sampling.

Constructors

PrioritizedReplayBuffer(int)

public PrioritizedReplayBuffer(int capacity)

Parameters

capacity int

Properties

Count

public int Count { get; }

Property Value

int

Methods

Add(Vector<T>, Vector<T>, T, Vector<T>, bool)

public void Add(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done)

Parameters

state Vector<T>
action Vector<T>
reward T
nextState Vector<T>
done bool

Sample(int, double, double)

public (List<(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done)> batch, List<int> indices, List<double> weights) Sample(int batchSize, double alpha, double beta)

Parameters

batchSize int
alpha double
beta double

Returns

(List<(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done)> batch, List<int> indices, List<double> weights)

UpdatePriorities(List<int>, List<double>, double)

public void UpdatePriorities(List<int> indices, List<double> priorities, double epsilon)

Parameters

indices List<int>
priorities List<double>
epsilon double