https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SamplerDRLControlTransfer Class Reference

Transfers a trained DRL controller from a trainer to controls on sampler subapps. More...

#include <SamplerDRLControlTransfer.h>

Inheritance diagram for SamplerDRLControlTransfer:
[legend]

Public Types

enum  DIRECTION
 
typedef DataFileName DataFileParameterType
 

Public Member Functions

 SamplerDRLControlTransfer (const InputParameters &parameters)
 Build the transfer that pushes a trained controller into subapps.
 
virtual void execute () override
 Execute the transfer in the standard non-batch path.
 
virtual void initialSetup () override
 Prepare the transfer for batch-mode execution.
 
virtual void initializeFromMultiapp () override
 Initialize a batch transfer from the multiapp.
 
virtual void executeFromMultiapp () override
 Execute a batch transfer from the multiapp.
 
virtual void finalizeFromMultiapp () override
 Finalize a batch transfer from the multiapp.
 
virtual void initializeToMultiapp () override
 Initialize a batch transfer to the multiapp.
 
virtual void executeToMultiapp () override
 Execute a batch transfer to the multiapp.
 
virtual void finalizeToMultiapp () override
 Finalize a batch transfer to the multiapp.
 
void setGlobalMultiAppIndex (dof_id_type index)
 Method for setting the app index when running in batch mode.
 
void setGlobalRowIndex (dof_id_type row)
 Method for keeping track of the global row index when running in batch mode.
 
void setCurrentRow (const std::vector< Real > &row)
 Method for keeping track of the row data when running in batch mode.
 
void variableIntegrityCheck (const AuxVariableName &var_name, bool is_from_multiapp) const
 
const std::shared_ptr< MultiApp > getMultiApp () const
 
const std::shared_ptr< MultiApp > getFromMultiApp () const
 
const std::shared_ptr< MultiApp > getToMultiApp () const
 
std::string getFromName () const
 
std::string getToName () const
 
bool hasFromMultiApp () const
 
bool hasToMultiApp () const
 
virtual void getAppInfo ()
 
const MultiMooseEnum & directions ()
 
void setCurrentDirection (const int direction)
 
bool executeAfterSiblingSourceApp () const
 
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 &parameter_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 &param1, const std::string &param2) 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 &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, 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 &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnum & getExecuteOnEnum () const
 
PerfGraph & perfGraph ()
 
MooseEnum direction ()
 
MooseEnum direction ()
 
MooseEnum currentDirection ()
 
MooseEnum currentDirection ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
template<>
SurrogateModel & getSurrogateModel (const std::string &name) const
 
template<>
SurrogateTrainerBase & getSurrogateTrainer (const std::string &name) const
 
template<>
SurrogateModel & getSurrogateModelByName (const UserObjectName &name) const
 
template<>
SurrogateTrainerBase & getSurrogateTrainerByName (const UserObjectName &name) const
 
template<typename T = SurrogateModel>
T & getSurrogateModel (const std::string &name) const
 Get a SurrogateModel/Trainer with a given name.
 
template<typename T = SurrogateTrainerBase>
T & getSurrogateTrainer (const std::string &name) const
 
template<typename T = SurrogateModel>
T & getSurrogateModelByName (const UserObjectName &name) const
 Get a sampler with a given name.
 
template<typename T = SurrogateTrainerBase>
T & getSurrogateTrainerByName (const UserObjectName &name) const
 

Static Public Member Functions

static InputParameters validParams ()
 Return the input parameters supported by this transfer.
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static void addSkipCoordCollapsingParam (InputParameters &params)
 
static libMesh::System * find_sys (libMesh::EquationSystems &es, const std::string &var_name)
 
static std::string possibleDirections ()
 

Public Attributes

 TO_MULTIAPP
 
 FROM_MULTIAPP
 
 BETWEEN_MULTIAPP
 
 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const libMesh::Number OutOfMeshValue
 
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

LibtorchDRLControl & getDRLControl (unsigned int app_index)
 Find the DRL control on a local subapp and check that its control period, observation history length, number of observations, and number of control signals match the trainer's.
 
std::vector< unsigned int > getFromsPerProc ()
 
libMesh::NumericVector< Real > & getTransferVector (unsigned int i_local, std::string var_name)
 
unsigned int getGlobalSourceAppIndex (unsigned int i_from) const
 
unsigned int getGlobalTargetAppIndex (unsigned int i_to) const
 
unsigned int getLocalSourceAppIndex (unsigned int i_from) const
 
