https://mooseframework.inl.gov
LibtorchDRLLogProbabilityPostprocessor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #ifdef LIBTORCH_ENABLED
11 
13 
15 
18 {
20 
21  params.addClassDescription(
22  "Computes the logarithmic probability of the action in a given LibtorchDRLController.");
23 
24  params.addRequiredParam<std::string>("control_name",
25  "The name of the LibtorchNeuralNetControl object.");
26  params.addParam<unsigned int>("signal_index",
27  0,
28  "The index of the signal from the LibtorchNeuralNetControl object. "
29  "This assumes indexing between [0,num_signals).");
30  return params;
31 }
32 
34  const InputParameters & params)
35  : GeneralPostprocessor(params), _signal_index(getParam<unsigned int>("signal_index"))
36 
37 {
38 }
39 
40 void
42 {
44 
47  .getActiveObject(getParam<std::string>("control_name"))
48  .get());
50  paramError("control_name",
51  "The supplied control object is not derived from LibtorchDRLControl!");
52 
54  paramError("signal_index",
55  "The given control object only has ",
57  " control signals!");
58 }
59 
60 Real
62 {
63  // Return the value of the control signal
65 }
66 
67 #endif
unsigned int numberOfControlSignals() const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void initialSetup() override
We override this to setup the linking with the control object.
void addRequiredParam(const std::string &name, const std::string &doc_string)
static InputParameters validParams()
std::shared_ptr< Control > getActiveObject(const std::string &name, THREAD_ID tid=0) const
Real getSignalLogProbability(const unsigned int signal_index) const
Get the logarithmic probability of (signal_index)-th signal of the control neural net...
void paramError(const std::string &param, Args... args) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FEProblemBase & _fe_problem
LibtorchDRLLogProbabilityPostprocessor(const InputParameters &parameters)
Class constructor.
void addClassDescription(const std::string &doc_string)
A time-dependent, neural-network-based controller which is associated with a Proximal Policy Optimiza...
registerMooseObject("StochasticToolsApp", LibtorchDRLLogProbabilityPostprocessor)
virtual Real getValue() const override
Returns the value of the latest response of a neural-network-based controller.
ExecuteMooseObjectWarehouse< Control > & getControlWarehouse()
A class for querying output signals from LibtorchNeuralNetControl and derived objects.
virtual void initialSetup()
void ErrorVector unsigned int