A time-dependent, neural-network-based controller which is associated with a Proximal Policy Optimization. More...
#include <LibtorchDRLControl.h>
Public Types | |
| typedef DataFileName | DataFileParameterType |
Public Member Functions | |
| LibtorchDRLControl (const InputParameters ¶meters) | |
| Construct using input parameters. | |
| virtual void | initialSetup () override |
| Restore any restartable controller state after base setup completes. | |
| virtual void | execute () override |
| Compute the actions and their corresponding logarithmic probabilities. | |
| Real | getSignalLogProbability (const unsigned int signal_index) const |
| Get the logarithmic probability of (signal_index)-th signal of the control neural net. | |
| void | loadControlNeuralNet (const Moose::LibtorchActorNeuralNet &input_nn) |
| Copy an actor network into this DRL controller. | |
| virtual void | loadControlNeuralNet (const Moose::LibtorchArtificialNeuralNet &input_nn) override |
| Reject loading a plain artificial neural network into this actor-based controller. | |
| virtual void | loadControlNeuralNetFromFile () override |
| Load the actor neural network from the configured checkpoint file. | |
| void | setPolicySampleSeed (uint64_t seed) |
| Reset the owned policy-sampling generator to a known seed. | |
| unsigned int | numStepsInPeriod () const |
| Return the number of time steps between policy evaluations. | |
| unsigned int | inputTimesteps () const |
| Return the number of observation time levels stacked into the actor input. | |
| unsigned int | numberOfObservations () const |
| Return the number of observations read at each time level. | |
| Real | getSignal (const unsigned int signal_index) const |
| unsigned int | numberOfControlSignals () const |
| const Moose::LibtorchNeuralNetBase & | controlNeuralNet () const |
| bool | hasControlNeuralNet () const |
| std::vector< std::string > & | getDependencies () |
| virtual bool | enabled () const |
| std::shared_ptr< MooseObject > | getSharedPtr () |
| std::shared_ptr< const MooseObject > | getSharedPtr () const |
| bool | isKokkosObject () const |
| MooseApp & | getMooseApp () const |
| const std::string & | type () const |
| const std::string & | name () const |
| std::string | typeAndName () const |
| MooseObjectParameterName | uniqueParameterName (const std::string ¶meter_name) const |
| MooseObjectName | uniqueName () const |
| const InputParameters & | parameters () const |
| const hit::Node * | getHitNode () const |
| bool | hasBase () const |
| const std::string & | getBase () const |
| const T & | getParam (const std::string &name) const |
| std::vector< std::pair< T1, T2 > > | getParam (const std::string ¶m1, const std::string ¶m2) const |
| const T * | queryParam (const std::string &name) const |
| const T & | getRenamedParam (const std::string &old_name, const std::string &new_name) const |
| T | getCheckedPointerParam (const std::string &name, const std::string &error_string="") const |
| bool | isParamValid (const std::string &name) const |
| bool | isParamSetByUser (const std::string &name) const |
| void | connectControllableParams (const std::string ¶meter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const |
| void | paramError (const std::string ¶m, Args... args) const |
| void | paramWarning (const std::string ¶m, Args... args) const |
| void | paramWarning (const std::string ¶m, Args... args) const |
| void | paramInfo (const std::string ¶m, Args... args) const |
| std::string | messagePrefix (const bool hit_prefix=true) const |
| std::string | errorPrefix (const std::string &) const |
| void | mooseError (Args &&... args) const |
| void | mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const |
| void | mooseErrorNonPrefixed (Args &&... args) const |
| void | mooseWarning (Args &&... args) const |
| void | mooseWarning (Args &&... args) const |
| void | mooseWarningNonPrefixed (Args &&... args) const |
| void | mooseWarningNonPrefixed (Args &&... args) const |
| void | mooseDeprecated (Args &&... args) const |
| void | mooseDeprecated (Args &&... args) const |
| void | mooseDeprecatedNoTrace (Args &&... args) const |
| void | mooseInfo (Args &&... args) const |
| void | callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const |
| std::string | getDataFileName (const std::string ¶m) const |
| std::string | getDataFileNameByName (const std::string &relative_path) const |
| std::string | getDataFilePath (const std::string &relative_path) const |
| bool | isImplicit () |
| Moose::StateArg | determineState () const |
| virtual void | timestepSetup () |
| virtual void | jacobianSetup () |
| virtual void | residualSetup () |
| virtual void | subdomainSetup () |
| virtual void | customSetup (const ExecFlagType &) |
| const ExecFlagEnum & | getExecuteOnEnum () const |
| const Function & | getFunction (const std::string &name) const |
| const Function & | getFunctionByName (const FunctionName &name) const |
| bool | hasFunction (const std::string ¶m_name) const |
| bool | hasFunctionByName (const FunctionName &name) const |
| Moose::Kokkos::Function | getKokkosFunction (const std::string &name) const |
| const T & | getKokkosFunction (const std::string &name) const |
| Moose::Kokkos::Function | getKokkosFunctionByName (const FunctionName &name) const |
| const T & | getKokkosFunctionByName (const FunctionName &name) const |
| bool | hasKokkosFunction (const std::string ¶m_name) const |
| bool | hasKokkosFunctionByName (const FunctionName &name) const |
| UserObjectName | getUserObjectName (const std::string ¶m_name) const |
| const T & | getUserObject (const std::string ¶m_name, bool is_dependency=true) const |
| const T & | getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const |
| const UserObjectBase & | getUserObjectBase (const std::string ¶m_name, bool is_dependency=true) const |
| const UserObjectBase & | getUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const |
| bool | hasUserObject (const std::string ¶m_name) const |
| bool | hasUserObject (const std::string ¶m_name) const |
| bool | hasUserObject (const std::string ¶m_name) const |
| bool | hasUserObject (const std::string ¶m_name) const |
| bool | hasUserObjectByName (const UserObjectName &object_name) const |
| bool | hasUserObjectByName (const UserObjectName &object_name) const |
| bool | hasUserObjectByName (const UserObjectName &object_name) const |
| bool | hasUserObjectByName (const UserObjectName &object_name) const |
| PerfGraph & | perfGraph () |
| bool | isDefaultPostprocessorValue (const std::string ¶m_name, const unsigned int index=0) const |
| bool | hasPostprocessor (const std::string ¶m_name, const unsigned int index=0) const |
| bool | hasPostprocessorByName (const PostprocessorName &name) const |
| std::size_t | coupledPostprocessors (const std::string ¶m_name) const |
| const PostprocessorName & | getPostprocessorName (const std::string ¶m_name, const unsigned int index=0) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValue (const std::string ¶m_name, const std::string &vector_name) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValue (const std::string ¶m_name, const std::string &vector_name, bool needs_broadcast) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValueOld (const std::string ¶m_name, const std::string &vector_name) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValueOld (const std::string ¶m_name, const std::string &vector_name, bool needs_broadcast) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
| const VectorPostprocessorValue & | getVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const |
| const ScatterVectorPostprocessorValue & | getScatterVectorPostprocessorValue (const std::string ¶m_name, const std::string &vector_name) const |
| const ScatterVectorPostprocessorValue & | getScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
| const ScatterVectorPostprocessorValue & | getScatterVectorPostprocessorValueOld (const std::string ¶m_name, const std::string &vector_name) const |
| const ScatterVectorPostprocessorValue & | getScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
| bool | hasVectorPostprocessor (const std::string ¶m_name, const std::string &vector_name) const |
| bool | hasVectorPostprocessor (const std::string ¶m_name) const |
| bool | hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
| bool | hasVectorPostprocessorByName (const VectorPostprocessorName &name) const |
| const VectorPostprocessorName & | getVectorPostprocessorName (const std::string ¶m_name) const |
| const PostprocessorValue & | getPostprocessorValue (const std::string ¶m_name, const unsigned int index=0) const |
| const PostprocessorValue & | getPostprocessorValue (const std::string ¶m_name, const unsigned int index=0) const |
| const PostprocessorValue & | getPostprocessorValueOld (const std::string ¶m_name, const unsigned int index=0) const |
| const PostprocessorValue & | getPostprocessorValueOld (const std::string ¶m_name, const unsigned int index=0) const |
| const PostprocessorValue & | getPostprocessorValueOlder (const std::string ¶m_name, const unsigned int index=0) const |
| const PostprocessorValue & | getPostprocessorValueOlder (const std::string ¶m_name, const unsigned int index=0) const |
| virtual const PostprocessorValue & | getPostprocessorValueByName (const PostprocessorName &name) const |
| virtual const PostprocessorValue & | getPostprocessorValueByName (const PostprocessorName &name) const |
| const PostprocessorValue & | getPostprocessorValueOldByName (const PostprocessorName &name) const |
| const PostprocessorValue & | getPostprocessorValueOldByName (const PostprocessorName &name) const |
| const PostprocessorValue & | getPostprocessorValueOlderByName (const PostprocessorName &name) const |
| const PostprocessorValue & | getPostprocessorValueOlderByName (const PostprocessorName &name) const |
| bool | isVectorPostprocessorDistributed (const std::string ¶m_name) const |
| bool | isVectorPostprocessorDistributed (const std::string ¶m_name) const |
| bool | isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const |
| bool | isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const |
| const Parallel::Communicator & | comm () const |
| processor_id_type | n_processors () const |
| processor_id_type | processor_id () const |
Static Public Member Functions | |
| static InputParameters | validParams () |
| Return the input parameters supported by this control. | |
| static void | callMooseError (MooseApp *const app, const InputParameters ¶ms, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true) |
| static MultiMooseEnum | getExecuteOptions () |
Public Attributes | |
| usingCombinedWarningSolutionWarnings | |
| const ConsoleStream | _console |
Static Public Attributes | |
| static const std::string | type_param |
| static const std::string | name_param |
| static const std::string | unique_name_param |
| static const std::string | app_param |
| static const std::string | moose_base_param |
| static const std::string | kokkos_object_param |
Protected Member Functions | |
| void | applyControlSignals () |
| Apply the current smoothed control signals, including optional offsets. | |
| Real | computeControlOffset (unsigned int control_i) const |
| Return the offset to add to a control signal at the current time. | |
| void | conditionalParameterError (const std::string ¶m_name, const std::vector< std::string > &conditional_param, bool should_be_defined=true) |
| void | updateCurrentObservation () |
| torch::Tensor | prepareInputTensor () |
| bool | hasControllableParameterByName (const std::string &name) const |
| void | flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const |
| InvalidSolutionID | registerInvalidSolutionInternal (const std::string &message, const bool warning) const |
| PerfID | registerTimedSection (const std::string §ion_name, const unsigned int level) const |
| PerfID | registerTimedSection (const std::string §ion_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const |
| std::string | timedSectionName (const std::string §ion_name) const |
| virtual void | addUserObjectDependencyHelper (const UserObjectBase &) const |
| T & | declareRestartableData (const std::string &data_name, Args &&... args) |
| ManagedValue< T > | declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args) |
| const T & | getRestartableData (const std::string &data_name) const |
| T & | declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args) |
| T & | declareRecoverableData (const std::string &data_name, Args &&... args) |
| T & | declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args) |
| T & | declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args) |
| std::string | restartableName (const std::string &data_name) const |
| virtual void | addPostprocessorDependencyHelper (const PostprocessorName &) const |
| virtual void | addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) const |
| const ReporterContextBase & | getReporterContextBaseByName (const ReporterName &reporter_name) const |
| const ReporterName & | getReporterName (const std::string ¶m_name) const |
| virtual void | addReporterDependencyHelper (const ReporterName &) |
| ControllableParameter | getControllableParameter (const std::string ¶m_name) |
| ControllableParameter | getControllableParameter (const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const std::string &tag, const std::string &object_name, const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const MooseObjectName &object_name, const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const MooseObjectParameterName ¶m_name) |
| ControllableParameter | getControllableParameterByName (const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const std::string &tag, const std::string &object_name, const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const MooseObjectName &object_name, const std::string ¶m_name) |
| ControllableParameter | getControllableParameterByName (const MooseObjectParameterName ¶m_name) |
| T | getControllableValue (const std::string &name, bool warn_when_values_differ=true) |
| T | getControllableValue (const std::string &name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const std::string &name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const std::string &object_name, const std::string ¶m_name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const MooseObjectName &object_name, const std::string ¶m_name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const std::string &tag, const std::string &object_name, const std::string ¶m_name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const MooseObjectParameterName &desired, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const std::string &name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const std::string &object_name, const std::string ¶m_name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const MooseObjectName &object_name, const std::string ¶m_name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const std::string &tag, const std::string &object_name, const std::string ¶m_name, bool warn_when_values_differ=true) |
| T | getControllableValueByName (const MooseObjectParameterName &desired, bool warn_when_values_differ=true) |
| void | setControllableValue (const std::string &name, const T &value) |
| void | setControllableValue (const std::string &name, const T &value) |
| void | setControllableValueByName (const std::string &name, const T &value) |
| void | setControllableValueByName (const std::string &object_name, const std::string ¶m_name, const T &value) |
| void | setControllableValueByName (const MooseObjectName &object_name, const std::string ¶m_name, const T &value) |
| void | setControllableValueByName (const std::string &tag, const std::string &object_name, const std::string ¶m_name, const T &value) |
| void | setControllableValueByName (const MooseObjectParameterName &name, const T &value) |
| void | setControllableValueByName (const std::string &name, const T &value) |
| void | setControllableValueByName (const std::string &object_name, const std::string ¶m_name, const T &value) |
| void | setControllableValueByName (const MooseObjectName &object_name, const std::string ¶m_name, const T &value) |
| void | setControllableValueByName (const std::string &tag, const std::string &object_name, const std::string ¶m_name, const T &value) |
| void | setControllableValueByName (const MooseObjectParameterName &name, const T &value) |
| const T & | getReporterValue (const std::string ¶m_name, const std::size_t time_index=0) |
| const T & | getReporterValue (const std::string ¶m_name, ReporterMode mode, const std::size_t time_index=0) |
| const T & | getReporterValue (const std::string ¶m_name, const std::size_t time_index=0) |
| const T & | getReporterValue (const std::string ¶m_name, ReporterMode mode, const std::size_t time_index=0) |
| const T & | getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0) |
| const T & | getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0) |
| const T & | getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0) |
| const T & | getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0) |
| bool | hasReporterValue (const std::string ¶m_name) const |
| bool | hasReporterValue (const std::string ¶m_name) const |
| bool | hasReporterValue (const std::string ¶m_name) const |
| bool | hasReporterValue (const std::string ¶m_name) const |
| bool | hasReporterValueByName (const ReporterName &reporter_name) const |
| bool | hasReporterValueByName (const ReporterName &reporter_name) const |
| bool | hasReporterValueByName (const ReporterName &reporter_name) const |
| bool | hasReporterValueByName (const ReporterName &reporter_name) const |
Protected Attributes | |
| std::vector< Real > & | _current_control_signal_log_probabilities |
| The log probability of control signals from the last evaluation of the controller. | |
| std::vector< Real > & | _previous_control_signal |
| The smoothed control signal from the previous execution, saved for restart/recover. | |
| std::vector< Real > & | _current_smoothed_signal |
| The current smoothed control signal applied to the controllable parameters. | |
| std::vector< Real > | _control_offsets |
| Constant offsets added to each control signal before it is applied. | |
| bool | _has_control_offsets |
| Whether any offset data was provided by the user. | |
| std::shared_ptr< Moose::LibtorchActorNeuralNet > | _actor_nn |
| Actor network used when the controller operates as a stochastic policy. | |
| at::Generator | _policy_generator |
| Owned libtorch CPU generator used for policy sampling. | |
| std::vector< std::uint8_t > & | _policy_generator_state |
| Restartable serialized state for the owned policy-sampling generator. | |
| const unsigned int | _num_steps_in_period |
| Number of time steps between policy evaluations. | |
| const Real | _control_smoothing_factor |
| Exponential smoothing factor in (0, 1] applied to the control signal at each time step. | |
| const bool | _stochastic |
| Whether to sample actions stochastically instead of using the deterministic actor output. | |
| std::vector< Real > | _current_observation |
| std::vector< std::vector< Real > > & | _old_observations |
| const std::vector< std::string > & | _control_names |
| std::vector< Real > & | _current_control_signals |
| const std::vector< PostprocessorName > & | _observation_names |
| std::vector< const Real * > | _observation_values |
| const unsigned int | _input_timesteps |
| const std::vector< Real > | _observation_shift_factors |
| const std::vector< Real > | _observation_scaling_factors |
| const std::vector< Real > | _action_scaling_factors |
| const LibtorchObservationHistoryHelper | _observation_history |
| std::shared_ptr< Moose::LibtorchNeuralNetBase > | _nn |
| FEProblemBase & | _fe_problem |
| std::vector< std::string > | _depends_on |
| const bool & | _enabled |
| MooseApp & | _app |
| Factory & | _factory |
| ActionFactory & | _action_factory |
| const std::string & | _type |
| const std::string & | _name |
| const InputParameters & | _pars |
| MooseApp & | _pg_moose_app |
| const std::string | _prefix |
| const InputParameters & | _ti_params |
| FEProblemBase & | _ti_feproblem |
| bool | _is_implicit |
| Real & | _t |
| const Real & | _t_old |
| int & | _t_step |
| Real & | _dt |
| Real & | _dt_old |
| bool | _is_transient |
| const ExecFlagEnum & | _execute_enum |
| const ExecFlagType & | _current_execute_flag |
| MooseApp & | _restartable_app |
| const std::string | _restartable_system_name |
| const THREAD_ID | _restartable_tid |
| const bool | _restartable_read_only |
| const Parallel::Communicator & | _communicator |
Private Member Functions | |
| bool | shouldEvaluatePolicy () const |
| Report whether the policy is evaluated at the current time step. | |
| void | restorePolicyGeneratorState () |
| Restore the owned libtorch generator state from restartable storage. | |
| void | savePolicyGeneratorState () |
| Mirror the owned libtorch generator state into restartable storage. | |
| const Moose::FunctionBase * | getKokkosFunctionByNameHelper (const FunctionName &name) const |
| const UserObjectBase & | getUserObjectFromFEProblem (const UserObjectName &object_name, const THREAD_ID tid=0) const |
| const T & | castUserObject (const UserObjectBase &uo_base, const std::string ¶m_name="") const |
| void | mooseObjectError (const std::string ¶m_name, std::stringstream &oss) const |
| const std::string & | userObjectType (const UserObjectBase &uo) const |
| const std::string & | userObjectName (const UserObjectBase &uo) const |
| RestartableDataValue & | registerRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const |
| void | registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter) |
| RestartableData< T > & | declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const |
| const PostprocessorName & | getPostprocessorNameInternal (const std::string ¶m_name, const unsigned int index, const bool allow_default_value=true) const |
| bool | isDefaultPostprocessorValueByName (const PostprocessorName &name) const |
| PostprocessorValue | getDefaultPostprocessorValueByName (const PostprocessorName &name) const |
| void | checkParam (const std::string ¶m_name, const unsigned int index=std::numeric_limits< unsigned int >::max()) const |
| bool | postprocessorsAdded () const |
| const VectorPostprocessorValue & | getVectorPostprocessorByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name, bool broadcast, std::size_t t_index) const |
| const VectorPostprocessorContext< VectorPostprocessorValue > & | getVectorPostprocessorContextByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name) const |
| bool | vectorPostprocessorsAdded () const |
| bool | reportersAdded () const |
| void | possiblyCheckHasReporter (const ReporterName &reporter_name, const std::string ¶m_name="") const |
| const PostprocessorValue & | getPostprocessorValueInternal (const std::string ¶m_name, unsigned int index, std::size_t t_index) const |
| const PostprocessorValue & | getPostprocessorValueInternal (const std::string ¶m_name, unsigned int index, std::size_t t_index) const |
| const PostprocessorValue & | getPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const |
| const PostprocessorValue & | getPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const |
| void | possiblyCheckHasVectorPostprocessor (const std::string ¶m_name, const std::string &vector_name) const |
| void | possiblyCheckHasVectorPostprocessor (const std::string ¶m_name, const std::string &vector_name) const |
| void | possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
| void | possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const |
Static Private Member Functions | |
| static const hit::Node * | getHitNode (const InputParameters ¶ms) |
| static std::string | messagePrefix (const InputParameters ¶ms, const bool hit_prefix) |
A time-dependent, neural-network-based controller which is associated with a Proximal Policy Optimization.
We use this neural net for the training of a controller. The additional functionality in this controller is the addition of the variability (using an assumed Gaussian distribution) to avoid overfitting. This control is supposed to be used in conjunction with LibtorchDRLControlTrainer.
Definition at line 26 of file LibtorchDRLControl.h.
| LibtorchDRLControl::LibtorchDRLControl | ( | const InputParameters & | parameters | ) |
Construct using input parameters.
Definition at line 71 of file LibtorchDRLControl.C.
|
protected |
Apply the current smoothed control signals, including optional offsets.
Definition at line 218 of file LibtorchDRLControl.C.
Referenced by execute().
|
protected |
Return the offset to add to a control signal at the current time.
| control_i | Index of the control signal. |
Definition at line 212 of file LibtorchDRLControl.C.
Referenced by applyControlSignals().
|
overridevirtual |
Compute the actions and their corresponding logarithmic probabilities.
Reimplemented from LibtorchNeuralNetControl.
Definition at line 153 of file LibtorchDRLControl.C.
Referenced by SamplerDRLControlTransfer::execute(), and SamplerDRLControlTransfer::executeToMultiapp().
| Real LibtorchDRLControl::getSignalLogProbability | ( | const unsigned int | signal_index | ) | const |
Get the logarithmic probability of (signal_index)-th signal of the control neural net.
| signal_index | The index of the signal |
Definition at line 295 of file LibtorchDRLControl.C.
Referenced by LibtorchDRLLogProbabilityPostprocessor::getValue().
|
overridevirtual |
Restore any restartable controller state after base setup completes.
Reimplemented from LibtorchNeuralNetControl.
Definition at line 105 of file LibtorchDRLControl.C.
|
inline |
Return the number of observation time levels stacked into the actor input.
Definition at line 87 of file LibtorchDRLControl.h.
Referenced by SamplerDRLControlTransfer::getDRLControl().
| void LibtorchDRLControl::loadControlNeuralNet | ( | const Moose::LibtorchActorNeuralNet & | input_nn | ) |
Copy an actor network into this DRL controller.
| input_nn | Actor network to copy into the controller. |
Definition at line 229 of file LibtorchDRLControl.C.
Referenced by SamplerDRLControlTransfer::execute(), SamplerDRLControlTransfer::executeToMultiapp(), and loadControlNeuralNet().
|
overridevirtual |
Reject loading a plain artificial neural network into this actor-based controller.
| input_nn | Artificial neural network passed through the base-class interface. |
Reimplemented from LibtorchNeuralNetControl.
Definition at line 236 of file LibtorchDRLControl.C.
|
overridevirtual |
Load the actor neural network from the configured checkpoint file.
Reimplemented from LibtorchNeuralNetControl.
Definition at line 113 of file LibtorchDRLControl.C.
|
inline |
Return the number of observations read at each time level.
Definition at line 92 of file LibtorchDRLControl.h.
Referenced by SamplerDRLControlTransfer::getDRLControl().
|
inline |
Return the number of time steps between policy evaluations.
Definition at line 82 of file LibtorchDRLControl.h.
Referenced by SamplerDRLControlTransfer::getDRLControl().
|
private |
Restore the owned libtorch generator state from restartable storage.
Definition at line 265 of file LibtorchDRLControl.C.
Referenced by initialSetup().
|
private |
Mirror the owned libtorch generator state into restartable storage.
Definition at line 280 of file LibtorchDRLControl.C.
Referenced by execute(), initialSetup(), LibtorchDRLControl(), and setPolicySampleSeed().
| void LibtorchDRLControl::setPolicySampleSeed | ( | uint64_t | seed | ) |
Reset the owned policy-sampling generator to a known seed.
| seed | Seed assigned to the policy-sampling generator. |
Definition at line 245 of file LibtorchDRLControl.C.
Referenced by SamplerDRLControlTransfer::executeToMultiapp(), and LibtorchDRLControl().
|
private |
Report whether the policy is evaluated at the current time step.
Definition at line 255 of file LibtorchDRLControl.C.
Referenced by execute().
|
static |
Return the input parameters supported by this control.
Definition at line 22 of file LibtorchDRLControl.C.
|
protected |
Actor network used when the controller operates as a stochastic policy.
Definition at line 120 of file LibtorchDRLControl.h.
Referenced by execute(), loadControlNeuralNet(), and loadControlNeuralNetFromFile().
|
protected |
Constant offsets added to each control signal before it is applied.
Definition at line 115 of file LibtorchDRLControl.h.
Referenced by computeControlOffset(), and LibtorchDRLControl().
|
protected |
Exponential smoothing factor in (0, 1] applied to the control signal at each time step.
Definition at line 129 of file LibtorchDRLControl.h.
Referenced by execute().
|
protected |
The log probability of control signals from the last evaluation of the controller.
Definition at line 107 of file LibtorchDRLControl.h.
Referenced by execute(), and getSignalLogProbability().
|
protected |
The current smoothed control signal applied to the controllable parameters.
Definition at line 112 of file LibtorchDRLControl.h.
Referenced by applyControlSignals(), and execute().
|
protected |
Whether any offset data was provided by the user.
Definition at line 117 of file LibtorchDRLControl.h.
Referenced by execute().
|
protected |
Number of time steps between policy evaluations.
Definition at line 127 of file LibtorchDRLControl.h.
Referenced by numStepsInPeriod(), and shouldEvaluatePolicy().
|
protected |
Owned libtorch CPU generator used for policy sampling.
Definition at line 122 of file LibtorchDRLControl.h.
Referenced by execute(), restorePolicyGeneratorState(), savePolicyGeneratorState(), and setPolicySampleSeed().
|
protected |
Restartable serialized state for the owned policy-sampling generator.
Definition at line 124 of file LibtorchDRLControl.h.
Referenced by restorePolicyGeneratorState(), and savePolicyGeneratorState().
|
protected |
The smoothed control signal from the previous execution, saved for restart/recover.
Definition at line 110 of file LibtorchDRLControl.h.
Referenced by execute().
|
protected |
Whether to sample actions stochastically instead of using the deterministic actor output.
Definition at line 131 of file LibtorchDRLControl.h.
Referenced by execute(), restorePolicyGeneratorState(), and savePolicyGeneratorState().