- controlReporters containing the values of the controlled quantities (control signals) from the model simulations.
C++ Type:std::vector<ReporterName>
Controllable:No
Description:Reporters containing the values of the controlled quantities (control signals) from the model simulations.
- control_learning_rateLearning rate used by the actor optimizer.
C++ Type:Real
Unit:(no unit assumed)
Range:0
Controllable:No
Description:Learning rate used by the actor optimizer.
- critic_learning_rateLearning rate used by the critic optimizer.
C++ Type:Real
Unit:(no unit assumed)
Range:0
Controllable:No
Description:Learning rate used by the critic optimizer.
- log_probabilityReporters containing the log probabilities of the actions taken during the simulations.
C++ Type:std::vector<ReporterName>
Controllable:No
Description:Reporters containing the log probabilities of the actions taken during the simulations.
- num_control_neurons_per_layerNumber of neurons per layer for the control neural network.
C++ Type:std::vector<unsigned int>
Controllable:No
Description:Number of neurons per layer for the control neural network.
- num_critic_neurons_per_layerHidden-layer widths for the critic network.
C++ Type:std::vector<unsigned int>
Controllable:No
Description:Hidden-layer widths for the critic network.
- num_epochsNumber of epochs for the training.
C++ Type:unsigned int
Controllable:No
Description:Number of epochs for the training.
- observationReporter values containing the observation values from the model.
C++ Type:std::vector<ReporterName>
Controllable:No
Description:Reporter values containing the observation values from the model.
- rewardReporter containing the earned time-dependent rewards from the simulation.
C++ Type:ReporterName
Controllable:No
Description:Reporter containing the earned time-dependent rewards from the simulation.
LibtorchDRLControlTrainer
Trains a neural network controller using fixed-horizon PPO on top of the libtorch RL core.
Overview
This object trains an on-policy actor-critic controller using Proximal Policy Optimization (PPO) Schulman et al. (2017) together with generalized advantage estimation (GAE) Schulman et al. (2015). Reporter trajectories are assembled into transitions, flattened across samples, shuffled into mini-batches, and then used to update separate actor and critic neural networks.
Algorithm Summary
For input_timesteps = H, the observation passed to the actor and critic is the stacked history where early missing history entries are filled with the earliest available reporter value.
Each collected trajectory is converted into the tuples . The "shift_outputs" option aligns the reported action and log-probability sequences with the reward sequence when the control is applied at the beginning of a time step and the reward is measured at the end of that step. The "timestep_window" option can be used to downsample long reporter trajectories before these transitions are assembled. For timestep_window = W, the trainer keeps every -th reporter entry, so consecutive entries of the stacked history are time steps apart. should match "num_steps_in_period" on the controller, which advances its observation history once per control period.
The critic is first evaluated on and , and the temporal-difference residual is computed as The trainer then computes the reverse-time GAE recursion with critic regression targets
For each mini-batch, PPO uses the probability ratio and the actor objective implemented here is The critic is trained with a mean-squared-error loss,
If "standardize_advantage" is set, each sampled mini-batch uses zero-mean, unit-variance advantages before the PPO loss is evaluated.
Notes
The actor embeds the configured input shifting, input scaling, and action scaling directly into the neural-network module so that transferred and checkpointed controllers operate in the same normalized coordinates used during training.
The trainer updates the actor and critic with separate Adam optimizers and then broadcasts the updated parameters so all MPI ranks hold the same networks after each PPO update.
Example Input File Syntax
Input Parameters
- action_scaling_factorsScale factors embedded into the trained policy outputs so transferred and checkpointed controllers operate in physical units.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Scale factors embedded into the trained policy outputs so transferred and checkpointed controllers operate in physical units.
- average_reward_over_timestep_windowFalseAverage reward reporter values over each timestep_window interval instead of sampling one value at the end of the interval.
Default:False
C++ Type:bool
Controllable:No
Description:Average reward reporter values over each timestep_window interval instead of sampling one value at the end of the interval.
- batch_size100Number of flattened samples per mini-batch.
Default:100
C++ Type:unsigned int
Controllable:No
Description:Number of flattened samples per mini-batch.
- clip_parameter0.2Clip parameter used while clamping the advantage value.
Default:0.2
C++ Type:Real
Unit:(no unit assumed)
Controllable:No
Description:Clip parameter used while clamping the advantage value.
- control_activation_functionsrelu Activation name for each actor hidden layer, or one shared value for all layers.
Default:relu
C++ Type:std::vector<std::string>
Controllable:No
Description:Activation name for each actor hidden layer, or one shared value for all layers.
- critic_activation_functionsrelu Activation name for each critic hidden layer, or one shared value for all layers.
Default:relu
C++ Type:std::vector<std::string>
Controllable:No
Description:Activation name for each critic hidden layer, or one shared value for all layers.
- decay_factor1Discount factor used when building PPO return and GAE targets.
Default:1
C++ Type:Real
Unit:(no unit assumed)
Range:0.0<=decay_factor<=1.0
Controllable:No
Description:Discount factor used when building PPO return and GAE targets.
- entropy_coeff0.01Entropy bonus coefficient used in the PPO actor loss.
Default:0.01
C++ Type:Real
Unit:(no unit assumed)
Controllable:No
Description:Entropy bonus coefficient used in the PPO actor loss.
- filenameThe name of the file which will be associated with the saved/loaded data.
C++ Type:FileName
Controllable:No
Description:The name of the file which will be associated with the saved/loaded data.
- filename_baseBase filename used when writing actor and critic checkpoints.
C++ Type:std::string
Controllable:No
Description:Base filename used when writing actor and critic checkpoints.
- input_timesteps1Number of time steps to use in the input data, if larger than 1, data from the previous timesteps will be used as inputs in the training.
Default:1
C++ Type:unsigned int
Range:1<=input_timesteps
Controllable:No
Description:Number of time steps to use in the input data, if larger than 1, data from the previous timesteps will be used as inputs in the training.
- lambda_factor1GAE lambda.
Default:1
C++ Type:Real
Unit:(no unit assumed)
Range:0.0<=lambda_factor<=1.0
Controllable:No
Description:GAE lambda.
- loss_print_frequency0Print PPO loss values every N updates. Use 0 to stay quiet.
Default:0
C++ Type:unsigned int
Controllable:No
Description:Print PPO loss values every N updates. Use 0 to stay quiet.
- 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.
- observation_scaling_factorsOptional multipliers applied after shifting the observed state values.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional multipliers applied after shifting the observed state values.
- observation_shift_factorsOptional offsets applied to the observed state values before scaling.
C++ Type:std::vector<Real>
Unit:(no unit assumed)
Controllable:No
Description:Optional offsets applied to the observed state values before scaling.
- read_from_fileFalseSwitch to read the neural network parameters from a file.
Default:False
C++ Type:bool
Controllable:No
Description:Switch to read the neural network parameters from a file.
- seed11Random number generator seed for stochastic optimizers.
Default:11
C++ Type:unsigned int
Controllable:No
Description:Random number generator seed for stochastic optimizers.
- shift_outputsTrueWhether to shift rollout outputs so observations and actions line up in time.
Default:True
C++ Type:bool
Controllable:No
Description:Whether to shift rollout outputs so observations and actions line up in time.
- standardize_advantageTrueSwitch to enable the shifting and normalization of the advantages in the PPO algorithm.
Default:True
C++ Type:bool
Controllable:No
Description:Switch to enable the shifting and normalization of the advantages in the PPO algorithm.
- state_independent_stdTrueIf true, learn one Gaussian log-std parameter per action dimension. If false, learn a state-dependent std head as in the older MOOSE actor implementation.
Default:True
C++ Type:bool
Controllable:No
Description:If true, learn one Gaussian log-std parameter per action dimension. If false, learn a state-dependent std head as in the older MOOSE actor implementation.
- timestep_window1Use every nth reporter timestep when assembling trajectories. Observation history lags also span this many timesteps, so it should match the controller's 'num_steps_in_period'.
Default:1
C++ Type:unsigned int
Range:1<=timestep_window
Controllable:No
Description:Use every nth reporter timestep when assembling trajectories. Observation history lags also span this many timesteps, so it should match the controller's 'num_steps_in_period'.
- update_frequency1Number of transient simulation data to collect for updating the controller neural network.
Default:1
C++ Type:unsigned int
Range:1<=update_frequency
Controllable:No
Description:Number of transient simulation data to collect for updating the controller neural network.
Optional Parameters
- allow_duplicate_execution_on_initialFalseIn the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
Default:False
C++ Type:bool
Controllable:No
Description:In the case where this UserObject is depended upon by an initial condition, allow it to be executed twice during the initial setup (once before the IC and again after mesh adaptivity (if applicable).
- execute_onTIMESTEP_ENDThe 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_END
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.
- execution_order_group0Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
Default:0
C++ Type:int
Controllable:No
Description:Execution order groups are executed in increasing order (e.g., the lowest number is executed first). Note that negative group numbers may be used to execute groups before the default (0) group. Please refer to the user object documentation for ordering of user object execution within a group.
- force_postauxFalseForces the UserObject to be executed in POSTAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in POSTAUX
- force_preauxFalseForces the UserObject to be executed in PREAUX
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREAUX
- force_preicFalseForces the UserObject to be executed in PREIC during initial setup
Default:False
C++ Type:bool
Controllable:No
Description:Forces the UserObject to be executed in PREIC during initial setup
Execution Scheduling 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:Yes
Description:Set the enabled status of the MooseObject.
- use_displaced_meshFalseWhether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Default:False
C++ Type:bool
Controllable:No
Description:Whether or not this object should use the displaced mesh for computation. Note that in the case this is true but no displacements are provided in the Mesh block the undisplaced mesh will still be used.
Advanced Parameters
- prop_getter_suffixAn optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
C++ Type:MaterialPropertyName
Unit:(no unit assumed)
Controllable:No
Description:An optional suffix parameter that can be appended to any attempt to retrieve/get material properties. The suffix will be prepended with a '_' character.
- use_interpolated_stateFalseFor the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
Default:False
C++ Type:bool
Controllable:No
Description:For the old and older state use projected material properties interpolated at the quadrature points. To set up projection use the ProjectedStatefulMaterialStorageAction.
Material Property Retrieval Parameters
Input Files
- (modules/stochastic_tools/test/tests/transfers/libtorch_nn_transfer/libtorch_drl_control_trainer.i)
- (modules/stochastic_tools/examples/libtorch_drl_control/libtorch_drl_control_trainer.i)
- (modules/stochastic_tools/test/tests/transfers/sampler_drl_control_transfer/trainer.i)
- (modules/stochastic_tools/test/tests/surrogates/libtorch_drl/trainer_errors.i)
References
- John Schulman, Philipp Moritz, Sergey Levine, Michael Jordan, and Pieter Abbeel.
High-dimensional continuous control using generalized advantage estimation.
arXiv preprint arXiv:1506.02438, 2015.[Export]
- John Schulman, Filip Wolski, Prafulla Dhariwal, Alec Radford, and Oleg Klimov.
Proximal policy optimization algorithms.
arXiv preprint arXiv:1707.06347, 2017.[Export]