主要内容

rlsimulationptions

Options for simulating a reinforcement learning agent within an environment

Description

使用一个rlsimulationptionsobject to specify simulation options for simulating a reinforcement learning agent within an environment. To perform the simulation, usesim.

For more information on agents training and simulation, seeTrain Reinforcement Learning Agents.

Creation

Description

simopts= rlSimulationOptionsreturns the default options for simulating a reinforcement learning environment against an agent. Use simulation options to specify parameters about the simulation such as the maximum number of steps to run per simulation and the number of simulations to run. After configuring the options, usesimoptsas an input argument forsim.

example

opt= rlSimulationOptions(Name,Value)creates a simulation options set with the specifiedPropertiesusing one or more name-value pair arguments.

Properties

expand all

Number of steps to run the simulation, specified as the comma-separated pair consisting of“ maxsteps'和一个积极的整数。通常,您定义环境中的发作终止条件。如果未满足这些终止条件,则此值是在模拟中运行的最大步骤数。

例子:“ maxsteps',1000

Number of simulations to run, specified as the comma-separated pair consisting of'NumSimulations'和一个积极的整数。在每个模拟的开始时,sim重置环境。您指定创建环境时在环境重置上发生的情况。例如,如果您将环境配置为这样做,则在每个情节开始时重置环境可以随机化初始状态值。在这种情况下,运行多个模拟使您可以在一系列初始条件下验证受过训练的代理的性能。

例子:“数字”,10

Stop simulation when an error occurs, specified as“离开”或者"on". When this option is“离开”, errors are captured and returned in the模拟output ofsim, and simulation continues.

用于使用并行模拟的标志,指定为logical. Setting this option to真的配置仿真以使用并行处理来模拟环境,从而使多个内核,处理器,计算机簇或云资源使用以加快模拟。要指定并行仿真的选项,请使用ParallelizationOptionsproperty.

请注意,如果您想使用本地GPU加快深度神经网络计算(例如梯度计算,参数更新和预测),则不需要设置UseParallelto true. Instead, when creating your actor or critic representation, use anrlRepresentationOptions对象UseDeviceoption is set to"gpu".

Using parallel computing or the GPU requires Parallel Computing Toolbox™ software. Using computer clusters or cloud resources additionally requiresMATLAB®Parallel Server™.

For more information about training using multicore processors and GPUs, see使用平行计算和GPU的训练代理.

例子:“ useparallel”,true

Parallelization options to control parallel simulation, specified as a并行培养目的。有关使用并行计算培训的更多信息,请参见Train Reinforcement Learning Agents.

The并行培养object has the following properties, which you can modify using dot notation after creating therltrainingoptions目的。

工人的随机化初始化,指定为以下一个:

  • –1- 为每个工人分配一个独特的随机种子。种子的价值是工人ID。

  • –2— Do not assign a random seed to the workers.

  • 向量 - 手动为每项工作指定随机种子。向量中的元素数必须与工人数量匹配。

Send model and workspace variables to parallel workers, specified as"on"或者“离开”. When the option is"on", the host sends variables used in models and defined in the base MATLAB workspace to the workers.

Additional files to attach to the parallel pool, specified as a string or string array.

Function to run before simulation starts, specified as a handle to a function having no input arguments. This function is run once per worker before simulation begins. Write this function to perform any processing that you need prior to simulation.

在模拟结束后运行的功能,将其指定为没有输入参数的函数的句柄。您可以编写此功能以清理工作空间或在模拟终止后执行其他处理。

Object Functions

sim 在指定环境中模拟训练有素的加固学习剂

Examples

collapse all

创建一个选项集,以模拟增强学习环境。将模拟的步骤数设置为1000,并配置选项以运行三个模拟。

创建选项集时,您可以使用名称,值对设置选项。您未明确设置的任何选项都有其默认值。

simopts= rlSimulationOptions(...“ maxsteps',1000,...'NumSimulations',3)
simopts =带有属性的rlSimulationOptions:maxSteps:1000数字:3 potonError:“ on” useParallel:0 parallealize options:[1x1 rl.option.parallelsimimulation]

或者,创建一个默认选项集并使用点符号来更改某些值。

simopts = rlSimulationOptions;simopts.maxsteps = 1000;simopts.numsimulations = 3;simopts
simopts =带有属性的rlSimulationOptions:maxSteps:1000数字:3 potonError:“ on” useParallel:0 parallealize options:[1x1 rl.option.parallelsimimulation]

版本历史

Introduced in R2019a

See Also