virtual void checkSiblingsTransferSupported () const
 
void checkParentAppUserObjectExecuteOn (const std::string &object_name) const
 
void errorIfObjectExecutesOnTransferInSourceApp (const std::string &object_name) const
 
Point getPointInTargetAppFrame (const Point &p, unsigned int local_i_to, const std::string &phase) const
 
Point getPointInSourceAppFrame (const Point &p, unsigned int local_i_from, const std::string &phase) const
 
void checkMultiAppExecuteOn ()
 
void checkVariable (const FEProblemBase &fe_problem, const VariableName &var_name, const std::string &param_name="") const
 
void extendBoundingBoxes (const Real factor, std::vector< libMesh::BoundingBox > &bboxes) const
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) 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
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
std::vector< libMesh::BoundingBox > getFromBoundingBoxes ()
 
std::vector< libMesh::BoundingBox > getFromBoundingBoxes (BoundaryID boundary_id)
 
std::vector< libMesh::BoundingBox > getFromBoundingBoxes ()
 
std::vector< libMesh::BoundingBox > getFromBoundingBoxes (BoundaryID boundary_id)
 

Static Protected Member Functions

static void addUserObjectExecutionCheckParam (InputParameters &params)
 
static void addBBoxFactorParam (InputParameters &params)
 
static void transformBoundingBox (libMesh::BoundingBox &box, const MultiAppCoordTransform &transform)
 

Protected Attributes

const std::string _control_name
 The name of the control object on the other app where we want to copy our neural net.
 
const LibtorchDRLControlTrainer & _trainer
 The trainer object which will contains the control neural net.
 
dof_id_type _app_index = 0
 Index for the sub-app that the batch-mode multiapp is working on.
 
dof_id_type _global_index = 0
 Index for tracking the row index when using batch mode operation.
 
std::vector< Real > _row_data
 The current row of data (comes from multiapp)
 
Sampler * _sampler_ptr
 Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
 
std::shared_ptr< MultiApp > _multi_app
 
std::vector< FEProblemBase * > _to_problems
 
std::vector< FEProblemBase * > _from_problems
 
std::vector< libMesh::EquationSystems * > _to_es
 
std::vector< libMesh::EquationSystems * > _from_es
 
std::vector< MooseMesh * > _to_meshes
 
std::vector< MooseMesh * > _from_meshes
 
std::vector< Point > _to_positions
 
std::vector< Point > _from_positions
 
std::vector< std::unique_ptr< MultiAppCoordTransform > > _to_transforms
 
std::vector< std::unique_ptr< MultiAppCoordTransform > > _from_transforms
 
const bool _skip_coordinate_collapsing
 
bool _displaced_source_mesh
 
bool _displaced_target_mesh
 
Real _bbox_factor
 
std::vector< unsigned int > _to_local2global_map
 
std::vector< unsigned int > _from_local2global_map
 
SubProblem & _subproblem
 
FEProblemBase & _fe_problem
 
SystemBase & _sys
 
THREAD_ID _tid
 
MultiMooseEnum _directions
 
const bool _exec_after_source_app_exec
 
const bool & _enabled
 
MooseApp & _app
 
Factory & _factory
 
ActionFactory & _action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters & _pars
 
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
 
MooseApp & _pg_moose_app
 
const std::string _prefix
 
MooseEnum _direction
 
MooseEnum _current_direction
 
const Parallel::Communicator & _communicator
 

Private Member Functions

virtual bool usesMooseAppCoordTransform () const
 
Point mapBackWithoutCollapsing (MultiAppCoordTransform &transform, const Point &p, const std::string &phase) const
 
void getFromMultiAppInfo ()
 
void getToMultiAppInfo ()
 
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
 
T & getSampler (const std::string &name)
 
Sampler & getSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
Sampler & getSamplerByName (const SamplerName &name)
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

std::shared_ptr< MultiApp > _from_multi_app
 
std::shared_ptr< MultiApp > _to_multi_app
 
std::unique_ptr< MooseAppCoordTransform > _from_moose_app_transform
 
std::unique_ptr< MooseAppCoordTransform > _to_moose_app_transform
 
const ParallelParamObject & _parent
 
const MooseBase & _si_moose_base
 
const FEProblemBase * _si_problem
 
ExecFlagEnum _empty_execute_enum
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 
const InputParameters & _si_params
 
FEProblemBase & _si_feproblem
 
THREAD_ID _si_tid
 
const InputParameters & _smi_params
 Parameters of the object with this interface.
 
