struct PolicyAgent {
struct Mlp policy;
struct Mlp value;
struct Optimizer opt;
struct PgConfig cfg;
struct Rng rng;
struct TensorArena stepArena;
unsigned long obsDim;
unsigned long actions;
struct Vec<float> rObs;
struct Vec<float> rNext;
struct Vec<float> rAction;
struct Vec<float> rReward;
struct Vec<float> rTerminal;
struct Vec<float> rDone;
unsigned long rollout;
float lastEntropy;
}Separate policy (logits) and value networks, one Adam optimizer. The rollout collects transitions until PolicyAgent::update consumes them: call it at episode ends (REINFORCE) or every N steps (A2C / PPO).
Fields
terminated or truncated
transitions stored
Methods
sample 1: draw from the policy; 0: the most likely action.
§
void record(
const &FloatTensor obs,
unsigned long action,
float reward,
const &FloatTensor next,
int terminated,
int truncated,
)source · definitionTrains on the stored rollout with the configured algorithm, clears it, and returns the last loss.
Parameterized (module.h): the policy and value networks.
= drop()
§
static struct PolicyAgent new(
unsigned long obsDim,
unsigned long actions,
const &PgConfig cfg,
)source · definition