Line data Source code
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 : 12 : #pragma once 13 : 14 : #include "LibtorchDRLControl.h" 15 : #include "GeneralPostprocessor.h" 16 : #include "InputParameterWarehouse.h" 17 : 18 : /** 19 : * A class for querying output signals from LibtorchNeuralNetControl and 20 : * derived objects. 21 : */ 22 : class LibtorchDRLLogProbabilityPostprocessor : public GeneralPostprocessor 23 : { 24 : public: 25 : static InputParameters validParams(); 26 : 27 : /** 28 : * Class constructor 29 : * @param parameters The input parameters 30 : */ 31 : LibtorchDRLLogProbabilityPostprocessor(const InputParameters & parameters); 32 : 33 : ///@{ 34 : /** 35 : * No action taken 36 : */ 37 1000 : void initialize() override {} 38 1000 : void execute() override {} 39 : ///@} 40 : 41 : /** 42 : * We override this to setup the linking with the control object. We need to do it here 43 : * because the PPs are contructed before te Control objects. 44 : */ 45 : void initialSetup() override; 46 : 47 : /** 48 : * Returns the value of the latest response of a neural-network-based controller. 49 : * This means that we grab current response value stored wihtin the controller. 50 : */ 51 : virtual Real getValue() const override; 52 : 53 : private: 54 : const unsigned int _signal_index; 55 : 56 : // This can't be const beause PPs are constructed before Controls 57 : const LibtorchDRLControl * _libtorch_nn_control; 58 : }; 59 : 60 : #endif