Answers.Body: <p>I was thinking this strategy may work.</p>
  <p>So, Q-learning takes vector input as state representation let's say your vector has n dimensions i.e. [<span class="math-container">$n_0$</span>, <span class="math-container">$n_1$</span>, <span class="math-container">$n_2$</span>,..., <span class="math-container">$n_{n-1}$</span>]</p>
  <p>Now, from my interpretation you want to populate a matrix with 0 and 1's given the state vector but action-space has a high complexity e.g. an 8*8 matrix has 64 cells i.e. <span class="math-container">$2^{64}$</span> possible actions if you want the action to be a matrix.</p>
  <p>I suggest this:</p>
  <p>Fill each cell, one at a time. i.e. Your agent has only two possible action 0 and 1.
  To indicate to your agent that you are at a specific cell, concatenate the row and column number to the state vector before passing it as input to the Q-learning agent.</p>
  <p>Example:</p>
  <p>If you original state-vector is [55, 22, 100, 4] and you have to fill cell at position (10, 30) of the matrix, the state-vector should be modified as follows:
  [55, 22, 100, 4, 10, 30].</p>
  <p>I'm not sure of the sample-efficiency of this approach though.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-18T00:55:31.130Z
Answers.LastActivityDate: 2020-10-18T00:55:31.130Z
Answers.UserDisplayName: rert588
Body: <p>I have a 2-dimentional matrix as an action space, the rows being a resource to be allocated, and the columns are the users that we will allocate the resources to. (I built my own RL environment)</p>
  <p>The possible actions are 'Zero' or 'One'. One if the resource was allocated to the user, Zero if not.</p>
  <p>I have a constraint related to the resource allocation, which states that each resource can be allocated to one user only, and the resource should only be allocated to users who have requested a resource to be allocated to them, and that would be the state space which is another matrix.</p>
  <p>A penalty would be applied if the agent violates the constraints and the episode would end and the reward would equal the penalty. Otherwise, the reward would equal the sum of all the users that were satisfied with the allocation.</p>
  <p>I am struggling with the implementation. The agent starts by exploring, then little by little it starts exploiting. When it gets to be more exploitative, I've noticed that the action matrix's values are all set to 'One', and the penalty always has the same value from episode to episode.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-17T15:45:36.577Z
Comments.Text: How does the state space evolve? If it is fixed for an episode, or changes independenty of actions taken, then this seems more like a contextual bandit scenario than full RL. It may also be better resolved as a constraint optimisation problem using a different tool to RL, so could you clairfy whether the point here is to solve the problem or learn RL?
Comments.UserDisplayName: Neil Slater
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-10-17T18:06:49.207Z
Comments.Text: could you give an example ? Initial data and optimal solution.
Comments.UserDisplayName: pasaba por aqui
Tags: <reinforcement-learning><python><q-learning>
Title: How to create a Q-Learning agent when we have a matrix as an action space?
UserDisplayName: Ness
ThreadText: # How to create a Q-Learning agent when we have a matrix as an action space?
  
  (Asked by: username_0 on 2020-10-17)
  
  I have a 2-dimentional matrix as an action space, the rows being a resource to be allocated, and the columns are the users that we will allocate the resources to. (I built my own RL environment)
  
  The possible actions are 'Zero' or 'One'. One if the resource was allocated to the user, Zero if not.
  
  I have a constraint related to the resource allocation, which states that each resource can be allocated to one user only, and the resource should only be allocated to users who have requested a resource to be allocated to them, and that would be the state space which is another matrix.
  
  A penalty would be applied if the agent violates the constraints and the episode would end and the reward would equal the penalty. Otherwise, the reward would equal the sum of all the users that were satisfied with the allocation.
  
  I am struggling with the implementation. The agent starts by exploring, then little by little it starts exploiting. When it gets to be more exploitative, I've noticed that the action matrix's values are all set to 'One', and the penalty always has the same value from episode to episode.
  
  **Tags:** reinforcement-learning, python, q-learning
  
  > **Comments:**
  > **username_1**: How does the state space evolve? If it is fixed for an episode, or changes independenty of actions taken, then this seems more like a contextual bandit scenario than full RL. It may also be better resolved as a constraint optimisation problem using a different tool to RL, so could you clairfy whether the point here is to solve the problem or learn RL?  
  > **username_2**: could you give an example ? Initial data and optimal solution.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2020-10-18. Score: 0
  
  I was thinking this strategy may work.
  
  So, Q-learning takes vector input as state representation let's say your vector has n dimensions i.e. [$n\_0$, $n\_1$, $n\_2$,..., $n\_{n-1}$]
  
  Now, from my interpretation you want to populate a matrix with 0 and 1's given the state vector but action-space has a high complexity e.g. an 8\*8 matrix has 64 cells i.e. $2^{64}$ possible actions if you want the action to be a matrix.
  
  I suggest this:
  
  Fill each cell, one at a time. i.e. Your agent has only two possible action 0 and 1.
  To indicate to your agent that you are at a specific cell, concatenate the row and column number to the state vector before passing it as input to the Q-learning agent.
  
  Example:
  
  If you original state-vector is [55, 22, 100, 4] and you have to fill cell at position (10, 30) of the matrix, the state-vector should be modified as follows:
  [55, 22, 100, 4, 10, 30].
  
  I'm not sure of the sample-efficiency of this approach though.
  
  
  ---
  
  