10#ifdef MOOSE_LIBTORCH_ENABLED
47 virtual void execute()
override;
120 std::shared_ptr<Moose::LibtorchActorNeuralNet>
_actor_nn;
A time-dependent, neural-network-based controller which is associated with a Proximal Policy Optimiza...
bool _has_control_offsets
Whether any offset data was provided by the user.
virtual void loadControlNeuralNetFromFile() override
Load the actor neural network from the configured checkpoint file.
std::vector< Real > _control_offsets
Constant offsets added to each control signal before it is applied.
at::Generator _policy_generator
Owned libtorch CPU generator used for policy sampling.
void restorePolicyGeneratorState()
Restore the owned libtorch generator state from restartable storage.
void savePolicyGeneratorState()
Mirror the owned libtorch generator state into restartable storage.
Real getSignalLogProbability(const unsigned int signal_index) const
Get the logarithmic probability of (signal_index)-th signal of the control neural net.
virtual void execute() override
Compute the actions and their corresponding logarithmic probabilities.
std::vector< Real > & _previous_control_signal
The smoothed control signal from the previous execution, saved for restart/recover.
std::vector< Real > & _current_control_signal_log_probabilities
The log probability of control signals from the last evaluation of the controller.
Real computeControlOffset(unsigned int control_i) const
Return the offset to add to a control signal at the current time.
static InputParameters validParams()
Return the input parameters supported by this control.
const bool _stochastic
Whether to sample actions stochastically instead of using the deterministic actor output.
const Real _control_smoothing_factor
Exponential smoothing factor in (0, 1] applied to the control signal at each time step.
unsigned int numStepsInPeriod() const
Return the number of time steps between policy evaluations.
void loadControlNeuralNet(const Moose::LibtorchActorNeuralNet &input_nn)
Copy an actor network into this DRL controller.
bool shouldEvaluatePolicy() const
Report whether the policy is evaluated at the current time step.
std::vector< Real > & _current_smoothed_signal
The current smoothed control signal applied to the controllable parameters.
const unsigned int _num_steps_in_period
Number of time steps between policy evaluations.
void setPolicySampleSeed(uint64_t seed)
Reset the owned policy-sampling generator to a known seed.
std::shared_ptr< Moose::LibtorchActorNeuralNet > _actor_nn
Actor network used when the controller operates as a stochastic policy.
std::vector< std::uint8_t > & _policy_generator_state
Restartable serialized state for the owned policy-sampling generator.
virtual void initialSetup() override
Restore any restartable controller state after base setup completes.
unsigned int numberOfObservations() const
Return the number of observations read at each time level.
unsigned int inputTimesteps() const
Return the number of observation time levels stacked into the actor input.
void applyControlSignals()
Apply the current smoothed control signals, including optional offsets.
const unsigned int _input_timesteps
const std::vector< PostprocessorName > & _observation_names
const InputParameters & parameters() const
Feed-forward actor network coupled to a Gaussian or Beta action distribution.