rlPredefinedEnv - Create a predefined reinforcement learning environment - MATLAB (original) (raw)

Main Content

Create a predefined reinforcement learning environment

Syntax

Description

[env](#mw%5F8e0314b4-a921-45c6-9053-83a95fb4e4de%5Fsep%5Fmw%5F2f5d6ab3-a323-439f-8cf5-dd63b3ba5e01) = rlPredefinedEnv([keyword](#mw%5F8e0314b4-a921-45c6-9053-83a95fb4e4de%5Fsep%5Fmw%5Fce7c0a55-fd51-47fb-ba50-bcbce7b830d4)) takes a predefined keyword keyword representing the environment name to create a MATLAB® or Simulink® reinforcement learning environment env. The environmentenv models the dynamics with which the agent interacts, generating rewards and observations in response to agent actions.

example

Examples

collapse all

Basic Grid World Reinforcement Learning Environment

Use the predefined "BasicGridWorld" keyword to create a basic grid world reinforcement learning environment.

env = rlPredefinedEnv("BasicGridWorld")

env = rlMDPEnv with properties:

   Model: [1x1 rl.env.GridWorld]
ResetFcn: []

Continuous Double Integrator Reinforcement Learning Environment

Use the predefined "DoubleIntegrator-Continuous" keyword to create a continuous double integrator reinforcement learning environment.

env = rlPredefinedEnv("DoubleIntegrator-Continuous")

env = DoubleIntegratorContinuousAction with properties:

         Gain: 1
           Ts: 0.1000
  MaxDistance: 5
GoalThreshold: 0.0100
            Q: [2x2 double]
            R: 0.0100
     MaxForce: Inf
        State: [2x1 double]

You can visualize the environment using the plot function and interact with it using the reset and step functions.

plot(env) observation = reset(env)

[observation,reward,isDone] = step(env,16)

Figure Double Integrator Visualizer contains an axes object. The axes object contains an object of type rectangle.

observation = 2×1

4.0800
1.6000

Create Continuous Simple Pendulum Model Environment

Use the predefined "SimplePendulumModel-Continuous" keyword to create a continuous simple pendulum model reinforcement learning environment.

env = rlPredefinedEnv("SimplePendulumModel-Continuous")

env = SimulinkEnvWithAgent with properties:

       Model : rlSimplePendulumModel
  AgentBlock : rlSimplePendulumModel/RL Agent
    ResetFcn : []

UseFastRestart : on

Input Arguments

collapse all

keyword — Predefined keyword representing the environment name

"BasicGridWorld" | "CartPole-Discrete" | "DoubleIntegrator-Continuous" | "SimplePendulumWithImage-Discrete" | "SimplePendulumModel-Discrete" | "SimplePendulumModel-Continuous" | "CartPoleSimscapeModel-Continuous" | ...

Predefined keyword representing the environment name, specified as one of the following:

MATLAB Environment

Simulink Environment

Output Arguments

collapse all

rlMDPEnv object | CartPoleDiscreteAction object | CartPoleContinuousAction object | DoubleIntegratorDiscreteAction object | DoubleIntegratorContinuousAction object | SimplePendlumWithImageDiscreteAction object | SimplePendlumWithImageContinuousAction object | SimulinkEnvWithAgent object

MATLAB or Simulink environment object, returned as one of the following:

Version History

Introduced in R2019a

See Also

Topics