FEProblemBase & _smi_feproblem
 Reference to FEProblemBase instance.
 
const THREAD_ID _smi_tid
 Thread ID.
 

Detailed Description

Transfers a trained DRL controller from a trainer to controls on sampler subapps.

Definition at line 25 of file SamplerDRLControlTransfer.h.

Constructor & Destructor Documentation

◆ SamplerDRLControlTransfer()

SamplerDRLControlTransfer::SamplerDRLControlTransfer ( const InputParameters &  parameters)

Build the transfer that pushes a trained controller into subapps.

Parameters
parametersInput parameters for the transfer.

Definition at line 37 of file SamplerDRLControlTransfer.C.

40 _control_name(getParam<std::string>("control_name")),
41 _trainer(getSurrogateTrainerByName<LibtorchDRLControlTrainer>(
42 getParam<UserObjectName>("trainer_name")))
43{
44}
const InputParameters & parameters() const
const LibtorchDRLControlTrainer & _trainer
The trainer object which will contains the control neural net.
const std::string _control_name
The name of the control object on the other app where we want to copy our neural net.
The class creates an additional API to allow Transfers to work when running the StochasticTools<FullS...
Interface for objects that need to use samplers.

Member Function Documentation

◆ execute()

void SamplerDRLControlTransfer::execute ( )
overridevirtual

Execute the transfer in the standard non-batch path.

Implements MultiAppTransfer.

Definition at line 52 of file SamplerDRLControlTransfer.C.

53{
54 const auto n = getToMultiApp()->numGlobalApps();
55 for (MooseIndex(n) i = 0; i < n; i++)
56 {
57 if (getToMultiApp()->hasLocalApp(i))
58 {
59 // Get the control neural net from the trainer
61
62 LibtorchDRLControl & control_object = getDRLControl(i);
63
64 // Copy and the neural net and execute it to get the initial values
65 control_object.loadControlNeuralNet(trainer_nn);
66 control_object.execute();
67 }
68 }
69}
const Moose::LibtorchActorNeuralNet & controlNeuralNet() const
Return the current actor network.
A time-dependent, neural-network-based controller which is associated with a Proximal Policy Optimiza...
virtual void execute() override
Compute the actions and their corresponding logarithmic probabilities.
void loadControlNeuralNet(const Moose::LibtorchActorNeuralNet &input_nn)
Copy an actor network into this DRL controller.
Feed-forward actor network coupled to a Gaussian or Beta action distribution.
const std::shared_ptr< MultiApp > getToMultiApp() const
LibtorchDRLControl & getDRLControl(unsigned int app_index)
Find the DRL control on a local subapp and check that its control period, observation history length,...

◆ executeFromMultiapp()

void SamplerDRLControlTransfer::executeFromMultiapp ( )
overridevirtual

Execute a batch transfer from the multiapp.

Reimplemented from StochasticToolsTransfer.

Definition at line 77 of file SamplerDRLControlTransfer.C.

78{
79}

◆ executeToMultiapp()

void SamplerDRLControlTransfer::executeToMultiapp ( )
overridevirtual

Execute a batch transfer to the multiapp.

Reimplemented from StochasticToolsTransfer.

Definition at line 92 of file SamplerDRLControlTransfer.C.

93{
94 if (getToMultiApp()->hasLocalApp(_app_index))
95 {
96 // Use a rank-invariant seed based on the configured trainer seed, the current main-app
97 // training step, and the sampler row being executed. This keeps the stochastic rollout path
98 // tied to the actual sample instead of the transient local app slot chosen by batch-reset.
99 const uint64_t sample_seed = static_cast<uint64_t>(_trainer.seed()) +
100 static_cast<uint64_t>(_global_index) +
101 static_cast<uint64_t>(_sampler_ptr->getNumberOfRows()) *
102 static_cast<uint64_t>(_fe_problem.timeStep());
103 // Get the control neural net from the trainer
105
106 LibtorchDRLControl & control_object = getDRLControl(_app_index);
107
108 // Copy and the neural net and execute it to get the initial values
109 control_object.loadControlNeuralNet(trainer_nn);
110 control_object.setPolicySampleSeed(sample_seed);
111 control_object.execute();
112 }
113}
virtual int & timeStep() const
unsigned int seed() const
Return the trainer seed used for sampling and shuffling.
void setPolicySampleSeed(uint64_t seed)
Reset the owned policy-sampling generator to a known seed.
dof_id_type getNumberOfRows() const
dof_id_type _global_index
Index for tracking the row index when using batch mode operation.
dof_id_type _app_index
Index for the sub-app that the batch-mode multiapp is working on.
Sampler * _sampler_ptr
Pointer to the Sampler object used by the SamplerTransientMultiApp or SamplerFullSolveMultiApp.
FEProblemBase & _fe_problem

