createIntegratedEnv

Create Simulink model for reinforcement learning, using reference model as environment

Description

env = createIntegratedEnv(refModel,newModel) creates a Simulink® model with the name specified by newModel and returns a reinforcement learning environment object, env, for this model. The new model contains an RL Agent block and uses the reference model refModel as a reinforcement learning environment for training the agent specified by this block.

[env,agentBlock,obsInfo,actInfo] = createIntegratedEnv(___) returns the block path to the RL Agent block in the new model and the observation and action data specifications for the reference model, obsInfo and actInfo, respectively.

[___] = createIntegratedEnv(___,Name,Value) creates a model and environment interface using port, observation, and action information specified using one or more Name,Value pair arguments.

Input Arguments

collapse all

Reference model name, specified as a string or character vector. The new Simulink model uses this reference model as the dynamic model of the environment for reinforcement learning.

New model name, specified as a string or character vector. createIntegratedEnv creates a Simulink model with this name, but does not save the model.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'IsDonePortName',"stopSim" sets the stopSim port of the reference model as the source of the isdone signal.

Reference model observation output port name, specified as the comma-separated pair consisting of 'ObservationPortName' and a string or character vector. Specify ObservationPortName when the name of the observation output port of the reference model is not "observation".

Reference model action input port name, specified as the comma-separated pair consisting of 'ActionPortName' and a string or character vector. Specify ActionPortName when the name of the action input port of the reference model is not "action".

Reference model reward output port name, specified as the comma-separated pair consisting of 'RewardPortName' and a string or character vector. Specify RewardPortName when the name of the reward output port of the reference model is not "reward".

Reference model done flag output port name, specified as the comma-separated pair consisting of 'IsDonePortName' and a string or character vector. Specify IsDonePortName when the name of the done flag output port of the reference model is not "isdone".

Names of observation bus leaf elements for which to create specifications, specified as a string array. To create observation specifications for a subset of the elements in a Simulink bus object, specify BusElementNames. If you do not specify BusElementNames, a data specification is created for each leaf element in the bus.

ObservationBusElementNames is applicable only when the observation output port is a bus signal.

Example: 'ObservationBusElementNames',["sin" "cos"] creates specifications for the observation bus elements with the names "sin" and "cos".

Finite values for discrete observation specification elements, specified as the comma-separated pair consisting of 'ObservationDiscreteElements' and a cell array of name-value pairs. Each name-value pair consists of an element name and an array of discrete values.

If the observation output port of the reference model is:

The specified discrete values must be castable to the data type of the specified observation signal.

If you do not specify discrete values for an observation specification element, the element is continuous.

Example: 'ObservationDiscretElements',{'observation',[-1 0 1]} specifies discrete values for a nonbus observation signal with default port name observation.

Example: 'ObservationDiscretElements',{'gear',[-1 0 1 2],'direction',[1 2 3 4]} specifies discrete values for the 'gear' and 'direction' leaf elements of a bus action signal.

Finite values for discrete action specification elements, specified as the comma-separated pair consisting of 'ActionDiscreteElements' and a cell array of name-value pairs. Each name-value pair consists of an element name and an array of discrete values.

If the action input port of the reference model is:

  • A bus signal, specify the name of a leaf element of the bus

  • Nonbus signal, specify the name of the action port, as specified by ActionPortName

The specified discrete values must be castable to the data type of the specified action signal.

If you do not specify discrete values for an action specification element, the element is continuous.

Example: 'ActionDiscretElements',{'action',[-1 0 1]} specifies discrete values for a nonbus action signal with default port name 'action'.

Example: 'ActionDiscretElements',{'force',[-10 0 10],'torque',[-5 0 5]} specifies discrete values for the 'force' and 'torque' leaf elements of a bus action signal.

Output Arguments

collapse all

Reinforcement learning environment interface, returned as an SimulinkEnvWithAgent object.

Block path to the agent block in the new model, returned as a character vector. To train an agent in the new Simulink model, you must create an agent and specify the agent name in the RL Agent block indicated by agentBlock.

For more information on creating agents, see Reinforcement Learning Agents.

Observation data specifications, returned as one of the following:

  • rlNumericSpec object for a single continuous observation specification

  • rlFiniteSetSpec object for a single discrete observation specification

  • Array of data specification objects for multiple specifications

Action data specifications, returned as one of the following:

  • rlNumericSpec object for a single continuous action specification

  • rlFiniteSetSpec object for a single discrete action specification

  • Array of data specification objects for multiple action specifications

Introduced in R2019a