LinearSARSAAgent<T>

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

Linear SARSA agent using linear function approximation with on-policy learning.

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

For Beginners

Linear SARSA is like Linear Q-Learning but learns on-policy, meaning it evaluates and improves the policy it is actually following. The name SARSA comes from the update sequence: State, Action, Reward, next State, next Action. This makes it safer for real-world applications because it accounts for the exploration the agent is doing, unlike Q-Learning which assumes optimal future behavior.

Example

// Create a linear SARSA agent for on-policy learning with function approximation
var options = new LinearSARSAOptions<double> { FeatureSize = 4, ActionSize = 2, LearningRate = 0.01 };
var agent = new LinearSARSAAgent<double>(options);
            
// Select an action using linear value function
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);

Constructors

Constructor Summary
LinearSARSAAgent() Initializes a new instance with default settings.
LinearSARSAAgent(LinearSARSAOptions<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)