@@ -29,20 +29,20 @@ your base code.
2929
3030 More information on the section :ref: `gymnasium_gym `
3131
32- Before grid2op 1.2.0 only some classes fully implemented the open AI gym interface:
32+ Before grid2op 1.2.0 only some classes fully implemented the gymnasium interface:
3333
3434- the :class: `grid2op.Environment ` (with methods such as `env.reset `, `env.step ` etc.)
3535- the :class: `grid2op.Agent ` (with the `agent.act ` etc.)
3636- the creation of pre defined environments (with `grid2op.make `)
3737
3838
3939Starting from 1.2.0 we implemented some automatic converters that are able to automatically map
40- grid2op representation for the action space and the observation space into open AI gym "spaces". More precisely these
40+ grid2op representation for the action space and the observation space into gymnasium "spaces". More precisely these
4141are represented as gym.spaces.Dict.
4242
43- As of grid2op 1.4.0 we tighten the gap between openAI gym and grid2op by introducing the dedicated module
43+ As of grid2op 1.4.0 we tighten the gap between gymnasium and grid2op by introducing the dedicated module
4444`grid2op.gym_compat ` . Withing this module there are lots of functionalities to convert a grid2op environment
45- into a gym environment (that inherit `gym .Env ` instead of "simply" implementing the open ai gym interface).
45+ into a gymnasium environment (that inherit `gymnasium .Env ` instead of "simply" implementing the gymnasium interface).
4646
4747
4848A simple usage is:
@@ -55,12 +55,12 @@ A simple usage is:
5555 env_name = " l2rpn_case14_sandbox" # or any other grid2op environment name
5656 g2op_env = grid2op.make(env_name) # create the gri2op environment
5757
58- gym_env = GymEnv(g2op_env) # create the gym environment
58+ gym_env = GymEnv(g2op_env) # create the gymnasium environment
5959
60- # check that this is a properly defined gym environment:
60+ # check that this is a properly defined gymnasium environment:
6161 import gym
62- print (f " Is gym_env and open AI gym environment: { isinstance (gym_env, gym.Env)} " )
63- # it shows "Is gym_env and open AI gym environment: True"
62+ print (f " Is gym_env a gymnasium environment: { isinstance (gym_env, gym.Env)} " )
63+ # it shows "Is gym_env a gymnasium environment: True"
6464
6565 .. note ::
6666
@@ -73,9 +73,9 @@ A simple usage is:
7373.. warning ::
7474 The `gym ` package has some breaking API change since its version 0.26. We attempted,
7575 in grid2op, to maintain compatibility both with former versions and later ones. This makes **this
76- class behave differently depending on the version of gym you have installed ** !
76+ class behave differently depending on the version of gymnasium you have installed ** !
7777
78- The main changes involve the functions `env.step ` and `env.reset ` (core gym functions)
78+ The main changes involve the functions `env.step ` and `env.reset ` (core gymnasium functions)
7979
8080This page is organized as follow:
8181
@@ -164,7 +164,7 @@ You can transform the observation space as you wish. There are some examples in
164164
165165Default Action space
166166******************************
167- The default action space is also a type of gym Dict. As for the observation space above, it is a
167+ The default action space is also a type of gymnasium Dict. As for the observation space above, it is a
168168straight translation from the attribute of the action to the key of the dictionary. This gives:
169169
170170- "change_bus": MultiBinary(`env.dim_topo `)
@@ -177,7 +177,7 @@ straight translation from the attribute of the action to the key of the dictiona
177177- "raise_alarm": MultiBinary(`env.dim_alarms `)
178178- "raise_alert": MultiBinary(`env.dim_alerts `)
179179
180- For example you can create a "gym action" (for the default encoding) like:
180+ For example you can create a "gymnasium action" (for the default encoding) like:
181181
182182.. code-block :: python
183183
@@ -191,27 +191,27 @@ For example you can create a "gym action" (for the default encoding) like:
191191 gym_env = GymEnv(env)
192192
193193 seed = ...
194- obs, info = gym_env.reset(seed) # for new gym interface
194+ obs, info = gym_env.reset(seed) # for new gymnasium interface
195195
196196 # do nothing
197197 gym_act = {}
198198 obs, reward, done, truncated, info = gym_env.step(gym_act)
199199
200200 # change the bus of the element 6 and 7 of the "topo_vect"
201201 gym_act = {}
202- gym_act[" change_bus" ] = np.zeros(env.dim_topo, dtype = np.int8) # gym encoding of a multi binary
202+ gym_act[" change_bus" ] = np.zeros(env.dim_topo, dtype = np.int8) # gymnasium encoding of a multi binary
203203 gym_act[" change_bus" ][[6 , 7 ]] = 1
204204 obs, reward, done, truncated, info = gym_env.step(gym_act)
205205
206206 # redispatch generator 2 of 1.7MW
207207 gym_act = {}
208- gym_act[" redispatch" ] = np.zeros(env.n_gen, dtype = np.float32) # gym encoding of a Box
208+ gym_act[" redispatch" ] = np.zeros(env.n_gen, dtype = np.float32) # gymnasium encoding of a Box
209209 gym_act[" redispatch" ][2 ] = 1.7
210210 obs, reward, done, truncated, info = gym_env.step(gym_act)
211211
212212 # set the bus of element 8 and 9 to bus 2
213213 gym_act = {}
214- gym_act[" set_bus" ] = np.zeros(env.dim_topo, dtype = int ) # gym encoding of a Box
214+ gym_act[" set_bus" ] = np.zeros(env.dim_topo, dtype = int ) # gymnasium encoding of a Box
215215 gym_act[" set_bus" ][[8 , 9 ]] = 2
216216 obs, reward, done, truncated, info = gym_env.step(gym_act)
217217
@@ -238,7 +238,7 @@ If you want a full control on this spaces, you need to implement something like:
238238 env = grid2op.make(env_name)
239239
240240 from grid2op.gym_compat import GymEnv
241- # this of course will not work... Replace "AGymSpace" with a normal gym space, like Dict, Box, MultiDiscrete etc.
241+ # this of course will not work... Replace "AGymSpace" with a normal gymnasium space, like Dict, Box, MultiDiscrete etc.
242242 from gym.spaces import AGymSpace
243243 gym_env = GymEnv(env)
244244
@@ -253,7 +253,7 @@ If you want a full control on this spaces, you need to implement something like:
253253 def to_gym (self , observation ):
254254 # this is this very same function that you need to implement
255255 # it should have this exact name, take only one observation (grid2op) as input
256- # and return a gym object that belong to your space "AGymSpace"
256+ # and return a gymnasium object that belong to your space "AGymSpace"
257257 return SomethingThatBelongTo_AGymSpace
258258 # eg. return np.concatenate((obs.gen_p * 0.1, np.sqrt(obs.load_p))
259259
@@ -268,7 +268,7 @@ And for the action space:
268268 env = grid2op.make(env_name)
269269
270270 from grid2op.gym_compat import GymEnv
271- # this of course will not work... Replace "AGymSpace" with a normal gym space, like Dict, Box, MultiDiscrete etc.
271+ # this of course will not work... Replace "AGymSpace" with a normal gymnasium space, like Dict, Box, MultiDiscrete etc.
272272 from gym.spaces import AGymSpace
273273 gym_env = GymEnv(env)
274274
@@ -282,7 +282,7 @@ And for the action space:
282282
283283 def from_gym (self , gym_action ):
284284 # this is this very same function that you need to implement
285- # it should have this exact name, take only one action (member of your gym space) as input
285+ # it should have this exact name, take only one action (member of your gymnasium space) as input
286286 # and return a grid2op action
287287 return TheGymAction_ConvertedTo_Grid2op_Action
288288 # eg. return np.concatenate((obs.gen_p * 0.1, np.sqrt(obs.load_p))
@@ -311,7 +311,7 @@ and divide input data by `divide`):
311311 env_name = " l2rpn_case14_sandbox" # or any other grid2op environment name
312312 g2op_env = grid2op.make(env_name) # create the gri2op environment
313313
314- gym_env = GymEnv(g2op_env) # create the gym environment
314+ gym_env = GymEnv(g2op_env) # create the gymnasium environment
315315
316316 ob_space = gym_env.observation_space
317317 ob_space = ob_space.reencode_space(" actual_dispatch" ,
@@ -336,7 +336,7 @@ the log of the loads instead of giving the direct value to your agent. This can
336336 env_name = " l2rpn_case14_sandbox" # or any other grid2op environment name
337337 g2op_env = grid2op.make(env_name) # create the gri2op environment
338338
339- gym_env = GymEnv(g2op_env) # create the gym environment
339+ gym_env = GymEnv(g2op_env) # create the gymnasium environment
340340
341341 ob_space = gym_env.observation_space
342342 shape_ = (g2op_env.n_load, )
@@ -350,7 +350,7 @@ the log of the loads instead of giving the direct value to your agent. This can
350350 )
351351
352352 gym_env.observation_space = ob_space
353- # and now you will get the key "log_load" as part of your gym observation.
353+ # and now you will get the key "log_load" as part of your gymnasium observation.
354354
355355 A detailed list of such "converter" is documented on the section "Detailed Documentation by class". In
356356the table below we describe some of them (**nb ** if you notice a converter is not displayed there,
@@ -360,11 +360,11 @@ do not hesitate to write us a "feature request" for the documentation, thanks in
360360Converter name Objective
361361============================================= ============================================================
362362:class: `ContinuousToDiscreteConverter ` Convert a continuous space into a discrete one
363- :class: `MultiToTupleConverter ` Convert a gym MultiBinary to a gym Tuple of gym Binary and a gym MultiDiscrete to a Tuple of Discrete
363+ :class: `MultiToTupleConverter ` Convert a gymnasium MultiBinary to a gymnasium Tuple of gymnasium Binary and a gymnasium MultiDiscrete to a Tuple of Discrete
364364:class: `ScalerAttrConverter ` Allows to scale (divide an attribute by something and subtract something from it)
365- `BaseGymSpaceConverter.add_key `_ Allows you to compute another "part" of the observation space (you add an information to the gym space)
365+ `BaseGymSpaceConverter.add_key `_ Allows you to compute another "part" of the observation space (you add an information to the gymnasium space)
366366`BaseGymSpaceConverter.keep_only_attr `_ Allows you to specify which part of the action / observation you want to keep
367- `BaseGymSpaceConverter.ignore_attr `_ Allows you to ignore some attributes of the action / observation (they will not be part of the gym space)
367+ `BaseGymSpaceConverter.ignore_attr `_ Allows you to ignore some attributes of the action / observation (they will not be part of the gymnasium space)
368368============================================= ============================================================
369369
370370.. warning ::
@@ -383,7 +383,7 @@ Converter name Objective
383383.. note ::
384384
385385 With the "converters" above, note that the observation space AND action space will still
386- inherit from gym Dict.
386+ inherit from gymnasium Dict.
387387
388388 They are complex spaces that are not well handled by some RL framework.
389389
@@ -395,19 +395,19 @@ Converter name Objective
395395Customizing the action and observation space, into Box or Discrete
396396*******************************************************************
397397
398- The use of the converter above is nice if you can work with gym Dict, but in some cases, or for some frameworks
398+ The use of the converter above is nice if you can work with gymnasium Dict, but in some cases, or for some frameworks
399399it is not convenient to do it at all.
400400
401- TO alleviate this problem, we developed 4 types of gym action space, following the architecture
401+ TO alleviate this problem, we developed 4 types of gymnasium action space, following the architecture
402402detailed in subsection :ref: `base_gym_space_function `
403403
404404=============================== ============================================================
405405Converter name Objective
406406=============================== ============================================================
407407:class: `BoxGymObsSpace ` Convert the observation space to a single "Box"
408- :class: `BoxGymActSpace ` Convert a gym MultiBinary to a gym Tuple of gym Binary and a gym MultiDiscrete to a Tuple of Discrete
408+ :class: `BoxGymActSpace ` Convert a gymnasium MultiBinary to a gymnasium Tuple of gymnasium Binary and a gymnasium MultiDiscrete to a Tuple of Discrete
409409:class: `MultiDiscreteActSpace ` Allows to scale (divide an attribute by something and subtract something from it)
410- :class: `DiscreteActSpace ` Allows you to compute another "part" of the observation space (you add an information to the gym space)
410+ :class: `DiscreteActSpace ` Allows you to compute another "part" of the observation space (you add an information to the gymnasium space)
411411=============================== ============================================================
412412
413413They can all be used like:
0 commit comments