This trainer is responsible for training neural networks that efficiently control different processes. More...
#include <LibtorchDRLControlTrainer.h>
Public Types | |
typedef DataFileName | DataFileParameterType |
Public Member Functions | |
LibtorchDRLControlTrainer (const InputParameters ¶meters) | |
construct using input parameters More... | |
virtual void | execute () override |
Real | averageEpisodeReward () |
Function which returns the current average episodic reward. More... | |
void | trainController () |
The condensed training function. More... | |
const Moose::LibtorchArtificialNeuralNet & | controlNeuralNet () const |
virtual void | initialize () |
virtual void | finalize () |
virtual void | threadJoin (const UserObject &) final |
SubProblem & | getSubProblem () const |
bool | shouldDuplicateInitialExecution () const |
virtual Real | spatialValue (const Point &) const |
virtual const std::vector< Point > | spatialPoints () const |
void | gatherSum (T &value) |
void | gatherMax (T &value) |
void | gatherMin (T &value) |
void | gatherProxyValueMax (T1 &proxy, T2 &value) |
void | gatherProxyValueMin (T1 &proxy, T2 &value) |
void | setPrimaryThreadCopy (UserObject *primary) |
UserObject * | primaryThreadCopy () |
std::set< UserObjectName > | getDependObjects () const |
virtual bool | needThreadedCopy () const |
const std::set< std::string > & | getRequestedItems () override |
const std::set< std::string > & | getSuppliedItems () override |
unsigned int | systemNumber () const |
virtual bool | enabled () const |
std::shared_ptr< MooseObject > | getSharedPtr () |
std::shared_ptr< const MooseObject > | getSharedPtr () const |
MooseApp & | getMooseApp () const |
const std::string & | type () const |
virtual const std::string & | name () const |
std::string | typeAndName () const |
std::string | errorPrefix (const std::string &error_type) const |
void | callMooseError (std::string msg, const bool with_prefix) const |
MooseObjectParameterName | uniqueParameterName (const std::string ¶meter_name) const |
const InputParameters & | parameters () const |
MooseObjectName | uniqueName () 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 &nm) const |
void | paramError (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 |
void | connectControllableParams (const std::string ¶meter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const |
void | mooseError (Args &&... args) const |
void | mooseErrorNonPrefixed (Args &&... args) const |
void | mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const |
void | mooseWarning (Args &&... args) const |
void | mooseWarningNonPrefixed (Args &&... args) const |
void | mooseDeprecated (Args &&... args) const |
void | mooseInfo (Args &&... args) 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 |
virtual void | initialSetup () |
virtual void | timestepSetup () |
virtual void | jacobianSetup () |
virtual void | residualSetup () |
virtual void | customSetup (const ExecFlagType &) |
const ExecFlagEnum & | getExecuteOnEnum () 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 UserObject & | getUserObjectBase (const std::string ¶m_name, bool is_dependency=true) const |
const UserObject & | getUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const |
const std::vector< MooseVariableScalar *> & | getCoupledMooseScalarVars () |
const std::set< TagID > & | getScalarVariableCoupleableVectorTags () const |
const std::set< TagID > & | getScalarVariableCoupleableMatrixTags () const |
const GenericMaterialProperty< T, is_ad > & | getGenericMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0) |
const GenericMaterialProperty< T, is_ad > & | getGenericMaterialProperty (const std::string &name, const unsigned int state=0) |
const GenericMaterialProperty< T, is_ad > & | getGenericMaterialProperty (const std::string &name, const unsigned int state=0) |
const MaterialProperty< T > & | getMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0) |
const MaterialProperty< T > & | getMaterialProperty (const std::string &name, const unsigned int state=0) |
const MaterialProperty< T > & | getMaterialProperty (const std::string &name, const unsigned int state=0) |
const ADMaterialProperty< T > & | getADMaterialProperty (const std::string &name, MaterialData &material_data) |
const ADMaterialProperty< T > & | getADMaterialProperty (const std::string &name) |
const ADMaterialProperty< T > & | getADMaterialProperty (const std::string &name) |
const MaterialProperty< T > & | getMaterialPropertyOld (const std::string &name, MaterialData &material_data) |
const MaterialProperty< T > & | getMaterialPropertyOld (const std::string &name) |
const MaterialProperty< T > & | getMaterialPropertyOld (const std::string &name) |
const MaterialProperty< T > & | getMaterialPropertyOlder (const std::string &name, MaterialData &material_data) |
const MaterialProperty< T > & | getMaterialPropertyOlder (const std::string &name) |
const MaterialProperty< T > & | getMaterialPropertyOlder (const std::string &name) |
const GenericMaterialProperty< T, is_ad > & | getGenericMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state) |
const GenericMaterialProperty< T, is_ad > & | getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0) |
const GenericMaterialProperty< T, is_ad > & | getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0) |
const MaterialProperty< T > & | getMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state=0) |
const MaterialProperty< T > & | getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0) |
const MaterialProperty< T > & | getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0) |
const ADMaterialProperty< T > & | getADMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data) |
const ADMaterialProperty< T > & | getADMaterialPropertyByName (const MaterialPropertyName &name) |
const ADMaterialProperty< T > & | getADMaterialPropertyByName (const MaterialPropertyName &name) |
const MaterialProperty< T > & | getMaterialPropertyOldByName (const MaterialPropertyName &name, MaterialData &material_data) |
const MaterialProperty< T > & | getMaterialPropertyOldByName (const MaterialPropertyName &name) |
const MaterialProperty< T > & | getMaterialPropertyOldByName (const MaterialPropertyName &name) |
const MaterialProperty< T > & | getMaterialPropertyOlderByName (const MaterialPropertyName &name, MaterialData &material_data) |
const MaterialProperty< T > & | getMaterialPropertyOlderByName (const MaterialPropertyName &name) |
const MaterialProperty< T > & | getMaterialPropertyOlderByName (const MaterialPropertyName &name) |
std::pair< const MaterialProperty< T > *, std::set< SubdomainID > > | getBlockMaterialProperty (const MaterialPropertyName &name) |
const GenericMaterialProperty< T, is_ad > & | getGenericZeroMaterialProperty (const std::string &name) |
const GenericMaterialProperty< T, is_ad > & | getGenericZeroMaterialProperty () |
const GenericMaterialProperty< T, is_ad > & | getGenericZeroMaterialPropertyByName (const std::string &prop_name) |
const MaterialProperty< T > & | getZeroMaterialProperty (Ts... args) |
std::set< SubdomainID > | getMaterialPropertyBlocks (const std::string &name) |
std::vector< SubdomainName > | getMaterialPropertyBlockNames (const std::string &name) |
std::set< BoundaryID > | getMaterialPropertyBoundaryIDs (const std::string &name) |
std::vector< BoundaryName > | getMaterialPropertyBoundaryNames (const std::string &name) |
void | checkBlockAndBoundaryCompatibility (std::shared_ptr< MaterialBase > discrete) |
std::unordered_map< SubdomainID, std::vector< MaterialBase *> > | buildRequiredMaterials (bool allow_stateful=true) |
void | statefulPropertiesAllowed (bool) |
bool | getMaterialPropertyCalled () const |
virtual const std::unordered_set< unsigned int > & | getMatPropDependencies () const |
virtual void | resolveOptionalProperties () |
const GenericMaterialProperty< T, is_ad > & | getPossiblyConstantGenericMaterialPropertyByName (const MaterialPropertyName &prop_name, MaterialData &material_data, const unsigned int state) |
bool | isImplicit () |
Moose::StateArg | determineState () const |
virtual void | subdomainSetup () override |
virtual void | subdomainSetup () override |
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 |
const GenericOptionalMaterialProperty< T, is_ad > & | getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0) |
const GenericOptionalMaterialProperty< T, is_ad > & | getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0) |
const OptionalMaterialProperty< T > & | getOptionalMaterialProperty (const std::string &name, const unsigned int state=0) |
const OptionalMaterialProperty< T > & | getOptionalMaterialProperty (const std::string &name, const unsigned int state=0) |
const OptionalADMaterialProperty< T > & | getOptionalADMaterialProperty (const std::string &name) |
const OptionalADMaterialProperty< T > & | getOptionalADMaterialProperty (const std::string &name) |
const OptionalMaterialProperty< T > & | getOptionalMaterialPropertyOld (const std::string &name) |
const OptionalMaterialProperty< T > & | getOptionalMaterialPropertyOld (const std::string &name) |
const OptionalMaterialProperty< T > & | getOptionalMaterialPropertyOlder (const std::string &name) |
const OptionalMaterialProperty< T > & | getOptionalMaterialPropertyOlder (const std::string &name) |
MaterialBase & | getMaterial (const std::string &name) |
MaterialBase & | getMaterial (const std::string &name) |
MaterialBase & | getMaterialByName (const std::string &name, bool no_warn=false) |
MaterialBase & | getMaterialByName (const std::string &name, bool no_warn=false) |
bool | hasMaterialProperty (const std::string &name) |
bool | hasMaterialProperty (const std::string &name) |
bool | hasMaterialPropertyByName (const std::string &name) |
bool | hasMaterialPropertyByName (const std::string &name) |
bool | hasADMaterialProperty (const std::string &name) |
bool | hasADMaterialProperty (const std::string &name) |
bool | hasADMaterialPropertyByName (const std::string &name) |
bool | hasADMaterialPropertyByName (const std::string &name) |
bool | hasGenericMaterialProperty (const std::string &name) |
bool | hasGenericMaterialProperty (const std::string &name) |
bool | hasGenericMaterialPropertyByName (const std::string &name) |
bool | hasGenericMaterialPropertyByName (const std::string &name) |
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 |
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 |
T & | getSampler (const std::string &name) |
Sampler & | getSampler (const std::string &name) |
T & | getSamplerByName (const SamplerName &name) |
Sampler & | getSamplerByName (const SamplerName &name) |
virtual void | meshChanged () |
virtual void | meshDisplaced () |
PerfGraph & | perfGraph () |
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 Distribution & | getDistribution (const std::string &name) const |
const T & | getDistribution (const std::string &name) const |
const Distribution & | getDistribution (const std::string &name) const |
const T & | getDistribution (const std::string &name) const |
const Distribution & | getDistributionByName (const DistributionName &name) const |
const T & | getDistributionByName (const std::string &name) const |
const Distribution & | getDistributionByName (const DistributionName &name) const |
const T & | getDistributionByName (const std::string &name) const |
const Parallel::Communicator & | comm () const |
processor_id_type | n_processors () const |
processor_id_type | processor_id () const |
const std::string & | modelMetaDataName () const |
Accessor for the name of the model meta data. More... | |
const FileName & | getModelDataFileName () const |
Get the associated filename. More... | |
bool | hasModelData () const |
Check if we need to load model data (if the filename parameter is used) More... | |
template<typename T , typename... Args> | |
T & | declareModelData (const std::string &data_name, Args &&... args) |
Declare model data for loading from file as well as restart. More... | |
template<typename T , typename... Args> | |
const T & | getModelData (const std::string &data_name, Args &&... args) const |
Retrieve model data from the interface. More... | |
Static Public Member Functions | |
static InputParameters | validParams () |
static void | sort (typename std::vector< T > &vector) |
static void | sortDFS (typename std::vector< T > &vector) |
static void | cyclicDependencyError (CyclicDependencyException< T2 > &e, const std::string &header) |
Public Attributes | |
const ConsoleStream | _console |
Static Public Attributes | |
static constexpr PropertyValue::id_type | default_property_id |
static constexpr PropertyValue::id_type | zero_property_id |
static constexpr auto | SYSTEM |
static constexpr auto | NAME |
Protected Member Functions | |
void | computeAverageEpisodeReward () |
Compute the average eposiodic reward. More... | |
void | convertDataToTensor (std::vector< std::vector< Real >> &vector_data, torch::Tensor &tensor_data, const bool detach=false) |
Function to convert input/output data from std::vector<std::vector> to torch::tensor. More... | |
torch::Tensor | evaluateValue (torch::Tensor &input) |
Function which evaluates the critic to get the value (discounter reward) More... | |
torch::Tensor | evaluateAction (torch::Tensor &input, torch::Tensor &output) |
Function which evaluates the control net and then computes the logarithmic probability of the action. More... | |
void | computeRewardToGo () |
Compute the return value by discounting the rewards and summing them. More... | |
void | resetData () |
Reset data after updating the neural network. More... | |
virtual void | addPostprocessorDependencyHelper (const PostprocessorName &name) const override |
virtual void | addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &name) const override |
virtual void | addUserObjectDependencyHelper (const UserObject &uo) const override |
void | addReporterDependencyHelper (const ReporterName &reporter_name) override |
const ReporterName & | getReporterName (const std::string ¶m_name) 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 |
const T & | getMeshProperty (const std::string &data_name, const std::string &prefix) |
const T & | getMeshProperty (const std::string &data_name) |
bool | hasMeshProperty (const std::string &data_name, const std::string &prefix) const |
bool | hasMeshProperty (const std::string &data_name, const std::string &prefix) const |
bool | hasMeshProperty (const std::string &data_name) const |
bool | hasMeshProperty (const std::string &data_name) const |
std::string | meshPropertyName (const std::string &data_name) 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 |
bool | isCoupledScalar (const std::string &var_name, unsigned int i=0) const |
unsigned int | coupledScalarComponents (const std::string &var_name) const |
unsigned int | coupledScalar (const std::string &var_name, unsigned int comp=0) const |
libMesh::Order | coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarValue (const std::string &var_name, unsigned int comp=0) const |
const ADVariableValue & | adCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const |
const GenericVariableValue< is_ad > & | coupledGenericScalarValue (const std::string &var_name, unsigned int comp=0) const |
const GenericVariableValue< false > & | coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const |
const GenericVariableValue< true > & | coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const |
const VariableValue & | coupledVectorTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const |
const VariableValue & | coupledMatrixTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const |
const VariableValue & | coupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarDot (const std::string &var_name, unsigned int comp=0) const |
const ADVariableValue & | adCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const |
const VariableValue & | coupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const |
const MooseVariableScalar * | getScalarVar (const std::string &var_name, unsigned int comp) const |
virtual void | checkMaterialProperty (const std::string &name, const unsigned int state) |
void | markMatPropRequested (const std::string &) |
MaterialPropertyName | getMaterialPropertyName (const std::string &name) const |
void | checkExecutionStage () |
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 |
const GenericMaterialProperty< T, is_ad > * | defaultGenericMaterialProperty (const std::string &name) |
const GenericMaterialProperty< T, is_ad > * | defaultGenericMaterialProperty (const std::string &name) |
const MaterialProperty< T > * | defaultMaterialProperty (const std::string &name) |
const MaterialProperty< T > * | defaultMaterialProperty (const std::string &name) |
const ADMaterialProperty< T > * | defaultADMaterialProperty (const std::string &name) |
const ADMaterialProperty< T > * | defaultADMaterialProperty (const std::string &name) |
Static Protected Member Functions | |
static std::string | meshPropertyName (const std::string &data_name, const std::string &prefix) |
Protected Attributes | |
const std::vector< ReporterName > | _response_names |
Response reporter names. More... | |
std::vector< const std::vector< Real > * > | _response_value_pointers |
Pointers to the current values of the responses. More... | |
const std::vector< Real > | _response_shift_factors |
Shifting constants for the responses. More... | |
const std::vector< Real > | _response_scaling_factors |
Scaling constants for the responses. More... | |
const std::vector< ReporterName > | _control_names |
Control reporter names. More... | |
std::vector< const std::vector< Real > * > | _control_value_pointers |
Pointers to the current values of the control signals. More... | |
const std::vector< ReporterName > | _log_probability_names |
Log probability reporter names. More... | |
std::vector< const std::vector< Real > * > | _log_probability_value_pointers |
Pointers to the current values of the control log probabilities. More... | |
const ReporterName | _reward_name |
Reward reporter name. More... | |
const std::vector< Real > * | _reward_value_pointer |
Pointer to the current values of the reward. More... | |
const unsigned int | _input_timesteps |
Number of timesteps to fetch from the reporters to be the input of then eural nets. More... | |
unsigned int | _num_inputs |
Number of inputs for the control and critic neural nets. More... | |
unsigned int | _num_outputs |
Number of outputs for the control neural network. More... | |
const unsigned int | _num_epochs |
Number of epochs for the training of the emulator. More... | |
const std::vector< unsigned int > | _num_critic_neurons_per_layer |
Number of neurons within the hidden layers in the critic neural net. More... | |
const Real | _critic_learning_rate |
The learning rate for the optimization algorithm for the critic. More... | |
const std::vector< unsigned int > | _num_control_neurons_per_layer |
Number of neurons within the hidden layers in the control neural net. More... | |
const Real | _control_learning_rate |
The learning rate for the optimization algorithm for the control. More... | |
const unsigned int | _update_frequency |
Number of transients to run and collect data from before updating the controller neural net. More... | |
const Real | _clip_param |
The clip parameter used while clamping the advantage value. More... | |
const Real | _decay_factor |
Decaying factor that is used when calculating the return from the reward. More... | |
const std::vector< Real > | _action_std |
Standard deviation for the actions. More... | |
const std::string | _filename_base |
Name of the pytorch output file. More... | |
const bool | _read_from_file |
Switch indicating if an already existing neural net should be read from a file or not. More... | |
const bool | _shift_outputs |
Currently, the controls are executed after the user objects at initial in moose. More... | |
Real | _average_episode_reward |
Storage for the current average episode reward. More... | |
const bool | _standardize_advantage |
Switch to enable the standardization of the advantages. More... | |
const unsigned int | _loss_print_frequency |
The frequency the loss should be printed. More... | |
std::shared_ptr< Moose::LibtorchArtificialNeuralNet > | _control_nn |
Pointer to the control (or actor) neural net object. More... | |
std::shared_ptr< Moose::LibtorchArtificialNeuralNet > | _critic_nn |
Pointer to the critic neural net object. More... | |
torch::Tensor | _std |
standard deviation in a tensor format for sampling the actual control value More... | |
torch::Tensor | _input_tensor |
Torch::tensor version of the input and action data. More... | |
torch::Tensor | _output_tensor |
torch::Tensor | _return_tensor |
torch::Tensor | _log_probability_tensor |
SubProblem & | _subproblem |
FEProblemBase & | _fe_problem |
SystemBase & | _sys |
const THREAD_ID | _tid |
Assembly & | _assembly |
const Moose::CoordinateSystemType & | _coord_sys |
const bool | _duplicate_initial_execution |
std::set< std::string > | _depend_uo |
const bool & | _enabled |
MooseApp & | _app |
const std::string | _type |
const std::string | _name |
const InputParameters & | _pars |
Factory & | _factory |
ActionFactory & | _action_factory |
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 |
FEProblemBase & | _mci_feproblem |
FEProblemBase & | _mdi_feproblem |
MooseApp & | _pg_moose_app |
const std::string | _prefix |
FEProblemBase & | _sc_fe_problem |
const THREAD_ID | _sc_tid |
const Real & | _real_zero |
const VariableValue & | _scalar_zero |
const Point & | _point_zero |
const InputParameters & | _mi_params |
const std::string | _mi_name |
const MooseObjectName | _mi_moose_object_name |
FEProblemBase & | _mi_feproblem |
SubProblem & | _mi_subproblem |
const THREAD_ID | _mi_tid |
const Moose::MaterialDataType | _material_data_type |
MaterialData & | _material_data |
bool | _stateful_allowed |
bool | _get_material_property_called |
std::vector< std::unique_ptr< PropertyValue > > | _default_properties |
std::unordered_set< unsigned int > | _material_property_dependencies |
const MaterialPropertyName | _get_suffix |
const bool | _use_interpolated_state |
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 Parallel::Communicator & | _communicator |
std::vector< std::vector< Real > > | _input_data |
std::vector< std::vector< Real > > | _output_data |
std::vector< std::vector< Real > > | _log_probability_data |
std::vector< Real > | _reward_data |
std::vector< Real > | _return_data |
Static Protected Attributes | |
static const std::string | _interpolated_old |
static const std::string | _interpolated_older |
Private Member Functions | |
void | getInputDataFromReporter (std::vector< std::vector< Real >> &data, const std::vector< const std::vector< Real > *> &reporter_links, const unsigned int num_timesteps) |
Extract the response values from the postprocessors of the controlled system. More... | |
void | getOutputDataFromReporter (std::vector< std::vector< Real >> &data, const std::vector< const std::vector< Real > *> &reporter_links) |
Extract the output (actions, logarithmic probabilities) values from the postprocessors of the controlled system. More... | |
void | getRewardDataFromReporter (std::vector< Real > &data, const std::vector< Real > *const reporter_link) |
Extract the reward values from the postprocessors of the controlled system This assumes that they are stored in an AccumulateReporter. More... | |
void | getReporterPointers (const std::vector< ReporterName > &reporter_names, std::vector< const std::vector< Real > *> &pointer_storage) |
Getting reporter pointers with given names. More... | |
Private Attributes | |
unsigned int | _update_counter |
Counter for number of transient simulations that have been run before updating the controller. More... | |
This trainer is responsible for training neural networks that efficiently control different processes.
It utilizes the Proximal Policy Optimization algorithms. For more information on the algorithm, see the following resources: Schulman, John, et al. "Proximal policy optimization algorithms." arXiv preprint arXiv:1707.06347 (2017). https://medium.com/analytics-vidhya/coding-ppo-from-scratch-with-pytorch-part-1-4-613dfc1b14c8 https://stable-baselines.readthedocs.io/en/master/modules/ppo2.html
Definition at line 28 of file LibtorchDRLControlTrainer.h.
LibtorchDRLControlTrainer::LibtorchDRLControlTrainer | ( | const InputParameters & | parameters | ) |
construct using input parameters
Definition at line 128 of file LibtorchDRLControlTrainer.C.
|
inline |
Function which returns the current average episodic reward.
It is only updated at the end of every episode.
Definition at line 42 of file LibtorchDRLControlTrainer.h.
Referenced by DRLRewardReporter::execute().
|
protected |
Compute the average eposiodic reward.
Definition at line 278 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
protected |
Compute the return value by discounting the rewards and summing them.
Definition at line 288 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
inline |
Definition at line 47 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchNeuralNetControlTransfer::execute().
|
protected |
Function to convert input/output data from std::vector<std::vector> to torch::tensor.
vector_data | The input data in vector-vectors format |
tensor_data | The tensor where we would like to save the results |
detach | If the gradient info needs to be detached from the tensor |
Definition at line 373 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
inherited |
Declare model data for loading from file as well as restart.
Definition at line 78 of file RestartableModelInterface.h.
|
protected |
Function which evaluates the control net and then computes the logarithmic probability of the action.
input | The observation values (responses) |
output | The actions corresponding to the observations |
Definition at line 399 of file LibtorchDRLControlTrainer.C.
Referenced by trainController().
|
protected |
Function which evaluates the critic to get the value (discounter reward)
input | The observation values (responses) |
Definition at line 393 of file LibtorchDRLControlTrainer.C.
Referenced by trainController().
|
overridevirtual |
Implements GeneralUserObject.
Definition at line 242 of file LibtorchDRLControlTrainer.C.
|
inlinevirtualinherited |
Implements GeneralUserObject.
Reimplemented in SurrogateTrainer, and PODReducedBasisTrainer.
Definition at line 39 of file SurrogateTrainer.h.
|
private |
Extract the response values from the postprocessors of the controlled system.
This assumes that they are stored in an AccumulateReporter
data | The data where we would like to store the response values |
reporter_names | The names of the reporters which need to be extracted |
num_timesteps | The number of timesteps we want to use for training |
Definition at line 426 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
inherited |
Retrieve model data from the interface.
Definition at line 85 of file RestartableModelInterface.h.
|
inherited |
Get the associated filename.
Definition at line 33 of file RestartableModelInterface.C.
|
private |
Extract the output (actions, logarithmic probabilities) values from the postprocessors of the controlled system.
This assumes that they are stored in an AccumulateReporter
data | The data where we would like to store the output values |
reporter_names | The names of the reporters which need to be extracted |
Definition at line 459 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
private |
Getting reporter pointers with given names.
Definition at line 479 of file LibtorchDRLControlTrainer.C.
Referenced by LibtorchDRLControlTrainer().
|
private |
Extract the reward values from the postprocessors of the controlled system This assumes that they are stored in an AccumulateReporter.
data | The data where we would like to store the reward values |
reporter_names | The name of the reporter which need to be extracted |
Definition at line 471 of file LibtorchDRLControlTrainer.C.
Referenced by computeRewardToGo(), and execute().
|
inherited |
Check if we need to load model data (if the filename parameter is used)
Definition at line 39 of file RestartableModelInterface.C.
|
inlinevirtualinherited |
Implements GeneralUserObject.
Reimplemented in SurrogateTrainer, ActiveLearningGaussianProcess, and PODReducedBasisTrainer.
Definition at line 38 of file SurrogateTrainer.h.
|
inlineinherited |
Accessor for the name of the model meta data.
Definition at line 47 of file RestartableModelInterface.h.
Referenced by SurrogateTrainerOutput::output(), and MappingOutput::output().
|
protected |
Reset data after updating the neural network.
Definition at line 410 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
inlinefinalvirtualinherited |
Reimplemented from GeneralUserObject.
Definition at line 40 of file SurrogateTrainer.h.
void LibtorchDRLControlTrainer::trainController | ( | ) |
The condensed training function.
Definition at line 312 of file LibtorchDRLControlTrainer.C.
Referenced by execute().
|
static |
Definition at line 22 of file LibtorchDRLControlTrainer.C.
|
protected |
Standard deviation for the actions.
Definition at line 161 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Storage for the current average episode reward.
Definition at line 178 of file LibtorchDRLControlTrainer.h.
Referenced by averageEpisodeReward(), and computeAverageEpisodeReward().
|
protected |
The clip parameter used while clamping the advantage value.
Definition at line 155 of file LibtorchDRLControlTrainer.h.
Referenced by trainController().
|
protected |
The learning rate for the optimization algorithm for the control.
Definition at line 149 of file LibtorchDRLControlTrainer.h.
Referenced by trainController().
|
protected |
Control reporter names.
Definition at line 98 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Pointer to the control (or actor) neural net object.
Definition at line 187 of file LibtorchDRLControlTrainer.h.
Referenced by controlNeuralNet(), evaluateAction(), LibtorchDRLControlTrainer(), and trainController().
|
protected |
Pointers to the current values of the control signals.
Definition at line 101 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and LibtorchDRLControlTrainer().
|
protected |
The learning rate for the optimization algorithm for the critic.
Definition at line 143 of file LibtorchDRLControlTrainer.h.
Referenced by trainController().
|
protected |
Pointer to the critic neural net object.
Definition at line 189 of file LibtorchDRLControlTrainer.h.
Referenced by evaluateValue(), LibtorchDRLControlTrainer(), and trainController().
|
protected |
Decaying factor that is used when calculating the return from the reward.
Definition at line 158 of file LibtorchDRLControlTrainer.h.
Referenced by computeRewardToGo().
|
protected |
Name of the pytorch output file.
This is used for loading and storing already existing data
Definition at line 165 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
The gathered data from the reporters, each row represents one QoI, each column represents one time step
Definition at line 125 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and resetData().
|
protected |
Torch::tensor version of the input and action data.
Definition at line 195 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and trainController().
|
protected |
Number of timesteps to fetch from the reporters to be the input of then eural nets.
Definition at line 116 of file LibtorchDRLControlTrainer.h.
Referenced by execute().
|
protected |
Definition at line 127 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and resetData().
|
protected |
Log probability reporter names.
Definition at line 104 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Definition at line 198 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and trainController().
|
protected |
Pointers to the current values of the control log probabilities.
Definition at line 107 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and LibtorchDRLControlTrainer().
|
protected |
The frequency the loss should be printed.
Definition at line 184 of file LibtorchDRLControlTrainer.h.
Referenced by trainController().
|
protected |
Number of neurons within the hidden layers in the control neural net.
Definition at line 146 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Number of neurons within the hidden layers in the critic neural net.
Definition at line 140 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Number of epochs for the training of the emulator.
Definition at line 137 of file LibtorchDRLControlTrainer.h.
Referenced by trainController().
|
protected |
Number of inputs for the control and critic neural nets.
Definition at line 119 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Number of outputs for the control neural network.
Definition at line 121 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Definition at line 126 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and resetData().
|
protected |
Definition at line 196 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and trainController().
|
protected |
Switch indicating if an already existing neural net should be read from a file or not.
This can be used to load existing torch files (from previous MOOSE runs for retraining and further manipulation)
Definition at line 170 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Response reporter names.
Definition at line 86 of file LibtorchDRLControlTrainer.h.
Referenced by LibtorchDRLControlTrainer().
|
protected |
Scaling constants for the responses.
Definition at line 95 of file LibtorchDRLControlTrainer.h.
Referenced by getInputDataFromReporter(), and LibtorchDRLControlTrainer().
|
protected |
Shifting constants for the responses.
Definition at line 92 of file LibtorchDRLControlTrainer.h.
Referenced by getInputDataFromReporter(), and LibtorchDRLControlTrainer().
|
protected |
Pointers to the current values of the responses.
Definition at line 89 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and LibtorchDRLControlTrainer().
|
protected |
Definition at line 133 of file LibtorchDRLControlTrainer.h.
Referenced by computeRewardToGo(), execute(), and resetData().
|
protected |
Definition at line 197 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and trainController().
|
protected |
The reward and return data. The return is calculated using the _reward_data
Definition at line 132 of file LibtorchDRLControlTrainer.h.
Referenced by computeAverageEpisodeReward(), execute(), and resetData().
|
protected |
Reward reporter name.
Definition at line 110 of file LibtorchDRLControlTrainer.h.
|
protected |
Pointer to the current values of the reward.
Definition at line 113 of file LibtorchDRLControlTrainer.h.
Referenced by computeRewardToGo(), and execute().
|
protected |
Currently, the controls are executed after the user objects at initial in moose.
So using a shift can realign the corresponding input-output values while reading the reporters
Definition at line 175 of file LibtorchDRLControlTrainer.h.
Referenced by getInputDataFromReporter(), getOutputDataFromReporter(), and getRewardDataFromReporter().
|
protected |
Switch to enable the standardization of the advantages.
Definition at line 181 of file LibtorchDRLControlTrainer.h.
Referenced by trainController().
|
protected |
standard deviation in a tensor format for sampling the actual control value
Definition at line 192 of file LibtorchDRLControlTrainer.h.
Referenced by evaluateAction(), and LibtorchDRLControlTrainer().
|
private |
Counter for number of transient simulations that have been run before updating the controller.
Definition at line 234 of file LibtorchDRLControlTrainer.h.
Referenced by execute(), and resetData().
|
protected |
Number of transients to run and collect data from before updating the controller neural net.
Definition at line 152 of file LibtorchDRLControlTrainer.h.
Referenced by resetData().