gym-examples 3.0.132__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 -23
- {gym_examples-3.0.132.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.132.dist-info/RECORD +0 -7
- {gym_examples-3.0.132.dist-info → gym_examples-3.0.134.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.132.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,32 +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
|
-
|
187
|
-
|
188
|
-
|
189
|
-
sensor_positions = np.stack(self.sensor_positions, axis=0)
|
190
|
-
number_of_packets = np.array([d for _, _, _, d in zip(self.remaining_energy, self.sensor_positions, self.number_of_packets)])
|
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
|
+
# })
|
191
198
|
|
199
|
+
def _get_obs(self):
|
192
200
|
return {
|
193
|
-
'remaining_energy': remaining_energy,
|
194
|
-
'consumption_energy':
|
195
|
-
'sensor_positions': sensor_positions,
|
196
|
-
'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)
|
197
205
|
}
|
198
206
|
|
199
|
-
|
200
207
|
def _get_observation_space(self):
|
201
|
-
return Dict({
|
202
|
-
'remaining_energy': Box(low=0, high=initial_energy, shape=(
|
203
|
-
'consumption_energy': Box(low=0, high=initial_energy, shape=(
|
204
|
-
'sensor_positions': Box(low=lower_bound, high=upper_bound, shape=(2
|
205
|
-
'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)
|
206
213
|
})
|
207
214
|
|
215
|
+
|
208
216
|
def get_state(self):
|
209
217
|
return self._get_obs()
|
210
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=dU8-YolQl-paevg9jiwQvDHFef9CiXOcJwH8ta5MNc8,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=5W5u9zooiRStpvilzRYpm1OhLsN2kB9f7n7tNRaKog0,22551
|
4
|
-
gym_examples-3.0.132.dist-info/METADATA,sha256=xwTGNgMRovwGjacZqazoL43Sq9H2o8YIIKTKjvDqlRU,412
|
5
|
-
gym_examples-3.0.132.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.132.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.132.dist-info/RECORD,,
|
File without changes
|
File without changes
|