Can someone please show me how to implement the stepfunction in Reinforcement Learning environment using "ActionVectors" in a continous action space (rlNumericSpec)?

4 次查看(过去 30 天)
I am currently trying to implement Reinforcment Learning over an environment with 6 continous actions. I tried to implement the stepfunction set in the example but I got a dimensionality error in the input variable "Action". I realized I need to implement a customized stepfunction with another input variable called "ActionVectors"(You can check the implementation of this variable with rlFiniteSpec action in the finance code). So, can someone provide me with an example that uses "ActionVectors" when actions are defined as rlNumericSpec ?

回答(1 个)

Shubham
Shubham 2024-2-13
Hi Mohamed,
To resolve the dimensionality error in your MATLAB Reinforcement Learning environment when using rlNumericSpec for continuous actions, follow these steps:
  1. Define the Action Space Correctly: Use rlNumericSpec to define the continuous action space accurately, specifying the number of actions and their respective lower and upper bounds.
  2. Customize the Step Function: Write a custom step function that accepts an action input argument with the correct dimensionality. This step function should take into account the action vector provided by the RL agent, which will have the same dimensions as specified by your rlNumericSpec.
  3. Implement Action Processing: Inside the step function, process the input action vector to determine the next state of the environment, calculate the reward, and decide if the episode is done.
  4. Ensure Consistency: Make sure that the action vector passed to the step function by the RL agent during training or simulation matches the dimensions specified by your rlNumericSpec. Typically, this vector will be a column vector where each element represents a continuous action.
  5. Create the Environment Interface: Use rlFunctionEnv or a similar function to create the environment interface, providing the custom step function, the observation space specification, and the action space specification.
  6. Train the RL Agent: Train your RL agent using the environment you've created. The agent will generate action vectors that conform to the action space specification, and these vectors will be passed to your custom step function during training.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by