getActionInfo
Obtain action data specifications from reinforcement learning environment, agent, or experience buffer
Description
Examples
Extract Action and Observation Specifications from Reinforcement Learning Environment
The reinforcement learning environment for this example is a longitudinal dynamics model comprising two cars, a leader and a follower. The vehicle model is also used in the Adaptive Cruise Control System Using Model Predictive Control (Model Predictive Control Toolbox) example.
Open the model.
mdl = "rlACCMdl";
open_system(mdl);
Specify path to the agent block in the model.
agentblk = mdl + "/RL Agent";
Create the observation and action specifications.
% Observation specifications obsInfo = rlNumericSpec([3 1],LowerLimit=-inf*ones(3,1),UpperLimit=inf*ones(3,1)); obsInfo.Name = "observations"; obsInfo.Description = "information on velocity error and ego velocity"; % Action specifications actInfo = rlNumericSpec([1 1],LowerLimit=-3,UpperLimit=2); actInfo.Name = "acceleration";
Define environment interface.
env = rlSimulinkEnv(mdl,agentblk,obsInfo,actInfo)
env = SimulinkEnvWithAgent with properties: Model : rlACCMdl AgentBlock : rlACCMdl/RL Agent ResetFcn : [] UseFastRestart : on
The reinforcement learning environment env
is a SimulinkEnvWithAgent
object.
Extract the action and observation specifications from env
.
actInfoExt = getActionInfo(env)
actInfoExt = rlNumericSpec with properties: LowerLimit: -3 UpperLimit: 2 Name: "acceleration" Description: [0x0 string] Dimension: [1 1] DataType: "double"
obsInfoExt = getObservationInfo(env)
obsInfoExt = rlNumericSpec with properties: LowerLimit: [3x1 double] UpperLimit: [3x1 double] Name: "observations" Description: "information on velocity error and ego velocity" Dimension: [3 1] DataType: "double"
The action information contains acceleration values while the observation information contains the velocity and velocity error values of the ego vehicle.
Input Arguments
env
— Reinforcement learning environment
rlFunctionEnv
object | SimulinkEnvWithAgent
object | rlNeuralNetworkEnvironment
object | predefined MATLAB environment object
Reinforcement learning environment from which to extract the action information, specified as one of the following:
MATLAB® environment represented as one of the following objects.
Predefined MATLAB environment created using
rlPredefinedEnv
Simulink® environment represented as a
SimulinkEnvWithAgent
object.
For more information on reinforcement learning environments, see Reinforcement Learning Environments and Create Custom Simulink Environments.
agent
— Reinforcement learning agent
rlQAgent
object | rlSARSAAgent
object | rlDQNAgent
object | rlPGAgent
object | rlDDPGAgent
object | rlTD3Agent
object | rlACAgent
object | rlPPOAgent
object | rlTRPOAgent
object | rlSACAgent
object | rlMBPOAgent
object
Reinforcement learning agent from which to extract the action information, specified as one of the following objects.
For more information on reinforcement learning agents, see Reinforcement Learning Agents.
buffer
— Experience buffer
rlReplayMemory
object | rlPrioritizedReplayMemory
object | rlHindsightReplayMemory
object | rlHindsightPrioritizedReplayMemory
object
Experience buffer, specified as one of the following replay memory objects.
Output Arguments
actInfo
— Action specification
rlNumericSpec
object | rlFiniteSetSpec
object | vector containing one rlFiniteSetSpec
followed by one
rlNumericSpec
object
Action specification, returned as one of the following:
One
rlNumericSpec
object (for continuous action spaces)One
rlFiniteSetSpec
object (for discrete action spaces)A vector consisting of one
rlFiniteSetSpec
followed by onerlNumericSpec
object (for hybrid action spaces)
The action specification defines the properties of the environment action channel, such as its dimensions, data type, and name.
Note
For non-hybrid action spaces (either discrete or continuous) or only one action channel is allowed. Environments with hybrid action spaces have two action channels, the first one for the discrete part of the action, the second one for the continuous part of the action.
The action specifications object defines the properties of the environment action channel, such as its dimensions, data type, and name.
Version History
Introduced in R2019a
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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)