question

Willie avatar image
0 Likes"
Willie asked Willie edited

DQN only use discrete action space

I am using MultiDiscrete in the action space, and the PPO algorithm is running correctly.

However, when I used DQN, it seems that DQN does not support MultiDiscrete action space.

Is it possible to convert MultiDiscrete to Discrete action space?

Thank you for your advise or the other method in advance.


1740568160325.png1740569324259.png


FlexSim 23.0.15
reinforcement learningdqnactionspacemultidiscrete
1740568160325.png (31.5 KiB)
1740569324259.png (6.1 KiB)
smalldemo.fsm (87.4 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Nil Ns avatar image
0 Likes"
Nil Ns answered Nil Ns commented

Hey Willie,

Yes, it's definitely possible to convert a MultiDiscrete action space into a Discrete one by combining OP1 and OP2 into a single value. Basically, you treat each combination of OP1 and OP2 as a unique action in a Discrete space.

For example, if OP1 has 10 (1,2,3...) possible values and OP2 has 5 possible values, you can map each pair (OP1, OP2) to a single discrete index using:


  1. //MultiDiscrete to Discrete
  2. int Op1 = 7;
  3. int Op2 = 4;
  4. int nOp2 = 5; // Num of posible actions of Op2
  5. return Op1 * nOp2 + Op2; //the Discret input
  6.  
  1. //Discrete to MultiDiscrete
  2. int answer = 39;
  3. int nOp2 = 5;
  4.  
  5. int OP1 = Math.floor(answer / nOp2 );
  6. int OP2 = Math.fmod(answer ,nOp2);
  7. return OP1 + "" + OP2;


This makes it possible to use DQN, but to be honest, it’s not the most efficient way. DQN treats each action as an independent choice, so combining multiple actions into one number can make it harder for the model to recognize patterns. This often leads to longer training times and more complex learning.

Since PPO is already working well for you, I'd recommend sticking with it if possible. But if DQN is a must, this method will get the job done—it just might take more effort to train.

Hope this helps!

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.