Main Content


Reinforcement learning policy

  • Library:
  • Reinforcement Learning Toolbox

  • Policy block


Use the Policy block to simulate a reinforcement learning policy in Simulink® and to generate code (using Simulink Coder™) for deployment purposes. This block takes an observation as input and outputs an action. You associate the block with a MAT-file that contains the information needed to fully characterize the policy, and which can be generated by generatePolicyFunction or generatePolicyBlock.



expand all

This port receives observation signals from the environment. Observation signals represent measurements or other instantaneous system data. If you have multiple observations, you can use a Mux block to combine them into a vector signal. To use a nonvirtual bus signal, use bus2RLSpec.


expand all

Action computed by the policy based on the observation input. Connect this port to the inputs of your system. To use a nonvirtual bus signal, use bus2RLSpec.


Policy blocks generated from a continuous action-space rlStochasticActorPolicy object or a continuous action-space rlACAgent, rlPGAgent, or rlPPOAgent object, do not enforce the constraints set by the action specification. In these cases, you must enforce action space constraints within the environment.


expand all

Enter the name of the MAT-file containing the information needed to fully characterize the policy. This file is generated by generatePolicyFunction or generatePolicyBlock. When you generate the block using generatePolicyBlock and specify a non-default dataFileName argument, then the generated block has this parameter set to the specified file name, so that the block is associated with the generated data file.

To use a Policy block within a conditionally executed subsystem, such as a Triggered Subsystem (Simulink) or a Function-Call Subsystem (Simulink), you must generate its data file from an agent or policy object which has its SampleTIme property set to -1. Doing so allows the block to inherit the sample time of its parent subsystem.

Programmatic Use

Block Parameter: MATFile
Type: string, character vector
Default: "blockAgentData.mat"

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2022b