-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[RLlib] MultiAgentEnv API enhancements (related to defining obs-/action spaces for agents). #47830
[RLlib] MultiAgentEnv API enhancements (related to defining obs-/action spaces for agents). #47830
Conversation
Signed-off-by: sven1977 <[email protected]>
…i_agent_env_space_enhancements
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. We should test, if checkpointing runs error-free with these changes. I don't see an obvious problem, but let's quickly check this.
def render(self) -> None: | ||
"""Tries to render the environment.""" | ||
@property | ||
def num_agents(self) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!!
# By default, do nothing. | ||
pass | ||
@property | ||
def max_num_agents(self) -> int: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might also help in the sampling from MultiAgentEpisodeBuffers
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…i_agent_env_space_enhancements
Signed-off-by: sven1977 <[email protected]>
…i_agent_env_space_enhancements
Signed-off-by: sven1977 <[email protected]>
…i_agent_env_space_enhancements
Signed-off-by: sven1977 <[email protected]>
Signed-off-by: sven1977 <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
…on spaces for agents). (ray-project#47830) Signed-off-by: ujjawal-khare <[email protected]>
MultiAgentEnv API enhancements (related to defining obs-/action spaces for agents).
The
MultiAgentEnv
API gets the following face-lift:get_observation_space(agent_id=...)
method, which is the only path that RLlib will use to get an agent's space.MultiAgentEnv
and always return the correct (single-agent) space for the givenagent_id
. This relieves one from having to include all agent IDs in the agent-to-space dict. In fact, you don't even have to define such a dict anymore at all.get_observation_space()
, one can defineself.observation_spaces
(plural!) to be a dict mapping AgentIDs to individual spaces (<- currently the only supported mechanism).get_observation_space()
, one can defineself.observation_space
(singular!) to be a single observation space that applies to all agents in the env (<- "lazy" mechanism for when all agents have the same space anyways).^ Exact same for action spaces.
On top of that, to make things more explicit and more similar to
PettingZoo
, we should also require users to provide the two attributes in theirMultiAgentEnv
The method
self.get_agent_ids()
will be deprecated soon (replaced byself.agents
orself.possible_agents
).The private attribute
self._agent_ids
will be deprecated soon (replaced byself.agents
orself.possible_agents
).Why are these changes needed?
Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.