ValueIterationAgent<T>

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

Value Iteration agent for reinforcement learning using dynamic programming.

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

For Beginners

Value Iteration repeatedly updates state values using the Bellman optimality equation until they converge. Unlike Policy Iteration which does full evaluation then improvement, Value Iteration does both in a single sweep - making it simpler but potentially slower per iteration. Think of it like iteratively improving a GPS estimate: each pass gets closer to the true shortest path. Requires a complete model of the environment.

How It Works

Value Iteration combines policy evaluation and improvement in a single update step, converging to the optimal value function.

Example

// Create a Value Iteration agent for dynamic programming
var options = new ValueIterationOptions<double> { StateSize = 4, ActionSize = 2 };
var agent = new ValueIterationAgent<double>(options);
            
// Select an action using the converged 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
ValueIterationAgent() Initializes a new instance with default settings.
ValueIterationAgent(ValueIterationOptions<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)