10#ifdef MOOSE_LIBTORCH_ENABLED
47 virtual void execute()
override;
54 Real
getSignal(
const unsigned int signal_index)
const;
92 const std::vector<std::string> & conditional_param,
93 bool should_be_defined =
true);
140 std::shared_ptr<Moose::LibtorchNeuralNetBase>
_nn;
Base class for Control objects.
A time-dependent, neural network-based control of multiple input parameters.
const std::vector< Real > _action_scaling_factors
Multipliers for the actions.
virtual void execute() override
Execute the neural network to determine the controllable parameter values.
void conditionalParameterError(const std::string ¶m_name, const std::vector< std::string > &conditional_param, bool should_be_defined=true)
Function responsible for checking for potential user errors in the input file.
bool hasControlNeuralNet() const
Return true if the object already has a neural network.
virtual void initialSetup() override
Load any file-backed controller state after full object construction.
const unsigned int _input_timesteps
Number of timesteps to use as input data from the reporters (this influences how many past results ar...
virtual void loadControlNeuralNet(const Moose::LibtorchArtificialNeuralNet &input_nn)
Function responsible for loading the neural network for the controller.
Real getSignal(const unsigned int signal_index) const
Get the (signal_index)-th signal of the control neural net.
unsigned int numberOfControlSignals() const
Get the number of controls this object is computing.
const std::vector< PostprocessorName > & _observation_names
Names of the postprocessors which contain the observations of the system.
const std::vector< Real > _observation_shift_factors
Shifting constants for the observations.
static InputParameters validParams()
Return the input parameters supported by this control.
const std::vector< Real > _observation_scaling_factors
Scaling constants (multipliers) for the observations.
std::vector< Real > _current_observation
The values of the current observed postprocessor values.
std::vector< Real > & _current_control_signals
The control signals from the last evaluation of the controller, saved for recover/restart.
void updateCurrentObservation()
Refresh the current observation values from the linked postprocessors.
virtual void loadControlNeuralNetFromFile()
Load the controller neural network from the configured checkpoint file.
const std::vector< std::string > & _control_names
The names of the controllable parameters.
torch::Tensor prepareInputTensor()
Prepare the input tensor for the controller neural network.
std::shared_ptr< Moose::LibtorchNeuralNetBase > _nn
Pointer to the neural net object which is supposed to be used to control the parameter values.
const LibtorchObservationHistoryHelper _observation_history
Shared observation history stacking and factor-expansion helper.
std::vector< std::vector< Real > > & _old_observations
This variable is populated if the controller needs access to older values of the observed postprocess...
std::vector< const Real * > _observation_values
Links to the current observation postprocessor values.
const Moose::LibtorchNeuralNetBase & controlNeuralNet() const
Return a reference to the stored neural network.
Shared observation history stacking and factor-expansion logic for libtorch-based controls and traine...
const InputParameters & parameters() const
Get the parameters of the object.
Simple feed-forward neural net with optional affine input and output scaling.
This base class is meant to gather the functions and members common in every neural network based on ...