gym-examples 3.0.135__py3-none-any.whl → 3.0.137__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 +14 -39
- {gym_examples-3.0.135.dist-info → gym_examples-3.0.137.dist-info}/METADATA +1 -1
- gym_examples-3.0.137.dist-info/RECORD +7 -0
- gym_examples-3.0.135.dist-info/RECORD +0 -7
- {gym_examples-3.0.135.dist-info → gym_examples-3.0.137.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.135.dist-info → gym_examples-3.0.137.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -59,19 +59,11 @@ class WSNRoutingEnv(gym.Env):
|
|
59
59
|
# Initialize the position of the sensors randomly
|
60
60
|
|
61
61
|
# Define observation space
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
self.observation_space = gym.spaces.Dict({
|
67
|
-
'remaining_energy': gym.spaces.Box(low=0, high=initial_energy, shape=(self.n_agents,), dtype=np.float32),
|
68
|
-
'consumption_energy': gym.spaces.Box(low=0, high=initial_energy, shape=(self.n_agents,), dtype=np.float32),
|
69
|
-
'sensor_positions': gym.spaces.Box(low=lower_bound, high=upper_bound, shape=(self.n_agents, 2), dtype=np.float32),
|
70
|
-
'number_of_packets': gym.spaces.Box(low=0, high=self.n_sensors * initial_number_of_packets + 1, shape=(self.n_agents,), dtype=int)
|
71
|
-
})
|
62
|
+
self.observation_space = Tuple(
|
63
|
+
tuple([self._get_observation_space() for _ in range(self.n_sensors)])
|
64
|
+
)
|
72
65
|
|
73
|
-
|
74
|
-
self.action_space = gym.spaces.MultiDiscrete([self.n_sensors + 1] * self.n_agents)
|
66
|
+
self.action_space = Tuple(tuple([Discrete(self.n_sensors + 1)] * self.n_agents))
|
75
67
|
|
76
68
|
self.reset()
|
77
69
|
|
@@ -181,38 +173,21 @@ class WSNRoutingEnv(gym.Env):
|
|
181
173
|
|
182
174
|
return self._get_obs(), rewards, dones, {}
|
183
175
|
|
184
|
-
# def _get_obs(self):
|
185
|
-
# return [{'remaining_energy': np.array([e]),
|
186
|
-
# 'consumption_energy': np.array([initial_energy - e]),
|
187
|
-
# 'sensor_positions': p,
|
188
|
-
# 'number_of_packets': np.array([d])
|
189
|
-
# } for e, p, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)]
|
190
|
-
|
191
|
-
# def _get_observation_space(self):
|
192
|
-
# return Dict({
|
193
|
-
# 'remaining_energy': Box(low=0, high=initial_energy, shape=(1,), dtype=np.float64),
|
194
|
-
# 'consumption_energy': Box(low=0, high=initial_energy, shape=(1,), dtype=np.float64),
|
195
|
-
# 'sensor_positions': Box(low=lower_bound, high=upper_bound, shape=(2,), dtype=np.float64),
|
196
|
-
# 'number_of_packets': Box(low=0, high=self.n_sensors * initial_number_of_packets + 1, shape=(1,), dtype=int)
|
197
|
-
# })
|
198
|
-
|
199
176
|
def _get_obs(self):
|
200
|
-
return {
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
}
|
177
|
+
return [{'remaining_energy': np.array([e]),
|
178
|
+
'consumption_energy': np.array([initial_energy - e]),
|
179
|
+
'sensor_positions': p,
|
180
|
+
'number_of_packets': np.array([d])
|
181
|
+
} for e, p, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)]
|
206
182
|
|
207
183
|
def _get_observation_space(self):
|
208
|
-
return
|
209
|
-
'remaining_energy':
|
210
|
-
'consumption_energy':
|
211
|
-
'sensor_positions':
|
212
|
-
'number_of_packets':
|
184
|
+
return Dict({
|
185
|
+
'remaining_energy': Box(low=0, high=initial_energy, shape=(1,), dtype=np.float64),
|
186
|
+
'consumption_energy': Box(low=0, high=initial_energy, shape=(1,), dtype=np.float64),
|
187
|
+
'sensor_positions': Box(low=lower_bound, high=upper_bound, shape=(2,), dtype=np.float64),
|
188
|
+
'number_of_packets': Box(low=0, high=self.n_sensors * initial_number_of_packets + 1, shape=(1,), dtype=int)
|
213
189
|
})
|
214
190
|
|
215
|
-
|
216
191
|
def get_state(self):
|
217
192
|
return self._get_obs()
|
218
193
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=EdR1SDwVV8SzSIJ4Gr54QXNHDqfRN9OQuvVu86vVSZ4,194
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=baMc1CiZz4NgtfUQ8LJW3057TCL9dPnuNEsreHMsSzs,21517
|
4
|
+
gym_examples-3.0.137.dist-info/METADATA,sha256=ybEfreDxfH-l3TFQdMGYJ4KBxunwS4ALQkGqcROtcAg,412
|
5
|
+
gym_examples-3.0.137.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.137.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.137.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=AtaFL7DdMIJNpqPaITYYoHuygF_KlV9TJ_6h7tHuVh0,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=HSTtatueYT5XWeAxyNhryTdoaGoB3n9h0zdRZ_K9Q84,23236
|
4
|
-
gym_examples-3.0.135.dist-info/METADATA,sha256=WbDIlcgIXn1PoECyUQJVa783GuenQxz2bfaTDzaZSHA,412
|
5
|
-
gym_examples-3.0.135.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.135.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.135.dist-info/RECORD,,
|
File without changes
|
File without changes
|