QTableParameterSource<T>

Models & Types · AiDotNet.ReinforcementLearning.Parameters

Exposes a tabular agent’s Q-table as a parameter source, so it can be registered like a network instead of every agent hand-writing the same flatten-and-refill loops.

Implements: IParameterSource<T>, IParameterTopologySource

For Beginners

this presents a lookup table of action values as one flat list of numbers, so saving and loading it works the same way it does for a neural network.

How It Works

Seventeen agents stored their values as Dictionary<string, Dictionary<int, T>> and each wrote its own ParameterCount, GetParameters and SetParameters over it. They were the same three loops seventeen times, which is three chances per agent for the count and the vector to disagree.

The table is held BY REFERENCE, deliberately. A tabular agent discovers states as it explores, so its parameter count genuinely grows during training; a snapshot taken at registration would describe a model that no longer exists. Every member reads the live dictionary.

Row order is the dictionary’s enumeration order, which is what the hand-written code used, so serialization order is unchanged by this conversion. That order is stable for a dictionary that is only ever added to, which is the tabular usage – but it is NOT guaranteed across a removal, so an agent that starts pruning states needs an explicit ordering here.

Constructors

Constructor Summary
QTableParameterSource(Dictionary<string, Dictionary<int, T>> table, int actionSize) Wraps table, reading actionSize values per state.

Properties

Property Summary
long ParameterCount { get; }

Methods

Method Summary
Vector<T> GetParameters()
void ReadParameterTopology(BinaryReader reader)
void SetParameters(Vector<T> parameters)
void WriteParameterTopology(BinaryWriter writer)