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

[Proposal] AsyncVectorEnv with Graph observation spaces #1162

Open
1 task done
ramondalmau opened this issue Sep 17, 2024 · 1 comment
Open
1 task done

[Proposal] AsyncVectorEnv with Graph observation spaces #1162

ramondalmau opened this issue Sep 17, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ramondalmau
Copy link

Proposal

Add support for environments with Graph observation spaces in AsyncVectorEnv in Gymnasium. Currently, AsyncVectorEnv assumes observations can be stacked in a typical array-like format. However, environments that return graph-based observations (e.g., adjacency matrices, node/edge features) are incompatible with the default vectorized operations. This proposal seeks to introduce native support for vectorizing such environments, allowing the parallelization of environments that utilize Graph-like spaces for their observations.

Motivation

The current limitation of AsyncVectorEnv is that it can only handle environments with simple observation spaces. For graphs (e.g., adjacency matrices or node/edge data), the default handling of observation stacking fails, leading to errors and the inability to utilize vectorized environments.

Pitch

Modify AsyncVectorEnv to natively handle observation spaces that are graph-structured, by allowing users to define custom stacking or returning observations as lists of graphs instead of arrays. This could be done via:

  • Adding a specific check for Graph-type spaces in the observation stacking method.
  • Providing an option for environments with complex observations to return observations as lists, or by defining a custom merging mechanism for such spaces.

Alternatives

No response

Additional context

Many modern reinforcement learning tasks involve graph-structured data, particularly in domains such as networked systems, biology, and operations research. A robust way to handle graph-based environments in a vectorized setup would greatly enhance Gymnasium's flexibility and application scope.

Additionally, this proposal would align with Gymnasium's mission to support a wide range of environment types, particularly as more graph-based tasks emerge in reinforcement learning.

Checklist

  • I have checked that there is no similar issue in the repo
@ramondalmau ramondalmau added the enhancement New feature or request label Sep 17, 2024
@pseudo-rnd-thoughts
Copy link
Member

With AsyncVectorEnv(..., shared_memory=True) then it is required that the observations have a fixed shape.
There are two options,

  1. disable shared memory - turning off shared memory will allow dynamic observation shapes
  2. fixed shape graph instances - we could add a feature such that observations have a fixed number of nodes (and thus edges)

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

No branches or pull requests

2 participants