rlACAgentOptions
Options for AC agent
Description
Use an rlACAgentOptions
object to specify options for
creating actor-critic (AC) agents. To create an actor-critic agent, use rlACAgent
For more information see Actor-Critic Agents.
For more information on the different types of reinforcement learning agents, see Reinforcement Learning Agents.
Creation
Description
creates a default
option set for an AC agent. You can modify the object properties using dot
notation.opt
= rlACAgentOptions
sets option properties using
name-value pairs. For example, opt
= rlACAgentOptions(Name,Value
)rlDQNAgentOptions('DiscountFactor',0.95)
creates an option set with a discount factor of 0.95
. You can specify
multiple name-value pairs. Enclose each property name in quotes.
Properties
NumStepsToLookAhead
— Number of steps ahead
32
(default) | positive integer
Number of steps the agent interacts with the environment before learning from its
experience, specified as a positive integer. When the agent uses a recurrent neural
network, NumStepsToLookAhead
is treated as the training trajectory
length.
EntropyLossWeight
— Entropy loss weight
0
(default) | scalar value between 0
and 1
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.
ActorOptimizerOptions
— Actor optimizer options
rlOptimizerOptions
object
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
.
CriticOptimizerOptions
— Critic optimizer options
rlOptimizerOptions
object
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
.
SampleTime
— Sample time of agent
1
(default) | positive scalar | -1
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.
DiscountFactor
— Discount factor
0.99
(default) | positive scalar less than or equal to 1
Discount factor applied to future rewards during training, specified as a positive scalar less than or equal to 1.
Object Functions
rlACAgent | Actor-critic reinforcement learning agent |
Examples
Create AC Agent Options Object
Create an AC agent options object, specifying the discount factor.
opt = rlACAgentOptions('DiscountFactor',0.95)
opt = rlACAgentOptions with properties: NumStepsToLookAhead: 32 EntropyLossWeight: 0 ActorOptimizerOptions: [1x1 rl.option.rlOptimizerOptions] CriticOptimizerOptions: [1x1 rl.option.rlOptimizerOptions] SampleTime: 1 DiscountFactor: 0.9500 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 R2019aR2022a: Simulation and deployment: UseDeterministicExploitation
will be removed
The property UseDeterministicExploitation
of the
rlACAgentOptions
object will be removed in a future release. Use the
UseExplorationPolicy
property of rlACAgent
instead.
Previously, you set UseDeterministicExploitation
as follows.
Force the agent to always select the action with maximum likelihood, thereby using a greedy deterministic policy for simulation and deployment.
agent.AgentOptions.UseDeterministicExploitation = true;
Allow the agent to select its action by sampling its probability distribution for simulation and policy deployment, thereby using a stochastic policy that explores the observation space.
agent.AgentOptions.UseDeterministicExploitation = false;
Starting in R2022a, set UseExplorationPolicy
as follows.
Force the agent to always select the action with maximum likelihood, thereby using a greedy deterministic policy for simulation and deployment.
agent.UseExplorationPolicy = false;
Allow the agent to select its action by sampling its probability distribution for simulation and policy deployment, thereby using a stochastic policy that explores the observation space.
agent.UseExplorationPolicy = true;
Similarly to UseDeterministicExploitation
,
UseExplorationPolicy
affects only simulation and deployment; it does
not affect training.
R2020b: Default value for NumStepsToLookAhead
changed to 32
A value of 32 for this property should work better than 1 for most environments. If you
nave MATLAB R2020b or a later version and you want
to reproduce how rlACAgent
behaved on
versions prior to R2020b, set this value to 1.
See Also
Topics
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)