gym-examples 2.0.24__py3-none-any.whl → 2.0.25__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 +9 -5
- {gym_examples-2.0.24.dist-info → gym_examples-2.0.25.dist-info}/METADATA +1 -1
- gym_examples-2.0.25.dist-info/RECORD +7 -0
- gym_examples-2.0.24.dist-info/RECORD +0 -7
- {gym_examples-2.0.24.dist-info → gym_examples-2.0.25.dist-info}/WHEEL +0 -0
- {gym_examples-2.0.24.dist-info → gym_examples-2.0.25.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -118,7 +118,8 @@ class WSNRoutingEnv(gym.Env):
|
|
118
118
|
# Calculate final reward
|
119
119
|
# rewards_individual = torch.tensor(rewards[i], dtype=torch.double)
|
120
120
|
# final_reward = net(rewards_individual)
|
121
|
-
final_reward = sum(rewards[i])
|
121
|
+
# final_reward = sum(rewards[i])
|
122
|
+
final_reward = np.mean(rewards[i])
|
122
123
|
rewards[i] = final_reward
|
123
124
|
|
124
125
|
for i in range(self.n_sensors):
|
@@ -249,10 +250,12 @@ class WSNRoutingEnv(gym.Env):
|
|
249
250
|
|
250
251
|
def compute_reward_number_of_packets(self, i, action, neighbors_i):
|
251
252
|
'''
|
252
|
-
Compute the reward based on the number of packets
|
253
|
+
Compute the reward based on the number of packets of each sensor in the neighborhood
|
253
254
|
'''
|
254
|
-
if len(neighbors_i) == 1:
|
255
|
+
if len(neighbors_i) == 1 or action == self.n_sensors:
|
255
256
|
return 1
|
257
|
+
elif self.n_sensors in neighbors_i.keys():
|
258
|
+
return 0
|
256
259
|
else:
|
257
260
|
total_number_of_packets = np.sum([self.number_of_packets[x] for x in neighbors_i])
|
258
261
|
normalized_number_of_packets = self.number_of_packets[action] / total_number_of_packets
|
@@ -269,8 +272,9 @@ class WSNRoutingEnv(gym.Env):
|
|
269
272
|
reward_dispersion_remaining_energy = self.compute_reward_dispersion_remaining_energy(i, action, neighbors_i, remaining_energy_before)
|
270
273
|
reward_number_of_packets = self.compute_reward_number_of_packets(i, action, neighbors_i)
|
271
274
|
|
272
|
-
return [reward_angle, reward_distance, reward_consumption_energy, reward_dispersion_remaining_energy, reward_number_of_packets]
|
273
|
-
|
275
|
+
# return [reward_angle, reward_distance, reward_consumption_energy, reward_dispersion_remaining_energy, reward_number_of_packets]
|
276
|
+
return [reward_angle, reward_distance, reward_consumption_energy, reward_dispersion_remaining_energy]
|
277
|
+
|
274
278
|
def integrate_mobility(self):
|
275
279
|
'''
|
276
280
|
Integrate the mobility of the sensors after each step
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=M32_6YSJZauKwn2-uBxRdUz47YkLA2k9Kba-ATqlmjY,193
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=ZyQ0DZ0SUVV8yj2TE0_8pbwPVfuzKzidcsymlQvLpU8,16041
|
4
|
+
gym_examples-2.0.25.dist-info/METADATA,sha256=bJhOsljL-MgvqCHj9v74RQ0_6qQCr7hTCsxLOjiebFM,411
|
5
|
+
gym_examples-2.0.25.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-2.0.25.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-2.0.25.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=cfrZU0rlt-uBEIIfos7Z0TRaI2NgwTZmM5YVG4ojpTE,193
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=HXDG3mR-GXlkwlPAf8xOvzbAk-Gj_sf5nFpsG-z7SEs,15757
|
4
|
-
gym_examples-2.0.24.dist-info/METADATA,sha256=p7X6WjQuMnFSqIr0oO4U_Iexvi3pRG_15678VqCXPl8,411
|
5
|
-
gym_examples-2.0.24.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-2.0.24.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-2.0.24.dist-info/RECORD,,
|
File without changes
|
File without changes
|