DynaQAgent<T>

Models & Types · AiDotNet.ReinforcementLearning.Agents.Planning

Dyna-Q agent combining learning and planning using a learned model.

Inheritance: ReinforcementLearningAgentBase<T> → DynaQAgent<T>

For Beginners

Dyna-Q learns from real experiences AND simulated ones. After each real interaction, it also “replays” past experiences in a mental model, like practicing chess moves in your head. This lets it learn much faster than pure Q-learning because each real experience generates many simulated learning updates. The planning steps parameter controls how many simulated updates happen per real step.

Example

// Create a Dyna-Q agent that combines real and simulated learning
var options = new DynaQOptions<double> { PlanningSteps = 10, StateSize = 4, ActionSize = 2 };
var agent = new DynaQAgent<double>(options);
            
// Select an action and learn from both real and simulated experiences
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);

Constructors

Constructor Summary
DynaQAgent()
DynaQAgent(DynaQOptions<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)