Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reason for Space wrapper? #8

Closed
zsunberg opened this issue Jul 27, 2022 · 4 comments
Closed

Reason for Space wrapper? #8

zsunberg opened this issue Jul 27, 2022 · 4 comments

Comments

@zsunberg
Copy link
Member

Hey @findmyway, thanks for getting started on this package.

@jamgochiana and I are trying to improve the continuous action space support in POMDPs.jl and we're hoping to use some version of this package.

I like the idea of defining some traits to communicate about properties of the spaces. But I am wondering what the purpose of the Space wrapper is. Why don't we just allow people to use normal Vectors or Tuples and then define the traits for those objects directly? i.e.

SpaceStyle(::AbstractVector) = DiscreteSpaceStyle{()}()
@findmyway
Copy link
Member

Hello @zsunberg ,

But I am wondering what the purpose of the Space wrapper is.

It is to support some complicated state/action spaces.

Let's say we have an environment of action space of ((:left, :top), (false, true)). Now we want to sample one random action from it. But what's the result? Is it one of (:left, :top) and (false, true), or is it one of (:left, false), (:left, true), (:top, false), (:top, true)?

To avoid such confusion, the Space wrapper is added to explicitly distinguish between such two cases.

For the former, we use Space(((:left, :top), (false, true))), for the later we use (Space((:left, :top)), Space((false, true))).

Another way to address such confusion is to define dedicated space types, like TupleSpace, VectorSpace or DictSpace. Personally I feel this approach is a bit redundant. However, that's just based on my limited programming experience.

Why don't we just allow people to use normal Vectors or Tuples and then define the traits for those objects directly?

I think we can add the support for some common element types (Number, String, Symbol, etc) like you proposed above. So that for some common spcaes, users don't need create the Space wrapper at all. What do you think?

@zsunberg
Copy link
Member Author

zsunberg commented Jul 28, 2022

What if we get rid of Space and define the elements of a space to be all objects x for which x in space returns true. This eliminates the ambiguity. union and rand would also work nicely with this.

We could also introduce product (or setproduct or cartesian_product) to accomplish what you were thinking with (Space((:left, :top)), Space((false, true))).

What do you think? I am going to start a PR with this so we can discuss.

@findmyway
Copy link
Member

What if we get rid of Space and define the elements of a space to be all objects x for which x in space returns true. This eliminates the ambiguity. union and rand would also work nicely with this.

Yes, But then we may need to figure out how to handle continuous spaces.

What do you think? I am going to start a PR with this so we can discuss.

That'd be great!

@zsunberg
Copy link
Member Author

zsunberg commented Aug 9, 2022

closed with #9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants