ModifiedPolicyIterationAgent<T>

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

Modified Policy Iteration agent - hybrid of Policy Iteration and Value Iteration.

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

For Beginners

Modified Policy Iteration is a middle ground between two classic algorithms: Value Iteration (fast but less stable) and Policy Iteration (stable but slow). Instead of fully evaluating a policy before improving it, it does a limited number of evaluation sweeps. Think of it like proofreading a draft: you do a few passes (not infinite) before revising. The number of evaluation sweeps controls the speed-stability trade-off.

How It Works

Modified PI performs limited policy evaluation sweeps before improvement, trading off between the efficiency of VI and the stability of PI.

Example

// Create a Modified Policy Iteration agent balancing speed and stability
var options = new ModifiedPolicyIterationOptions<double> { StateSize = 4, ActionSize = 2, MaxEvaluationSweeps = 5 };
var agent = new ModifiedPolicyIterationAgent<double>(options);
            
// Select an action using the partially-evaluated policy
var state = new Vector<double>(new double[] { 0.5, -0.3, 1.0, 0.2 });
var action = agent.SelectAction(state);

Constructors

Constructor Summary
ModifiedPolicyIterationAgent() Initializes a new instance with default options (StateSize=4, ActionSize=2).
ModifiedPolicyIterationAgent(ModifiedPolicyIterationOptions<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)