Main Content

policyParameters

Obtain structure of policy parameters to update policy during simulation or deployment

Since R2025a

    Description

    This function returns a structure containing the parameters of a policy, including its learnable and tunable parameters. You can use this structure to update the policy parameters during simulation or deployment. For MATLAB® simulations, use the updatePolicyParameters function. For Simulink® simulations, the structure is consistent with the bus object generated by the Policy block, so you can provide the structure as an input to the parameters port of the block.

    For more information on policies and value functions, see Create Policies and Value Functions.

    params = policyParameters(policy) returns the structure params containing the tunable and learnable parameters of policy.

    example

    Examples

    collapse all

    Assume that you have an existing trained reinforcement learning agent. For this example, load the trained agent from Compare DDPG Agent to LQR Controller.

    load("DoubleIntegDDPG.mat","agent") 

    Obtain the exploration policy from the agent.

    policy = getExplorationPolicy(agent);

    Obtain the parameters structure from the policy.

    params = policyParameters(policy)
    params = struct with fields:
               Model_fc_Weights: [-15.4663 -7.2746]
                  Model_fc_Bias: 0
        Policy_EnableNoiseDecay: 0
          Policy_UseNoisyAction: 1
                             ID: 0
    
    

    Modify the parameter values. For this example, turn off the additive action noise to make the policy greedy.

    params.Policy_UseNoisyAction = false;

    Update the policy with the modified structure.

    policy = updatePolicyParameters(policy,params);

    Display the updated value of the policy parameter.

    policy.UseNoisyAction
    ans = logical
       0
    
    

    Input Arguments

    collapse all

    Reinforcement learning policy, specified as one of these objects:

    Example: getExplorationPolicy(rlPPOAgent(rlNumericSpec([3 1]),rlNumericSpec([1 1])))

    Output Arguments

    collapse all

    Parameters of the policy, returned as a structure. The params structure is consistent with the bus object generated by the Policy block, and so it can be used to update the policy parameters during simulation or deployment.

    The policy does not use the parameter ID, so you can use it to associate experiences to a given set of parameters. For example, while learning with an on-policy agent, you can identify the experiences associated with the latest policy.

    Version History

    Introduced in R2025a