MATLAB: Specifying Actions using rlFiniteSetSpec or rlNumericSpec (Reinforcement Learning)

q-learningreinforcement learningReinforcement Learning Toolbox

I understand that I can use CreateGridWorld for a Grid Maze environment for reinforcement learning. However, when creating my own, I have to specify the action settings using either rlFiniteSetSpec or rlNumericSpec. How am I to specify them if my actions are 4 (U, D, L, R). Any suggestions and help would be much appreciated!

Best Answer

Hi Huzaifah,
It is my understanding that have 4 actions (U, D, L, R) and want to specify them in your RL agent.
Generally, rlNumericSpec is used when you have a continuous action space and rlFiniteSetSpec is used when you have a discrete action space.
In your case, the action space is discrete. So, you should go with rlFiniteSetSpec.
As rlFiniteSetSpec takes only numeric input, you have to encode your actions to numbers. For example, (U,D,L,R) -> (1,2,3,4)
>> actInfo = rlFiniteSetSpec([1,2,3,4])
actInfo =
rlFiniteSetSpec with properties:
Elements: [4×1 double]
Name: [0×0 string]
Description: [0×0 string]
Dimension: [1 1]
DataType: "double"