◆ finalizeFromMultiapp()

void SamplerDRLControlTransfer::finalizeFromMultiapp ( )
overridevirtual

Finalize a batch transfer from the multiapp.

Reimplemented from StochasticToolsTransfer.

Definition at line 82 of file SamplerDRLControlTransfer.C.

83{
84}

◆ finalizeToMultiapp()

void SamplerDRLControlTransfer::finalizeToMultiapp ( )
overridevirtual

Finalize a batch transfer to the multiapp.

Reimplemented from StochasticToolsTransfer.

Definition at line 189 of file SamplerDRLControlTransfer.C.

190{
191}

◆ getDRLControl()

LibtorchDRLControl & SamplerDRLControlTransfer::getDRLControl ( unsigned int  app_index)
protected

Find the DRL control on a local subapp and check that its control period, observation history length, number of observations, and number of control signals match the trainer's.

Parameters
app_indexGlobal index of the local subapp.
Returns
The DRL control on the subapp.

Definition at line 116 of file SamplerDRLControlTransfer.C.

117{
118 // Get the control object from the other app
119 FEProblemBase & app_problem = _multi_app->appProblemBase(app_index);
120 auto & control_warehouse = app_problem.getControlWarehouse();
121 std::shared_ptr<Control> control_ptr = control_warehouse.getActiveObject(_control_name);
122 LibtorchDRLControl * control_object = dynamic_cast<LibtorchDRLControl *>(control_ptr.get());
123
124 if (!control_object)
125 paramError("control_name", "The given control is not a LibtorchDRLControl!");
126
127 // The trainer builds one transition and one history lag per timestep_window steps, so any
128 // other window mixes held actions or skips policy evaluations made by the control.
129 const unsigned int timestep_window = _trainer.timestepWindow();
130 const unsigned int num_steps_in_period = control_object->numStepsInPeriod();
131 if (timestep_window != num_steps_in_period)
132 {
133 const auto divisor = std::gcd(timestep_window, num_steps_in_period);
134 const auto numerator = std::to_string(timestep_window / divisor);
135 const auto denominator = num_steps_in_period / divisor;
136 const std::string ratio = denominator == 1
137 ? numerator + " times"
138 : numerator + "/" + std::to_string(denominator) + " of";
139 paramError("control_name",
140 "The trainer '",
141 _trainer.name(),
142 "' has timestep_window = ",
143 timestep_window,
144 ", which is ",
145 ratio,
146 " this control's num_steps_in_period = ",
147 num_steps_in_period,
148 ". They must be equal so that each training transition corresponds to exactly one "
149 "policy evaluation.");
150 }
151
152 if (_trainer.inputTimesteps() != control_object->inputTimesteps())
153 paramError("control_name",
154 "The trainer '",
155 _trainer.name(),
156 "' has input_timesteps = ",
158 ", but this control has input_timesteps = ",
159 control_object->inputTimesteps(),
160 ". They must be equal so that the control stacks the same observation history "
161 "that the actor was trained on.");
162
163 if (_trainer.numberOfObservations() != control_object->numberOfObservations())
164 paramError("control_name",
165 "The trainer '",
166 _trainer.name(),
167 "' reads ",
169 " observation(s), but this control reads ",
170 control_object->numberOfObservations(),
171 ". They must be equal so that the actor receives the observations it was trained "
172 "on.");
173
174 if (_trainer.numberOfControlSignals() != control_object->numberOfControlSignals())
175 paramError("control_name",
176 "The trainer '",
177 _trainer.name(),
178 "' produces ",
180 " control signal(s), but this control sets ",
181 control_object->numberOfControlSignals(),
182 " parameter(s). They must be equal so that each actor output drives exactly one "
183 "controllable parameter.");
184
185 return *control_object;
186}
ExecuteMooseObjectWarehouse< Control > & getControlWarehouse()
unsigned int numberOfObservations() const
Return the number of observation reporters read at each time level.
unsigned int timestepWindow() const
Return the number of raw reporter entries per training transition.
unsigned int numberOfControlSignals() const
Return the number of control signals produced by the actor.
unsigned int inputTimesteps() const
Return the number of observation time levels stacked into the network inputs.
unsigned int numStepsInPeriod() const
Return the number of time steps between policy evaluations.
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.
unsigned int numberOfControlSignals() const
const std::string & name() const
void paramError(const std::string &param, Args... args) const
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
std::shared_ptr< MultiApp > _multi_app

