https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 MOOSE_LIBTORCH_ENABLED
11
13
15
18{
20
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
40void
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
60Real
62{
63 // Return the value of the control signal
65}
66
67#endif
registerMooseObject("StochasticToolsApp", LibtorchDRLLogProbabilityPostprocessor)
void ErrorVector unsigned int
ExecuteMooseObjectWarehouse< Control > & getControlWarehouse()
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
A time-dependent, neural-network-based controller which is associated with a Proximal Policy Optimiza...
Real getSignalLogProbability(const unsigned int signal_index) const
Get the logarithmic probability of (signal_index)-th signal of the control neural net.
A class for querying output signals from LibtorchNeuralNetControl and derived objects.
virtual Real getValue() const override
Returns the value of the latest response of a neural-network-based controller.
LibtorchDRLLogProbabilityPostprocessor(const InputParameters &parameters)
Class constructor.
void initialSetup() override
We override this to setup the linking with the control object.
unsigned int numberOfControlSignals() const
void paramError(const std::string &param, Args... args) const
std::shared_ptr< T > getActiveObject(const std::string &name, THREAD_ID tid=0) const
virtual void initialSetup()
FEProblemBase & _fe_problem