Main Content

rlPGAgentOptions

Options for PG agent

Since R2019a

Description

Use an rlPGAgentOptions object to specify options for policy gradient (PG) agents. To create a PG agent, use rlPGAgent

For more information on PG agents, see Policy Gradient (PG) Agents.

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

Creation

Description

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

example

opt = rlPGAgentOptions(Name=Value) creates the options set opt and sets its properties using one or more name-value arguments. For example, rlPGAgentOptions(DiscountFactor=0.95) creates an options set with a discount factor of 0.95. You can specify multiple name-value arguments.

Properties

expand all

Option to use baseline for learning, specified as a logical value. When UseBaseline is true, you must specify a critic network as the baseline function approximator.

In general PG agents work better without a baseline for simpler problems and when using a small actor network.

Example: UseBaseline=false

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 this loss function.

Example: EntropyLossWeight=0.01

Actor optimizer options, specified as an rlOptimizerOptions object. It allows you to specify training parameters of the actor approximator such as learning rate, gradient threshold, as well as the optimizer algorithm and its parameters. For more information, see rlOptimizerOptions and rlOptimizer.

Example: ActorOptimizerOptions = rlOptimizerOptions(LearnRate=2e-3)

Critic optimizer options, specified as an rlOptimizerOptions object. It allows you to specify training parameters of the critic approximator such as learning rate, gradient threshold, as well as the optimizer algorithm and its parameters. For more information, see rlOptimizerOptions and rlOptimizer.

Example: CriticOptimizerOptions = rlOptimizerOptions(LearnRate=5e-3)

Sample time of agent, specified as a positive scalar or as -1. Setting this parameter to -1 allows for event-based simulations.

Within a Simulink® environment, the RL Agent block in which the agent is specified to execute every SampleTime seconds of simulation time. If SampleTime is -1, the block inherits the sample time from its parent subsystem.

Within a MATLAB® environment, the agent is executed every time the environment advances. In this case, SampleTime is the time interval between consecutive elements in the output experience returned by sim or train. If SampleTime is -1, the time interval between consecutive elements in the returned output experience reflects the timing of the event that triggers the agent execution.

Example: SampleTime=-1

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

Example: DiscountFactor=0.9

Object Functions

rlPGAgentPolicy gradient (PG) reinforcement learning agent

Examples

collapse all

This example shows how to create and modify a PG agent options object.

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

opt = rlPGAgentOptions(DiscountFactor=0.9)
opt = 
  rlPGAgentOptions with properties:

                SampleTime: 1
            DiscountFactor: 0.9000
         EntropyLossWeight: 0
               UseBaseline: 1
     ActorOptimizerOptions: [1x1 rl.option.rlOptimizerOptions]
    CriticOptimizerOptions: [1x1 rl.option.rlOptimizerOptions]
                InfoToSave: [1x1 struct]

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

opt.SampleTime = 0.5;

Version History

Introduced in R2019a

expand all