Referenced by execute(), and executeToMultiapp().

◆ getSurrogateModel() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateModel ( const std::string &  name) const
inherited

Get a SurrogateModel/Trainer with a given name.

Parameters
nameThe name of the parameter key of the sampler to retrieve
Returns
The sampler with name associated with the parameter 'name'

Definition at line 81 of file SurrogateModelInterface.h.

82{
83 return getSurrogateModelByName<T>(_smi_params.get<UserObjectName>(name));
84}
const std::string name
Definition Setup.h:21
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
const InputParameters & _smi_params
Parameters of the object with this interface.

Referenced by SurrogateTrainer::initialize().

◆ getSurrogateModel() [2/2]

template<>
SurrogateModel & SurrogateModelInterface::getSurrogateModel ( const std::string &  name) const
inherited

Definition at line 46 of file SurrogateModelInterface.C.

47{
48 return getSurrogateModelByName<SurrogateModel>(_smi_params.get<UserObjectName>(name));
49}

◆ getSurrogateModelByName() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateModelByName ( const UserObjectName &  name) const
inherited

Get a sampler with a given name.

Parameters
nameThe name of the sampler to retrieve
Returns
The sampler with name 'name'

Definition at line 88 of file SurrogateModelInterface.h.

89{
90 std::vector<T *> models;
92 .query()
93 .condition<AttribName>(name)
94 .condition<AttribSystem>("SurrogateModel")
95 .queryInto(models);
96 if (models.empty())
97 mooseError("Unable to find a SurrogateModel object of type " + std::string(typeid(T).name()) +
98 " with the name '" + name + "'");
99 return *(models[0]);
100}
const double T
void mooseError(Args &&... args)
TheWarehouse & theWarehouse() const
FEProblemBase & _smi_feproblem
Reference to FEProblemBase instance.
Query query()

Referenced by CrossValidationScores::CrossValidationScores(), EvaluateSurrogate::EvaluateSurrogate(), and InverseMapping::initialSetup().

◆ getSurrogateModelByName() [2/2]

template<>
SurrogateModel & SurrogateModelInterface::getSurrogateModelByName ( const UserObjectName &  name) const
inherited

Definition at line 31 of file SurrogateModelInterface.C.

32{
33 std::vector<SurrogateModel *> models;
35 .query()
36 .condition<AttribName>(name)
37 .condition<AttribSystem>("SurrogateModel")
38 .queryInto(models);
39 if (models.empty())
40 mooseError("Unable to find a SurrogateModel object with the name '" + name + "'");
41 return *(models[0]);
42}

◆ getSurrogateTrainer() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateTrainer ( const std::string &  name) const
inherited

Definition at line 104 of file SurrogateModelInterface.h.

105{
106 return getSurrogateTrainerByName<T>(_smi_params.get<UserObjectName>(name));
107}

◆ getSurrogateTrainer() [2/2]

template<>
SurrogateTrainerBase & SurrogateModelInterface::getSurrogateTrainer ( const std::string &  name) const
inherited

Definition at line 60 of file SurrogateModelInterface.C.

61{
62 return getSurrogateTrainerByName<SurrogateTrainerBase>(_smi_params.get<UserObjectName>(name));
63}

◆ getSurrogateTrainerByName() [1/2]

template<typename T >
T & SurrogateModelInterface::getSurrogateTrainerByName ( const UserObjectName &  name) const
inherited

Definition at line 111 of file SurrogateModelInterface.h.

112{
113 SurrogateTrainerBase * base_ptr =
115 T * obj_ptr = dynamic_cast<T *>(base_ptr);
116 if (!obj_ptr)
117 mooseError("Failed to find a SurrogateTrainer object of type " + std::string(typeid(T).name()) +
118 " with the name '",
119 name,
120 "' for the desired type.");
121 return *obj_ptr;
122}
T & getUserObject(const std::string &name, unsigned int tid=0) const
const THREAD_ID _smi_tid
Thread ID.
This is the base trainer class whose main functionality is the API for declaring model data.

Referenced by SurrogateTrainerOutput::output().

◆ getSurrogateTrainerByName() [2/2]

template<>
SurrogateTrainerBase & SurrogateModelInterface::getSurrogateTrainerByName ( const UserObjectName &  name) const
inherited

