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

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].


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 package (of which I am an author).

Also check out DomainSets.jl and 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.


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).

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)

I had a look at gym’s Box Python class; you will find that such functionality (random sampling, membership, inclusion checks) is available in Julia too.