gym-examples 3.0.128__py3-none-any.whl → 3.0.129__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- gym_examples/__init__.py +1 -1
- gym_examples/envs/wsn_env.py +8 -47
- {gym_examples-3.0.128.dist-info → gym_examples-3.0.129.dist-info}/METADATA +1 -1
- gym_examples-3.0.129.dist-info/RECORD +7 -0
- gym_examples-3.0.128.dist-info/RECORD +0 -7
- {gym_examples-3.0.128.dist-info → gym_examples-3.0.129.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.128.dist-info → gym_examples-3.0.129.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -59,33 +59,10 @@ class WSNRoutingEnv(gym.Env):
|
|
59
59
|
# Initialize the position of the sensors randomly
|
60
60
|
|
61
61
|
# Define observation space
|
62
|
-
|
63
|
-
|
64
|
-
# )
|
65
|
-
# self.action_space = Tuple(tuple([Discrete(self.n_sensors + 1)] * self.n_agents))
|
66
|
-
|
67
|
-
# Define the flattened observation space
|
68
|
-
single_sensor_obs_space = self._get_observation_space()
|
69
|
-
obs_low = np.concatenate([
|
70
|
-
single_sensor_obs_space['remaining_energy'].low,
|
71
|
-
single_sensor_obs_space['consumption_energy'].low,
|
72
|
-
single_sensor_obs_space['sensor_positions'].low,
|
73
|
-
single_sensor_obs_space['number_of_packets'].low
|
74
|
-
])
|
75
|
-
obs_high = np.concatenate([
|
76
|
-
single_sensor_obs_space['remaining_energy'].high,
|
77
|
-
single_sensor_obs_space['consumption_energy'].high,
|
78
|
-
single_sensor_obs_space['sensor_positions'].high,
|
79
|
-
single_sensor_obs_space['number_of_packets'].high
|
80
|
-
])
|
81
|
-
self.observation_space = Box(
|
82
|
-
low=np.tile(obs_low, self.n_sensors),
|
83
|
-
high=np.tile(obs_high, self.n_sensors),
|
84
|
-
dtype=np.float32
|
62
|
+
self.observation_space = Tuple(
|
63
|
+
tuple([self._get_observation_space() for _ in range(self.n_sensors)])
|
85
64
|
)
|
86
|
-
|
87
|
-
# Define the flattened action space
|
88
|
-
self.action_space = MultiDiscrete([self.n_sensors + 1] * self.n_agents)
|
65
|
+
self.action_space = Tuple(tuple([Discrete(self.n_sensors + 1)] * self.n_agents))
|
89
66
|
|
90
67
|
self.reset()
|
91
68
|
|
@@ -195,28 +172,12 @@ class WSNRoutingEnv(gym.Env):
|
|
195
172
|
|
196
173
|
return self._get_obs(), rewards, dones, {}
|
197
174
|
|
198
|
-
# def _get_obs(self):
|
199
|
-
|
200
|
-
# return [{'remaining_energy': np.array([e]),
|
201
|
-
# 'consumption_energy': np.array([initial_energy - e]),
|
202
|
-
# 'sensor_positions': p,
|
203
|
-
# 'number_of_packets': np.array([d])
|
204
|
-
# } for e, p, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)]
|
205
|
-
|
206
175
|
def _get_obs(self):
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
} for e, p, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)]
|
213
|
-
|
214
|
-
# Flattened observation for compatibility with Stable Baselines3
|
215
|
-
flat_obs = np.concatenate([
|
216
|
-
np.concatenate([obs['remaining_energy'], obs['consumption_energy'], obs['sensor_positions'], obs['number_of_packets']])
|
217
|
-
for obs in structured_obs
|
218
|
-
])
|
219
|
-
return flat_obs
|
176
|
+
return [{'remaining_energy': np.array([e]),
|
177
|
+
'consumption_energy': np.array([initial_energy - e]),
|
178
|
+
'sensor_positions': p,
|
179
|
+
'number_of_packets': np.array([d])
|
180
|
+
} for e, p, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)]
|
220
181
|
|
221
182
|
def _get_observation_space(self):
|
222
183
|
return Dict({
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=f5RfZkZxk0_sPLzl68-buUGDEr0bw8Odn_OhBrqtJMI,194
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=SPuZ6Eezn7LY38r7eGtMAZw6SfbLnBSdbGyLNaSA0D0,21515
|
4
|
+
gym_examples-3.0.129.dist-info/METADATA,sha256=kKkDZbChu1-rph3VjmRNqfLqMhfRP7jQkn-OpZeKxGQ,412
|
5
|
+
gym_examples-3.0.129.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.129.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.129.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=HtlSQQsIPVhRkM90RZRf4j2KCKHhI4jQzcBnLzxNT1U,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=cPfhzLLoAMoBonuR7PdgS-OjU9e1AbaJlgRo4AxHTqY,23329
|
4
|
-
gym_examples-3.0.128.dist-info/METADATA,sha256=CCcUSZp8Tyavj_Gxy9eWmZH1XJgvrMbItHuVR6BlRXM,412
|
5
|
-
gym_examples-3.0.128.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.128.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.128.dist-info/RECORD,,
|
File without changes
|
File without changes
|