Main Content

rlTRPOAgentOptions

Options for TRPO agent

Description

Use an rlTRPOAgentOptions object to specify options for trust region policy optimization (TRPO) agents. To create a TRPO agent, use rlTRPOAgent.

For more information on TRPO agents, see Trust Region Policy Optimization Agents.

For more information on the different types of reinforcement learning agents, see Reinforcement Learning Agents.

Creation

Description

opt = rlTRPOAgentOptions creates an rlPPOAgentOptions object for use as an argument when creating a TRPO agent using all default settings. You can modify the object properties using dot notation.

example

opt = rlTRPOAgentOptions(Name,Value) sets option properties using name-value arguments. For example, rlTRPOAgentOptions('DiscountFactor',0.95) creates an option set with a discount factor of 0.95. You can specify multiple name-value arguments. Enclose each property name in quotes.

Properties

expand all

Number of steps the agent interacts with the environment before learning from its experience, specified as a positive integer.

The ExperienceHorizon value must be greater than or equal to the MiniBatchSize value.

Mini-batch size used for each learning epoch, specified as a positive integer. When the agent uses a recurrent neural network, MiniBatchSize is treated as the training trajectory length.

The MiniBatchSize value must be less than or equal to the ExperienceHorizon value.

Entropy loss weight, specified as a scalar value between 0 and 1. A higher entropy loss weight value promotes agent exploration by applying a penalty for being too certain about which action to take. Doing so can help the agent move out of local optima.

When gradients are computed during training, an additional gradient component is computed for minimizing the entropy loss. For more information, see Entropy Loss.

Number of epochs for which the actor and critic networks learn from the current experience set, specified as a positive integer.

Method for estimating advantage values, specified as one of the following:

  • "gae" — Generalized advantage estimator

  • "finite-horizon" — Finite horizon estimation

For more information on these methods, see the training algorithm information in Proximal Policy Optimization Agents.

Smoothing factor for generalized advantage estimator, specified as a scalar value between 0 and 1, inclusive. This option applies only when the AdvantageEstimateMethod option is "gae"

Option to return the action with maximum likelihood for simulation and policy generation, specified as a logical value. When UseDeterministicExploitation is set to true, the action with maximum likelihood is always used in sim and generatePolicyFunction, which causes the agent to behave deterministically.

When UseDeterministicExploitation is set to false, the agent samples actions from probability distributions, which causes the agent to behave stochastically.

Upper limit for the Kullback-Leibler (KL) divergence between the old policy and the current policy, specified as a positive scalar.

Maximum number of iterations for conjugate gradient decent, specified as positive integer.

Conjugate gradient damping factor for numerical stability, specified as a nonnegative scalar.

Conjugate gradient residual tolerance, specified as a positive scalar. Once the residual for the conjugate gradient algorithm is below this tolerance, the algorithm stops.

Typically, the default value works well for most cases.

Number of iterations for line search, specified as a positive integer.

Typically, the default value works well for most cases.

Method for normalizing advantage function values, specified as one of the following:

  • "none" — Do not normalize advantage values

  • "current" — Normalize the advantage function using the mean and standard deviation for the current mini-batch of experiences.

  • "moving" — Normalize the advantage function using the mean and standard deviation for a moving window of recent experiences. To specify the window size, set the AdvantageNormalizingWindow option.

In some environments, you can improve agent performance by normalizing the advantage function during training. The agent normalizes the advantage function by subtracting the mean advantage value and scaling by the standard deviation.

Window size for normalizing advantage function values, specified as a positive integer. Use this option when the NormalizedAdvantageMethod option is "moving".

Sample time of agent, specified as a positive scalar.

Within a Simulink® environment, the agent gets executed every SampleTime seconds of simulation time.

Within a MATLAB® environment, the agent gets executed every time the environment advances. However, SampleTime is the time interval between consecutive elements in the output experience returned by sim or train.

Discount factor applied to future rewards during training, specified as a positive scalar less than or equal to 1.

Object Functions

rlTRPOAgentTrust region policy optimization reinforcement learning agent

Examples

collapse all

Create a TRPO agent options object, specifying the discount factor.

opt = rlTRPOAgentOptions('DiscountFactor',0.9)
opt = 
  rlTRPOAgentOptions with properties:

                     ExperienceHorizon: 512
                         MiniBatchSize: 128
                     EntropyLossWeight: 0.0100
                              NumEpoch: 1
               AdvantageEstimateMethod: "gae"
                             GAEFactor: 0.9500
          UseDeterministicExploitation: 0
              ConjugateGradientDamping: 1.0000e-04
                     KLDivergenceLimit: 0.0100
        NumIterationsConjugateGradient: 10
               NumIterationsLineSearch: 10
    ConjugateGradientResidualTolerance: 1.0000e-08
             NormalizedAdvantageMethod: "none"
            AdvantageNormalizingWindow: 1000000
                            SampleTime: 1
                        DiscountFactor: 0.9000

You can modify options using dot notation. For example, set the agent sample time to 0.1.

opt.SampleTime = 0.1;
Introduced in R2021b