# Continuous action space array

**URL:** <https://discourse.julialang.org/t/continuous-action-space-array/62515>\
**Category:** Machine Learning\
**Tags:** question, machine-learning\
**Created:** [June 7, 2021, 1:27pm UTC](https://discourse.julialang.org/t/continuous-action-space-array/62515 "2021-06-07T13:27:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GK\_197](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@GK\_197](https://discourse.julialang.org/u/GK_197)\
**Post date:** [June 7, 2021, 1:27pm UTC](https://discourse.julialang.org/t/continuous-action-space-array/62515/1 "2021-06-07T13:27:40Z")

</div>

Hi, I have a question regarding implementation of multidimensional array in continuous action spaces.  
I am trying to implement DDPG algorithm for a problem which requires action space in 1-D vector.

```julia
A = [ClosedInterval{Int64}(0,BUDGET)] #range of value of actions in 0..Budget 
A_space = repeat(A,length(CHANNELS)) #range of values for diff channels

RLBase.action_space(env::Environment, p::DefaultPlayer) = Space(A_space)

```

I am confused, how should I implement the above correctly, so i can get an action vector which i can clamp (for legal values) later during steps?

Any help or suggestion on how this is usually done is appreciated! 😃

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 7, 2021, 4:12pm UTC](https://discourse.julialang.org/t/continuous-action-space-array/62515/2 "2021-06-07T16:12:54Z")

</div>

First if all, welcome to our community! 🎊

I am not sure I understood what you are asking, I would suggest you to give an MWE (i.e., an excerpt of code that is executable, your code does not define ClosedInterval) and make clearer what do you mean by “clamp”.

---

<div class="post-metadata">

**Author:** ![GK\_197](https://avatars.discourse-cdn.com/v4/letter/g/ba9def/32.png) [@GK\_197](https://discourse.julialang.org/u/GK_197)\
**Post date:** [June 8, 2021, 4:48am UTC](https://discourse.julialang.org/t/continuous-action-space-array/62515/3 "2021-06-08T04:48:41Z")

</div>

Thanks for warm welcome!  
So, the problem is as follows :  
when we have discrete action space we use

`action_space = Base.OneTo(n_actions)`

where n\_actions means number of discrete actions (on or off etc)

when we are in continuous action space, so far i have only found code for one continuous variable i.e.,

`action_space = -2.0..2.0`  
where the variable can have actions from -2 to 2 continuous.

But now instead of having one variable as continuous i need a vector of 3 elements to be in continuous space, all with range -2 to 2.  
This is my question as how should i implement a vector for continuous space.  
PS - by clamp i just meant to put a constraint on the range of the action vector.

---

<div class="post-metadata">

**Author:** ![findmyway](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/findmyway/32/4946_2.png) [@findmyway](https://discourse.julialang.org/u/findmyway)\
**Post date:** [June 8, 2021, 5:30am UTC](https://discourse.julialang.org/t/continuous-action-space-array/62515/4 "2021-06-08T05:30:50Z")

</div>

You can simply create something like this: `Space([-2.0..2.0, -1..1])`

We may have a specialized type for it later:

> <https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issues/268>
>
> Ref: https://github.com/JuliaReinforcementLearning/ReinforcementLearning.jl/issu…es/257#issuecomment-831710404
