主要内容

rlNumericSpec

创造continuous action or observation data specifications for reinforcement learning environments

Description

AnrlNumericSpecobject specifies continuous action or observation data specifications for reinforcement learning environments.

Creation

Description

example

spec= rlNumericSpec(方面)creates a data specification for continuous actions or observations and sets theDimensionproperty.

spec= rlNumericSpec(方面,Name,Value)setsPropertiesusing name-value pair arguments.

Properties

expand all

Lower limit of the data space, specified as a scalar or matrix of the same size as the data space. When下限is specified as a scalar,rlNumericSpec将其应用于数据空间中的所有条目。

Upper limit of the data space, specified as a scalar or matrix of the same size as the data space. WhenUpperLimitis specified as a scalar,rlNumericSpec将其应用于数据空间中的所有条目。

的名字rlNumericSpecobject, specified as a string.

Description of therlNumericSpecobject, specified as a string.

This property is read-only.

数据空间的维度,指定为数字向量。

This property is read-only.

有关数据类型的信息, specified as a string.

Object Functions

rlSimulinkEnv 使用实施的动态模型创建强化学习环境金宝app
rlfunctionenv Specify custom reinforcement learning environment dynamics using functions
rlRepresentation (Not recommended) Model representation for reinforcement learning agents

Examples

collapse all

对于这个示例,考虑rlSimplePendulumModel金宝appSimulink模型。该模型是一种简单的无摩擦摆,最初悬挂在向下的位置。

Open the model.

mdl ='rlsimplependulummodel'; open_system(mdl)

创造rlNumericSpecrlFiniteSetSpec观察和行动信息的对象。

obsinfo = rlnumericspec([3 1])3个观测值的矢量​​:sin(theta),cos(theta),d(theta)/dt
obsInfo = rlNumericSpec with properties: LowerLimit: -Inf UpperLimit: Inf Name: [0x0 string] Description: [0x0 string] Dimension: [3 1] DataType: "double"
actInfo = rlFiniteSetSpec([-2 0 2])% 3 possible values for torque: -2 Nm, 0 Nm and 2 Nm
actInfo = rlFiniteSetSpec with properties: Elements: [3x1 double] Name: [0x0 string] Description: [0x0 string] Dimension: [1 1] DataType: "double"

You can use dot notation to assign property values for therlNumericSpecrlFiniteSetSpecobjects.

obsInfo.Name ='observations'; actInfo.Name ='torque';

Assign the agent block path information, and create the reinforcement learning environment for the Simulink model using the information extracted in the previous steps.

AgentBlk = [MDL' / RL代理']; env = rlSimulinkEnv(mdl,agentBlk,obsInfo,actInfo)
env = SimulinkEnvWithAgent with properties: Model : rlSimplePendulumModel AgentBlock : rlSimplePendulumModel/RL Agent ResetFcn : [] UseFastRestart : on

You can also include a reset function using dot notation. For this example, randomly initializetheta0in the model workspace.

env.ResetFcn = @(in) setVariable(in,'theta0',randn,'Workspace',MDL)
env = SimulinkEnvWithAgent with properties: Model : rlSimplePendulumModel AgentBlock : rlSimplePendulumModel/RL Agent ResetFcn : @(in)setVariable(in,'theta0',randn,'Workspace',mdl) UseFastRestart : on

版本History

Introduced in R2019a