- observationsPostprocessors used as the current observation vector.
C++ Type:std::vector<PostprocessorName>
Unit:(no unit assumed)
Controllable:No
Description:Postprocessors used as the current observation vector.
- parametersControllable input parameters driven by the network.
C++ Type:std::vector<std::string>
Controllable:No
Description:Controllable input parameters driven by the network.
LibtorchDRLControl
Sets the value of multiple 'Real' input parameters and postprocessors based on a Deep Reinforcement Learning (DRL) neural network trained using a PPO algorithm.
Overview
This object is the runtime policy executor paired with LibtorchDRLControlTrainer. It extends LibtorchNeuralNetControl with stochastic policy sampling, action reuse, optional smoothing, and restartable policy state. For deterministic execution of the same actor, set "stochastic" to false. Use LibtorchNeuralNetControl instead when a plain deterministic neural-net control object is preferred without the DRL-specific execution features.
Execution Model
LibtorchDRLControl only supports TIMESTEP_BEGIN. On each execution it reads the current observation values, combines them with the stored history implied by "input_timesteps", and evaluates the actor when a new policy action is needed.
If "stochastic" is true, the action is sampled from the actor distribution and the corresponding log probabilities are stored for PPO training. If it is false, the deterministic actor output is used instead. The policy evaluation can be reused across multiple time steps with "num_steps_in_period". For num_steps_in_period = P, the actor is evaluated on steps , and the action is held in between. A transfer that executes the control before the first time step also triggers an evaluation at step 0. The observation history only advances when the actor is evaluated, so consecutive entries of the stacked input are one control period apart. Set "timestep_window" on the trainer to the same value so that it rebuilds the observations the controller used.
The applied control can also be smoothed exponentially with "control_smoothing_factor": where is the control_smoothing_factor value. Setting control_smoothing_factor = 1 applies the raw policy action directly. Because each applied value lies between the previous applied value and the policy action, smoothing does not overshoot the action or leave the range set by "min_control_value" and "max_control_value", provided the starting value lies in that range. The smoothed signal starts from zero, so with the first applied values lie between zero and the policy action. The smoothing is applied every time step, including the steps within a control period that reuse the previous action. LibtorchControlValuePostprocessor reports the policy action , not the applied value.
The controller stores the observation history, smoothed signal, and the libtorch CPU random-number-generator state as restartable data. This keeps stochastic recovered runs aligned with uninterrupted runs, provided the same controller state is recovered.
Input Parameters
- action_scaling_factorsPer-action scaling embedded in the controller outputs so saved checkpoints stay in physical units.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Per-action scaling embedded in the controller outputs so saved checkpoints stay in physical units.
- activation_functionrelu Activation name for each hidden layer, or one shared value for all layers.
Default:relu
C++ Type:std::vector<std::string>
Controllable:No
Description:Activation name for each hidden layer, or one shared value for all layers.
- control_offsetsOptional constant offsets added to each policy signal before setting the controlled parameter. This can be used to train a policy on deviations from a nominal signal.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional constant offsets added to each policy signal before setting the controlled parameter. This can be used to train a policy on deviations from a nominal signal.
- control_smoothing_factor1Exponential smoothing factor for the applied control signal: the fraction of the change from the previously applied signal toward the new policy action that is applied at each time step. A value of 1 applies the policy action directly.
Default:1
C++ Type:Real
Unit:(no unit assumed)
Range:control_smoothing_factor>0 & control_smoothing_factor<=1
Controllable:No
Description:Exponential smoothing factor for the applied control signal: the fraction of the change from the previously applied signal toward the new policy action that is applied at each time step. A value of 1 applies the policy action directly.
- depends_onThe Controls that this control relies upon (i.e. must execute before this one)
C++ Type:std::vector<std::string>
Controllable:No
Description:The Controls that this control relies upon (i.e. must execute before this one)
- execute_onTIMESTEP_BEGINThe list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
Default:TIMESTEP_BEGIN
C++ Type:ExecFlagEnum
Controllable:No
Description:The list of flag(s) indicating when this object should be executed. For a description of each flag, see https://mooseframework.inl.gov/source/interfaces/SetupInterface.html.
- filenameFile containing the controller network.
C++ Type:std::string
Controllable:No
Description:File containing the controller network.
- input_timesteps1Number of recent timesteps to stack into each network input.
Default:1
C++ Type:unsigned int
Range:1<=input_timesteps
Controllable:No
Description:Number of recent timesteps to stack into each network input.
- max_control_valueOptional upper bounds for each control signal.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional upper bounds for each control signal.
- min_control_valueOptional lower bounds for each control signal.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional lower bounds for each control signal.
- num_neurons_per_layerHidden-layer widths used when constructing the controller.
C++ Type:std::vector<unsigned int>
Controllable:No
Description:Hidden-layer widths used when constructing the controller.
- num_steps_in_period1Number of time steps between policy evaluations. The observation history advances once per period, so the trainer's 'timestep_window' should match this value.
Default:1
C++ Type:unsigned int
Range:1<=num_steps_in_period
Controllable:No
Description:Number of time steps between policy evaluations. The observation history advances once per period, so the trainer's 'timestep_window' should match this value.
- observation_scaling_factorsOptional multipliers applied after shifting the observation values.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional multipliers applied after shifting the observation values.
- observation_shift_factorsOptional offsets applied to the observation values before scaling.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional offsets applied to the observation values before scaling.
- seedSeed for the random number generator.
C++ Type:unsigned int
Controllable:No
Description:Seed for the random number generator.
- state_independent_stdTrueIf true, interpret the unbounded Gaussian actor as learning one log-std per action dimension. If false, use a state-dependent std head.
Default:True
C++ Type:bool
Controllable:No
Description:If true, interpret the unbounded Gaussian actor as learning one log-std per action dimension. If false, use a state-dependent std head.
- stochasticTrueIf true, sample from the policy distribution; otherwise use the deterministic action.
Default:True
C++ Type:bool
Controllable:No
Description:If true, sample from the policy distribution; otherwise use the deterministic action.
Optional Parameters
- control_tagsAdds user-defined labels for accessing object parameters via control logic.
C++ Type:std::vector<std::string>
Controllable:No
Description:Adds user-defined labels for accessing object parameters via control logic.
- enableTrueSet the enabled status of the MooseObject.
Default:True
C++ Type:bool
Controllable:No
Description:Set the enabled status of the MooseObject.
- implicitTrueDetermines whether this object is calculated using an implicit or explicit form
Default:True
C++ Type:bool
Controllable:No
Description:Determines whether this object is calculated using an implicit or explicit form
Advanced Parameters
Input Files
- (modules/stochastic_tools/test/tests/controls/libtorch_drl_control/libtorch_drl_control.i)
- (modules/stochastic_tools/test/tests/transfers/sampler_drl_control_transfer/sub.i)
- (modules/stochastic_tools/test/tests/transfers/libtorch_nn_transfer/libtorch_drl_control_sub.i)
- (modules/stochastic_tools/examples/libtorch_drl_control/libtorch_drl_control_sub.i)