LinearQLearningAgent<T>

Models & Types ยท AiDotNet.ReinforcementLearning.Agents.AdvancedRL

Linear Q-Learning agent using linear function approximation.

Inheritance: ReinforcementLearningAgentBase<T> โ†’ LinearQLearningAgent<T>

For Beginners

Linear Q-Learning replaces the Q-table with a linear function Q(s,a) = w dot phi(s,a), where phi extracts features from state-action pairs. This allows handling continuous or large state spaces that would be impossible with tables. Think of it like using a formula instead of a lookup table. The trade-off is that it can only represent linear relationships, but it scales to much larger problems than tabular Q-learning.

Example

// Create a linear Q-Learning agent for continuous state spaces
var options = new LinearQLearningOptions<double> { FeatureSize = 4, ActionSize = 2, LearningRate = 0.01 };
var agent = new LinearQLearningAgent<double>(options);
            
// Select an action using linear function approximation
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);

Constructors

Constructor Summary
LinearQLearningAgent() Initializes a new instance with default settings.
LinearQLearningAgent(LinearQLearningOptions<T> options)

Properties

Property Summary
int FeatureCount { get; }

Methods

Method Summary
Dictionary<string, T> GetMetrics()
ModelMetadata<T> GetModelMetadata()
T Train()
Task TrainAsync()
Task<Vector<T>> PredictAsync(Vector<T> input)
Vector<T> Predict(Vector<T> input)
Vector<T> SelectAction(Vector<T> state, bool training)
byte[] Serialize() Auto-generated common model serialization surface.
void Deserialize(byte[] data) Auto-generated common model deserialization surface.
void LoadModel(string filepath)
void ResetEpisode()
void SaveModel(string filepath)
void StoreExperience(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done)