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

Improve Gym integration #16

Closed
BDonnot opened this issue Dec 31, 2019 · 4 comments
Closed

Improve Gym integration #16

BDonnot opened this issue Dec 31, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@BDonnot
Copy link
Collaborator

BDonnot commented Dec 31, 2019

I think it's now time to add a full gym integration (and dependency) for the environment (that is almost done already) but also for observation and action spaces.

This would mean introducing the gym framework as a dependency and check for license first.

This would also make some use of other RL methods easier.

@BDonnot BDonnot added the enhancement New feature or request label Dec 31, 2019
BDonnot added a commit that referenced this issue Apr 9, 2020
Rewards, Unitary actions, Smart reconnecting & Bug fixes
@BDonnot
Copy link
Collaborator Author

BDonnot commented Jul 8, 2020

For information, to get a "gym" observation space, you can get the following:

import grid2op
from gym import spaces
env = grid2op.make(...)
gym_observation_space = spaces.Dict({attr_nm: spaces.Box(low=-np.inf, high=np.inf, shape=(sh,), dtype=dt) 
                                                               for attr_nm, sh, dt in 
                                      zip(env.observation_space._empty_obs.attr_list_vect, 
                                           env.observation_space.shape, 
                                            env.observation_space.dtype)})

@BDonnot BDonnot pinned this issue Jul 13, 2020
@Tezirg Tezirg unpinned this issue Jul 17, 2020
@ZyOjV
Copy link

ZyOjV commented Jul 21, 2020

Please include gym in the competition container

@BDonnot
Copy link
Collaborator Author

BDonnot commented Aug 3, 2020

@Kronos9247 Hello :-)

Gym has been added in the competition container (in version 0.17.2).

Also you might want to check out the documentation at https://grid2op.readthedocs.io/en/latest/#compatibility-with-openai-gym that presents the classes we added for improving compatibility with Gym :-)

Don't hesitate to let us know if you need anything

All of that is available for grid2op 1.2.0

Benjamin

@BDonnot
Copy link
Collaborator Author

BDonnot commented Nov 13, 2020

As of grid2op 1.3.1 the module "grid2op.gym_compat" has been introduced.

import grid2op
from grid2op.gym_compat import GymEnv

env_name = ...
env = grid2op.make(env_name)
gym_env = GymEnv(env)  # is a gym environment properly inheriting from gym.Env !

There are lots of possibilities to modify the encoding of the action space or the observation. Do not hesitate to check out https://grid2op.readthedocs.io/en/latest/gym.html for more information

@BDonnot BDonnot closed this as completed Nov 13, 2020
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