10#ifdef MOOSE_LIBTORCH_ENABLED
33 using ReporterData = std::vector<const std::vector<std::vector<Real>> *>;
43 unsigned int timestep_window,
45 bool average_reward_over_timestep_window);
55 std::vector<LibtorchRLTrajectoryBuffer::Trajectory>
59 const std::vector<std::vector<Real>> & rewards)
const;
76 const std::string & quantity,
77 std::size_t num_samples);
87 downsample(
const std::vector<Real> & sample,
unsigned int offset,
unsigned int num_entries)
const;
95 std::vector<Real>
windowAverage(
const std::vector<Real> & sample,
unsigned int num_entries)
const;
Builds fixed-horizon RL trajectories from raw per-sample reporter sequences.
std::vector< Real > windowAverage(const std::vector< Real > &sample, unsigned int num_entries) const
Average a raw reporter sequence over consecutive timestep windows after the initial entry.
const bool _average_reward_over_timestep_window
Whether rewards are averaged over each window instead of sampled at its end.
unsigned int numTransitions(std::size_t raw_sequence_size) const
Count the transitions available in a raw reporter sequence.
const LibtorchObservationHistoryHelper _observation_history
Observation history stacking helper.
const unsigned int _timestep_window
Raw reporter entries per transition.
std::vector< Real > downsample(const std::vector< Real > &sample, unsigned int offset, unsigned int num_entries) const
Take every timestep_window-th entry of a raw reporter sequence.
std::vector< LibtorchRLTrajectoryBuffer::Trajectory > assemble(const ReporterData &observations, const ReporterData &actions, const ReporterData &log_probabilities, const std::vector< std::vector< Real > > &rewards) const
Assemble one trajectory per sample that holds at least one transition.
const bool _shift_outputs
Whether actions and log probabilities are read one raw entry after the observation.
static void checkSampleCount(const ReporterData &data, const std::string &quantity, std::size_t num_samples)
Check that every component of a rollout quantity holds one sequence per sample.