10#ifdef MOOSE_LIBTORCH_ENABLED
16#include <torch/torch.h>
On-policy trajectory storage for fixed-horizon RL training.
void addTrajectory(Trajectory trajectory)
Append one trajectory to the on-policy buffer.
std::vector< Trajectory > & trajectories()
Return mutable access to the stored trajectories.
TensorBatch flatten() const
Flatten every stored trajectory into one tensor batch.
std::size_t numTrajectories() const
Return the number of stored trajectories.
RewardStatistics rewardStatistics() const
Compute reward statistics over the stored trajectories.
static void validateTrajectory(const Trajectory &trajectory)
Validate a trajectory before it is stored.
std::vector< Trajectory > _trajectories
Stored on-policy trajectories.
bool empty() const
Return true if the buffer contains no trajectories.
void clear()
Clear every stored trajectory.
std::size_t numTransitions() const
Count the total number of transitions stored across every trajectory.
const std::vector< Trajectory > & trajectories() const
Return read-only access to the stored trajectories.
Reward statistics over the stored trajectories.
std::vector< Real > trajectory_stds
Reward standard deviation of each non-empty trajectory about its own mean.
std::vector< Real > trajectory_means
Mean reward of each non-empty trajectory.
Real mean
Mean reward over every stored transition.
Flattened tensor data assembled from the stored trajectories.
torch::Tensor actions
Flattened action matrix.
torch::Tensor value_targets
Flattened critic targets.
torch::Tensor next_observations
Flattened next-observation matrix.
torch::Tensor observations
Flattened observation matrix.
torch::Tensor advantages
Flattened advantages.
torch::Tensor log_probabilities
Flattened action log-probabilities.
torch::Tensor rewards
Flattened rewards.
std::int64_t size() const
Return the number of transitions represented by the batch.
Vector data for one on-policy trajectory.
std::vector< Real > advantages
Advantage estimates aligned with each transition.
std::vector< Real > rewards
Scalar rewards for each transition.
std::vector< std::vector< Real > > observations
Observations for each transition.
std::vector< std::vector< Real > > actions
Actions applied at each transition.
std::vector< std::vector< Real > > next_observations
Next observations for each transition.
std::vector< Real > value_targets
Critic targets aligned with each transition.
std::vector< std::vector< Real > > log_probabilities
Action log-probabilities recorded during rollout.
std::vector< bool > terminals
Terminal flags for each transition. A true value cuts value bootstrapping at that step.