gym-examples 3.0.70__py3-none-any.whl → 3.0.71__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 +19 -13
- {gym_examples-3.0.70.dist-info → gym_examples-3.0.71.dist-info}/METADATA +1 -1
- gym_examples-3.0.71.dist-info/RECORD +7 -0
- gym_examples-3.0.70.dist-info/RECORD +0 -7
- {gym_examples-3.0.70.dist-info → gym_examples-3.0.71.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.70.dist-info → gym_examples-3.0.71.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -88,7 +88,7 @@ class WSNRoutingEnv(gym.Env):
|
|
88
88
|
|
89
89
|
def step(self, actions):
|
90
90
|
self.steps += 1
|
91
|
-
rewards = [
|
91
|
+
rewards = [-1] * self.n_sensors
|
92
92
|
dones = [False] * self.n_sensors
|
93
93
|
for i, action in enumerate(actions):
|
94
94
|
if action not in range(self.n_sensors + 1):
|
@@ -165,8 +165,6 @@ class WSNRoutingEnv(gym.Env):
|
|
165
165
|
|
166
166
|
self.get_metrics()
|
167
167
|
|
168
|
-
# rewards = [r / len(rewards) for r in rewards]
|
169
|
-
|
170
168
|
return self._get_obs(), rewards, dones, {}
|
171
169
|
|
172
170
|
def _get_obs(self):
|
@@ -224,7 +222,8 @@ class WSNRoutingEnv(gym.Env):
|
|
224
222
|
# Normalize the angle
|
225
223
|
normalized_angle = abs(angle) / np.pi
|
226
224
|
|
227
|
-
return np.clip(1 - normalized_angle, 0, 1)
|
225
|
+
# return np.clip(1 - normalized_angle, 0, 1)
|
226
|
+
return np.clip(- normalized_angle, -1, 1)
|
228
227
|
|
229
228
|
def compute_reward_distance(self, i, action):
|
230
229
|
'''
|
@@ -237,7 +236,8 @@ class WSNRoutingEnv(gym.Env):
|
|
237
236
|
# Normalize the distance to the next hop
|
238
237
|
normalized_distance_to_next_hop = distance / self.coverage_radius
|
239
238
|
|
240
|
-
return np.clip(1 - normalized_distance_to_next_hop, 0, 1)
|
239
|
+
# return np.clip(1 - normalized_distance_to_next_hop, 0, 1)
|
240
|
+
return np.clip(-normalized_distance_to_next_hop, -1, 1)
|
241
241
|
|
242
242
|
def compute_reward_consumption_energy(self, i, action):
|
243
243
|
'''
|
@@ -258,8 +258,9 @@ class WSNRoutingEnv(gym.Env):
|
|
258
258
|
max_total_energy = max_transmission_energy + max_reception_energy
|
259
259
|
normalized_total_energy = total_energy / (max_total_energy + self.epsilon)
|
260
260
|
|
261
|
-
return np.clip(1 - normalized_total_energy, 0, 1)
|
262
|
-
|
261
|
+
# return np.clip(1 - normalized_total_energy, 0, 1)
|
262
|
+
return np.clip(- normalized_total_energy, -1, 1)
|
263
|
+
|
263
264
|
def compute_reward_dispersion_remaining_energy(self):
|
264
265
|
'''
|
265
266
|
Compute the reward based on the standard deviation of the remaining energy
|
@@ -269,8 +270,9 @@ class WSNRoutingEnv(gym.Env):
|
|
269
270
|
max_dispersion_remaining_energy = initial_energy / 2 # maximum standard deviation of the remaining energy if n_sensors is even
|
270
271
|
normalized_dispersion_remaining_energy = dispersion_remaining_energy / (max_dispersion_remaining_energy + self.epsilon)
|
271
272
|
|
272
|
-
return np.clip(1 - normalized_dispersion_remaining_energy, 0, 1)
|
273
|
-
|
273
|
+
# return np.clip(1 - normalized_dispersion_remaining_energy, 0, 1)
|
274
|
+
return np.clip(- normalized_dispersion_remaining_energy, -1, 1)
|
275
|
+
|
274
276
|
def compute_reward_number_of_packets(self, action):
|
275
277
|
'''
|
276
278
|
Compute the reward based on the number of packets of the receiver
|
@@ -281,7 +283,8 @@ class WSNRoutingEnv(gym.Env):
|
|
281
283
|
else:
|
282
284
|
normalized_number_of_packets = self.number_of_packets[action] / (max_number_of_packets + self.epsilon)
|
283
285
|
|
284
|
-
return np.clip(1 - normalized_number_of_packets, 0, 1)
|
286
|
+
# return np.clip(1 - normalized_number_of_packets, 0, 1)
|
287
|
+
return np.clip(- normalized_number_of_packets, -1, 1)
|
285
288
|
|
286
289
|
def compute_individual_rewards(self, i, action):
|
287
290
|
'''
|
@@ -315,7 +318,8 @@ class WSNRoutingEnv(gym.Env):
|
|
315
318
|
max_dispersion_remaining_energy = initial_energy / 2 # maximum standard deviation of the remaining energy if n_sensors is even
|
316
319
|
normalized_dispersion_remaining_energy = dispersion_remaining_energy / (max_dispersion_remaining_energy + self.epsilon)
|
317
320
|
|
318
|
-
return np.clip(1 - normalized_dispersion_remaining_energy, 0, 1)
|
321
|
+
# return np.clip(1 - normalized_dispersion_remaining_energy, 0, 1)
|
322
|
+
return np.clip(- normalized_dispersion_remaining_energy, -1, 1)
|
319
323
|
|
320
324
|
def network_reward_consumption_energy(self):
|
321
325
|
'''
|
@@ -326,7 +330,8 @@ class WSNRoutingEnv(gym.Env):
|
|
326
330
|
max_total_energy = self.n_sensors * initial_energy
|
327
331
|
normalized_total_energy = total_energy / (max_total_energy + self.epsilon)
|
328
332
|
|
329
|
-
return np.clip(1 - normalized_total_energy, 0, 1)
|
333
|
+
# return np.clip(1 - normalized_total_energy, 0, 1)
|
334
|
+
return np.clip(- normalized_total_energy, -1, 1)
|
330
335
|
|
331
336
|
def compute_reward_packet_delivery_ratio(self):
|
332
337
|
'''
|
@@ -343,7 +348,8 @@ class WSNRoutingEnv(gym.Env):
|
|
343
348
|
max_latency = self.n_sensors * self.steps
|
344
349
|
normalized_latency = self.total_latency / (max_latency + self.epsilon)
|
345
350
|
|
346
|
-
return np.clip(1 - normalized_latency, 0, 1)
|
351
|
+
# return np.clip(1 - normalized_latency, 0, 1)
|
352
|
+
return np.clip(- normalized_latency, -1, 1)
|
347
353
|
|
348
354
|
def compute_reward_network_throughput(self):
|
349
355
|
'''
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=g7xElPNRTjXJyIh9gGRHxZuNWJ8yoQ4m9wG2vxXXR8U,193
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=6ozl-jBiWyPwRaUvgMAshbydZn56lg77VGqYI8SqT2c,20451
|
4
|
+
gym_examples-3.0.71.dist-info/METADATA,sha256=O34q71LQmiTyPg53ntHDZAKanPvL9Xjd2IPpJKiASok,411
|
5
|
+
gym_examples-3.0.71.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.71.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.71.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=90AkOI4OSX_jWRjyWz1Qwg43aeQY7I_e5zr_0JEf9-o,193
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=BNBpC74P-CK4F1rA59PTgYTUjMyGZclmJmDE4D4YBuA,20007
|
4
|
-
gym_examples-3.0.70.dist-info/METADATA,sha256=fPNX7FRPRX9T1KVRK2E14UEUBVgwbhe1EQGd5sqU4O0,411
|
5
|
-
gym_examples-3.0.70.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.70.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.70.dist-info/RECORD,,
|
File without changes
|
File without changes
|