gym-examples 2.0.31__py3-none-any.whl → 2.0.32__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 +26 -2
- {gym_examples-2.0.31.dist-info → gym_examples-2.0.32.dist-info}/METADATA +1 -1
- gym_examples-2.0.32.dist-info/RECORD +7 -0
- gym_examples-2.0.31.dist-info/RECORD +0 -7
- {gym_examples-2.0.31.dist-info → gym_examples-2.0.32.dist-info}/WHEEL +0 -0
- {gym_examples-2.0.31.dist-info → gym_examples-2.0.32.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -115,9 +115,10 @@ class WSNRoutingEnv(gym.Env):
|
|
115
115
|
# Calculate final reward
|
116
116
|
# rewards_individual = torch.tensor(rewards[i], dtype=torch.double)
|
117
117
|
# final_reward = net(rewards_individual)
|
118
|
-
final_reward = np.sum(rewards[i])
|
118
|
+
final_reward = np.sum(rewards[i])
|
119
119
|
rewards[i] = final_reward
|
120
|
-
|
120
|
+
rewards *= self.network_reward_consumption_energy() * self.network_reward_dispersion_remaining_energy()
|
121
|
+
|
121
122
|
for i in range(self.n_sensors):
|
122
123
|
if (self.remaining_energy[i] <= 0) or (self.number_of_packets[i] <= 0):
|
123
124
|
dones[i] = True
|
@@ -254,6 +255,29 @@ class WSNRoutingEnv(gym.Env):
|
|
254
255
|
|
255
256
|
return [reward_angle, reward_distance, reward_consumption_energy, reward_dispersion_remaining_energy, reward_number_of_packets]
|
256
257
|
|
258
|
+
def network_reward_dispersion_remaining_energy(self):
|
259
|
+
'''
|
260
|
+
Compute the reward based on the standard deviation of the remaining energy at the network level
|
261
|
+
'''
|
262
|
+
dispersion_remaining_energy = np.std(self.remaining_energy)
|
263
|
+
# Normalize the standard deviation of the remaining energy
|
264
|
+
max_dispersion_remaining_energy = initial_energy / 2 # maximum standard deviation of the remaining energy if n_sensors is even
|
265
|
+
normalized_dispersion_remaining_energy = dispersion_remaining_energy / max_dispersion_remaining_energy
|
266
|
+
|
267
|
+
return np.clip(1 - normalized_dispersion_remaining_energy, 0, 1)
|
268
|
+
|
269
|
+
def network_reward_consumption_energy(self):
|
270
|
+
'''
|
271
|
+
Compute the reward based on the total energy consumption (transmission, reception) at the network level
|
272
|
+
'''
|
273
|
+
total_energy = np.sum(self.consumption_energy)
|
274
|
+
# Normalize the total energy consumption
|
275
|
+
max_transmission_energy = self.transmission_energy(self.n_sensors * initial_number_of_packets, self.coverage_radius)
|
276
|
+
max_reception_energy = self.reception_energy(self.n_sensors * initial_number_of_packets)
|
277
|
+
normalized_total_energy = total_energy / (max_transmission_energy + max_reception_energy)
|
278
|
+
|
279
|
+
return 1 - normalized_total_energy
|
280
|
+
|
257
281
|
def integrate_mobility(self):
|
258
282
|
'''
|
259
283
|
Integrate the mobility of the sensors after each step
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=EYrWJ3V1oe3cV6qzc6PCLGBpaidU210LmmACYpG1bt4,193
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=gZkGOQuMxtNO40vk-D1k90ed_iIdJdUQ3LFbpWkjxmU,14710
|
4
|
+
gym_examples-2.0.32.dist-info/METADATA,sha256=IokXfCpcv9CpKNwR5aId5HN4I1UVNd5Of6E2nRy1adc,411
|
5
|
+
gym_examples-2.0.32.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-2.0.32.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-2.0.32.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=-Zi6pjtuGP4mWLhMJ5XoRMBap3wEBnvbILvg_aozuTw,193
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=M2bo_-wLWkXTJajQc7OgkT7vsXlCyGBTkfXA3ipFSc0,13265
|
4
|
-
gym_examples-2.0.31.dist-info/METADATA,sha256=XZzdSuDCJ2CXoAF6osyaCT0nKN9xRQoL5GksbJvxnq4,411
|
5
|
-
gym_examples-2.0.31.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-2.0.31.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-2.0.31.dist-info/RECORD,,
|
File without changes
|
File without changes
|