On-policy trajectory storage for fixed-horizon RL training. More...
#include <LibtorchRLTrajectoryBuffer.h>
Classes | |
| struct | RewardStatistics |
| Reward statistics over the stored trajectories. More... | |
| struct | TensorBatch |
| Flattened tensor data assembled from the stored trajectories. More... | |
| struct | Trajectory |
| Vector data for one on-policy trajectory. More... | |
Public Member Functions | |
| void | addTrajectory (Trajectory trajectory) |
| Append one trajectory to the on-policy buffer. | |
| void | clear () |
| Clear every stored trajectory. | |
| bool | empty () const |
| Return true if the buffer contains no trajectories. | |
| std::size_t | numTrajectories () const |
| Return the number of stored trajectories. | |
| std::size_t | numTransitions () const |
| Count the total number of transitions stored across every trajectory. | |
| std::vector< Trajectory > & | trajectories () |
| Return mutable access to the stored trajectories. | |
| const std::vector< Trajectory > & | trajectories () const |
| Return read-only access to the stored trajectories. | |
| TensorBatch | flatten () const |
| Flatten every stored trajectory into one tensor batch. | |
| RewardStatistics | rewardStatistics () const |
| Compute reward statistics over the stored trajectories. | |
Static Private Member Functions | |
| static void | validateTrajectory (const Trajectory &trajectory) |
| Validate a trajectory before it is stored. | |
Private Attributes | |
| std::vector< Trajectory > | _trajectories |
| Stored on-policy trajectories. | |
On-policy trajectory storage for fixed-horizon RL training.
Definition at line 24 of file LibtorchRLTrajectoryBuffer.h.
| void LibtorchRLTrajectoryBuffer::addTrajectory | ( | Trajectory | trajectory | ) |
Append one trajectory to the on-policy buffer.
| trajectory | Trajectory to store. |
Definition at line 67 of file LibtorchRLTrajectoryBuffer.C.
Referenced by LibtorchDRLControlTrainer::collectTrajectoriesFromReporters().
| void LibtorchRLTrajectoryBuffer::clear | ( | ) |
Clear every stored trajectory.
Definition at line 74 of file LibtorchRLTrajectoryBuffer.C.
Referenced by LibtorchDRLControlTrainer::resetData().
|
inline |
Return true if the buffer contains no trajectories.
Definition at line 105 of file LibtorchRLTrajectoryBuffer.h.
| LibtorchRLTrajectoryBuffer::TensorBatch LibtorchRLTrajectoryBuffer::flatten | ( | ) | const |
Flatten every stored trajectory into one tensor batch.
Definition at line 89 of file LibtorchRLTrajectoryBuffer.C.
Referenced by LibtorchDRLControlTrainer::execute().
|
inline |
Return the number of stored trajectories.
Definition at line 110 of file LibtorchRLTrajectoryBuffer.h.
| std::size_t LibtorchRLTrajectoryBuffer::numTransitions | ( | ) | const |
Count the total number of transitions stored across every trajectory.
Definition at line 80 of file LibtorchRLTrajectoryBuffer.C.
Referenced by flatten(), and rewardStatistics().
| LibtorchRLTrajectoryBuffer::RewardStatistics LibtorchRLTrajectoryBuffer::rewardStatistics | ( | ) | const |
Compute reward statistics over the stored trajectories.
Definition at line 147 of file LibtorchRLTrajectoryBuffer.C.
Referenced by LibtorchDRLControlTrainer::computeEpisodeRewardStatistics().
|
inline |
Return mutable access to the stored trajectories.
Definition at line 121 of file LibtorchRLTrajectoryBuffer.h.
Referenced by LibtorchRLValueEstimator::computeValueTargets().
|
inline |
Return read-only access to the stored trajectories.
Definition at line 126 of file LibtorchRLTrajectoryBuffer.h.
|
staticprivate |
Validate a trajectory before it is stored.
| trajectory | Trajectory to validate. |
Definition at line 191 of file LibtorchRLTrajectoryBuffer.C.
Referenced by addTrajectory().
|
private |
Stored on-policy trajectories.
Definition at line 148 of file LibtorchRLTrajectoryBuffer.h.
Referenced by addTrajectory(), clear(), empty(), flatten(), numTrajectories(), numTransitions(), rewardStatistics(), trajectories(), and trajectories().