Definition at line 53 of file SurrogateModelInterface.C.

◆ initializeFromMultiapp()

void SamplerDRLControlTransfer::initializeFromMultiapp ( )
overridevirtual

Initialize a batch transfer from the multiapp.

Reimplemented from StochasticToolsTransfer.

Definition at line 72 of file SamplerDRLControlTransfer.C.

73{
74}

◆ initializeToMultiapp()

void SamplerDRLControlTransfer::initializeToMultiapp ( )
overridevirtual

Initialize a batch transfer to the multiapp.

Reimplemented from StochasticToolsTransfer.

Definition at line 87 of file SamplerDRLControlTransfer.C.

88{
89}

◆ initialSetup()

void SamplerDRLControlTransfer::initialSetup ( )
overridevirtual

Prepare the transfer for batch-mode execution.

Reimplemented from MultiAppTransfer.

Definition at line 47 of file SamplerDRLControlTransfer.C.

48{
49}

◆ setCurrentRow()

void StochasticToolsTransfer::setCurrentRow ( const std::vector< Real > &  row)
inlineinherited

Method for keeping track of the row data when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 65 of file StochasticToolsTransfer.h.

65{ _row_data = row; }
std::vector< Real > _row_data
The current row of data (comes from multiapp)

◆ setGlobalMultiAppIndex()

void StochasticToolsTransfer::setGlobalMultiAppIndex ( dof_id_type  index)
inlineinherited

Method for setting the app index when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 51 of file StochasticToolsTransfer.h.

51{ _app_index = index; }

◆ setGlobalRowIndex()

void StochasticToolsTransfer::setGlobalRowIndex ( dof_id_type  row)
inlineinherited

Method for keeping track of the global row index when running in batch mode.

See StochasticTools<FullSolve/Transient>MultiApp

Definition at line 58 of file StochasticToolsTransfer.h.

58{ _global_index = row; }

◆ validParams()

InputParameters SamplerDRLControlTransfer::validParams ( )
static

Return the input parameters supported by this transfer.

Definition at line 20 of file SamplerDRLControlTransfer.C.

21{
24
26 "Copies a DRL actor from a trainer object on the main app to a LibtorchDRLControl object "
27 "on the subapp.");
28
29 params.suppressParameter<MultiAppName>("from_multi_app");
30
31 params.addRequiredParam<UserObjectName>(
32 "trainer_name", "Trainer object that owns the latest controller network.");
33 params.addRequiredParam<std::string>("control_name", "Controller object name.");
34 return params;
35}
void suppressParameter(const std::string &name)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
static InputParameters validParams()

Member Data Documentation

◆ _app_index

dof_id_type StochasticToolsTransfer::_app_index = 0
protectedinherited

◆ _control_name

const std::string SamplerDRLControlTransfer::_control_name
protected

The name of the control object on the other app where we want to copy our neural net.

Definition at line 89 of file SamplerDRLControlTransfer.h.

Referenced by getDRLControl().

◆ _global_index

dof_id_type StochasticToolsTransfer::_global_index = 0
protectedinherited

◆ _row_data

std::vector<Real> StochasticToolsTransfer::_row_data
protectedinherited

The current row of data (comes from multiapp)

Definition at line 73 of file StochasticToolsTransfer.h.

Referenced by SamplerParameterTransfer::executeToMultiapp(), and StochasticToolsTransfer::setCurrentRow().

◆ _sampler_ptr

Sampler* StochasticToolsTransfer::_sampler_ptr
protectedinherited

◆ _smi_feproblem

FEProblemBase& SurrogateModelInterface::_smi_feproblem
privateinherited

◆ _smi_params

const InputParameters& SurrogateModelInterface::_smi_params
privateinherited

Parameters of the object with this interface.

Definition at line 70 of file SurrogateModelInterface.h.

Referenced by SurrogateModelInterface::getSurrogateModel(), and SurrogateModelInterface::getSurrogateTrainer().

◆ _smi_tid

const THREAD_ID SurrogateModelInterface::_smi_tid
privateinherited

Thread ID.

Definition at line 76 of file SurrogateModelInterface.h.

Referenced by SurrogateModelInterface::getSurrogateTrainerByName().

◆ _trainer

const LibtorchDRLControlTrainer& SamplerDRLControlTransfer::_trainer
protected

The trainer object which will contains the control neural net.

Definition at line 92 of file SamplerDRLControlTransfer.h.

Referenced by execute(), executeToMultiapp(), and getDRLControl().


The documentation for this class was generated from the following files: