# What is the alternative to Python gym.spaces.Box() in Julia?

**URL:** https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758
**Category:** General Usage
**Tags:** intervals
**Created:** [January 3, 2021, 5:37am UTC](https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758 "2021-01-03T05:37:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ZdM87](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zdm87/32/15353_2.png) [@ZdM87](https://discourse.julialang.org/u/ZdM87)
#### Post date: [January 3, 2021, 5:37am UTC](https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758/1 "2021-01-03T05:37:50Z")

</div>

In Python gym’s there is a class called Box that defines a (possibly unbounded) box in `R^n`. Is there any alternative to this box in Julia?

There is `IntervalSets.jl` but I cannot seem to be able to create a Cartesian product of different intervals like `[0,200]x[0,200]x[0,1]x[0,2]`.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [January 3, 2021, 6:31am UTC](https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758/2 "2021-01-03T06:31:07Z")

</div>

There’s

```julia
julia> using IntervalArithmetic

julia> X = (1..2) × (3..4) × (10..∞)
[1, 2] × [3, 4] × [10, ∞]

julia> typeof(X)
IntervalBox{3, Float64}

```

from the [IntervalArithmetic.jl](https://github.com/JuliaIntervals/IntervalArithmetic.jl/) package (of which I am an author).

Also check out [DomainSets.jl](https://github.com/JuliaApproximation/DomainSets.jl) and [LazySets.jl](https://github.com/JuliaReach/LazySets.jl)

EDIT: It would also be not to hard to make a type like this yourself. It rather depends what you want to then do with it.

---

<div class="post-metadata">

### Author: ![mforets](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mforets/32/298_2.png) [@mforets](https://discourse.julialang.org/u/mforets)
#### Post date: [January 3, 2021, 12:52pm UTC](https://discourse.julialang.org/t/what-is-the-alternative-to-python-gym-spaces-box-in-julia/52758/3 "2021-01-03T12:52:06Z")

</div>

[LazySets.Hyperrectangle](https://juliareach.github.io/LazySets.jl/dev/lib/sets/Hyperrectangle/#LazySets.Hyperrectangle) accepts `low` and `high` keyword arguments in the constructor, similar to `gym.spaces.Box()`, although it is only for bounded sets (if you require to use unbounded sets there are other types, such as [LazySets.HPolyhedron](https://juliareach.github.io/LazySets.jl/dev/lib/sets/HPolyhedron/)).

```julia
julia> using LazySets

julia> X = Hyperrectangle(low=[0, 0, 0, 0.], high=[200, 200, 1, 2.])
Hyperrectangle{Float64,Array{Float64,1},Array{Float64,1}}([100.0, 100.0, 0.5, 1.0], [100.0, 100.0, 0.5, 1.0])

julia> isbounded(X)
true

```

* * *

I had a look at gym’s [Box](https://github.com/openai/gym/blob/master/gym/spaces/box.py) Python class; you will find that such functionality (random sampling, membership, inclusion checks) is available in Julia too.
