gym-examples 3.0.133__py3-none-any.whl → 3.0.134__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 +31 -19
- {gym_examples-3.0.133.dist-info → gym_examples-3.0.134.dist-info}/METADATA +1 -1
- gym_examples-3.0.134.dist-info/RECORD +7 -0
- gym_examples-3.0.133.dist-info/RECORD +0 -7
- {gym_examples-3.0.133.dist-info → gym_examples-3.0.134.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.133.dist-info → gym_examples-3.0.134.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -59,10 +59,19 @@ class WSNRoutingEnv(gym.Env):
|
|
59
59
|
# Initialize the position of the sensors randomly
|
60
60
|
|
61
61
|
# Define observation space
|
62
|
-
self.observation_space = Tuple(
|
63
|
-
|
64
|
-
)
|
65
|
-
|
62
|
+
# self.observation_space = Tuple(
|
63
|
+
# tuple([self._get_observation_space() for _ in range(self.n_sensors)])
|
64
|
+
# )
|
65
|
+
|
66
|
+
self.observation_space = gym.spaces.Dict({
|
67
|
+
'remaining_energy': gym.spaces.Box(low=0, high=initial_energy, shape=(len(self.remaining_energy),), dtype=np.float32),
|
68
|
+
'consumption_energy': gym.spaces.Box(low=0, high=initial_energy, shape=(len(self.remaining_energy),), dtype=np.float32),
|
69
|
+
'sensor_positions': gym.spaces.Box(low=lower_bound, high=upper_bound, shape=(len(self.sensor_positions), 2), dtype=np.float32),
|
70
|
+
'number_of_packets': gym.spaces.Box(low=0, high=self.n_sensors * initial_number_of_packets + 1, shape=(len(self.number_of_packets),), dtype=int)
|
71
|
+
})
|
72
|
+
|
73
|
+
# self.action_space = Tuple(tuple([Discrete(self.n_sensors + 1)] * self.n_agents))
|
74
|
+
self.action_space = gym.spaces.MultiDiscrete([self.n_sensors + 1] * self.n_agents)
|
66
75
|
|
67
76
|
self.reset()
|
68
77
|
|
@@ -179,28 +188,31 @@ class WSNRoutingEnv(gym.Env):
|
|
179
188
|
# 'number_of_packets': np.array([d])
|
180
189
|
# } for e, p, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)]
|
181
190
|
|
182
|
-
def
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
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
|
+
# })
|
187
198
|
|
199
|
+
def _get_obs(self):
|
188
200
|
return {
|
189
|
-
'remaining_energy': remaining_energy,
|
190
|
-
'consumption_energy':
|
191
|
-
'sensor_positions': sensor_positions,
|
192
|
-
'number_of_packets': number_of_packets
|
201
|
+
'remaining_energy': np.array(self.remaining_energy),
|
202
|
+
'consumption_energy': np.array([initial_energy - e for e in self.remaining_energy]),
|
203
|
+
'sensor_positions': np.stack(self.sensor_positions, axis=0),
|
204
|
+
'number_of_packets': np.array(self.number_of_packets)
|
193
205
|
}
|
194
206
|
|
195
|
-
|
196
207
|
def _get_observation_space(self):
|
197
|
-
return Dict({
|
198
|
-
'remaining_energy': Box(low=0, high=initial_energy, shape=(
|
199
|
-
'consumption_energy': Box(low=0, high=initial_energy, shape=(
|
200
|
-
'sensor_positions': Box(low=lower_bound, high=upper_bound, shape=(2
|
201
|
-
'number_of_packets': Box(low=0, high=self.n_sensors * initial_number_of_packets + 1, shape=(
|
208
|
+
return gym.spaces.Dict({
|
209
|
+
'remaining_energy': gym.spaces.Box(low=0, high=initial_energy, shape=(len(self.remaining_energy),), dtype=np.float32),
|
210
|
+
'consumption_energy': gym.spaces.Box(low=0, high=initial_energy, shape=(len(self.remaining_energy),), dtype=np.float32),
|
211
|
+
'sensor_positions': gym.spaces.Box(low=lower_bound, high=upper_bound, shape=(len(self.sensor_positions), 2), dtype=np.float32),
|
212
|
+
'number_of_packets': gym.spaces.Box(low=0, high=self.n_sensors * initial_number_of_packets + 1, shape=(len(self.number_of_packets),), dtype=int)
|
202
213
|
})
|
203
214
|
|
215
|
+
|
204
216
|
def get_state(self):
|
205
217
|
return self._get_obs()
|
206
218
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=NDW_AoYQPwLsSSYhRWfejgVCkMyXx98eNpLQEYLe4-8,194
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=dwIYGkIGyeuhF2jmq4WoOGcgzN2ytfAqrU-WPIIxoOI,23289
|
4
|
+
gym_examples-3.0.134.dist-info/METADATA,sha256=ZBMLM_U-MRZze2R6hKGKYG9kcoO5sdoYd2a15ytT-68,412
|
5
|
+
gym_examples-3.0.134.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.134.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.134.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=31q77oyVfUPqhF9_jOEky-D3Zs6aIBDa-xeXPR1tMws,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=uiL4qIvGQBErxITIN5shoVinf_XxKpkVf1xQzjOt9wA,22277
|
4
|
-
gym_examples-3.0.133.dist-info/METADATA,sha256=4yvoNgX-zLOio9dYCw1eqN2SEU9tBYsXn-gnTqUUFwc,412
|
5
|
-
gym_examples-3.0.133.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.133.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.133.dist-info/RECORD,,
|
File without changes
|
File without changes
|