gym-examples 3.0.284__py3-none-any.whl → 3.0.285__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 +5 -2
- {gym_examples-3.0.284.dist-info → gym_examples-3.0.285.dist-info}/METADATA +1 -1
- gym_examples-3.0.285.dist-info/RECORD +7 -0
- gym_examples-3.0.284.dist-info/RECORD +0 -7
- {gym_examples-3.0.284.dist-info → gym_examples-3.0.285.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.284.dist-info → gym_examples-3.0.285.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -173,7 +173,7 @@ class WSNRoutingEnv(gym.Env):
|
|
173
173
|
self.packet_latency[action] += self.packet_latency[i] + latency_per_hop
|
174
174
|
self.packet_latency[i] = 0
|
175
175
|
|
176
|
-
rewards = self.compute_individual_rewards(i, action)
|
176
|
+
rewards[i] = self.compute_individual_rewards(i, action)
|
177
177
|
|
178
178
|
# Update the number of packets
|
179
179
|
self.number_of_packets[action] += self.number_of_packets[i]
|
@@ -181,7 +181,7 @@ class WSNRoutingEnv(gym.Env):
|
|
181
181
|
self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
|
182
182
|
# Calculate final reward
|
183
183
|
# rewards[i] = self.compute_attention_rewards(rewards[i])
|
184
|
-
rewards = np.mean(rewards)
|
184
|
+
rewards[i] = np.mean(rewards[i])
|
185
185
|
|
186
186
|
# Integrate the mobility of the sensors
|
187
187
|
# self.integrate_mobility()
|
@@ -194,9 +194,12 @@ class WSNRoutingEnv(gym.Env):
|
|
194
194
|
self.get_metrics()
|
195
195
|
|
196
196
|
rewards = [reward.item() if isinstance(reward, torch.Tensor) else reward for reward in rewards] # Convert the reward to a float
|
197
|
+
rewards = np.mean(rewards) # Average the rewards
|
198
|
+
|
197
199
|
for i in range(self.n_sensors):
|
198
200
|
if not dones[i]:
|
199
201
|
dones[i] = self.remaining_energy[i] <= 0 or self.number_of_packets[i] == 0
|
202
|
+
dones = np.all(dones)
|
200
203
|
|
201
204
|
return self._get_obs(), rewards, dones, self.get_metrics()
|
202
205
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=RG4x72mbBXJgNSIrzig4Fq6xeAVsPtwrVaN8fHLoVHc,166
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=7AKFR_Q4I_GADV3Q78g-JYacUSIwRDzjxLRZ5X9lzFc,23610
|
4
|
+
gym_examples-3.0.285.dist-info/METADATA,sha256=fR_FUKKdoAUxYEjQ8KbeVC4quinNkfxfqShtSaWFMlo,412
|
5
|
+
gym_examples-3.0.285.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.285.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.285.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=SbYVbDAngXH8S9SM6aQijqGwMUt-FSXYtOV00-_0ahI,166
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=VzbARUwPIdS6-RkQND3dxx0lLheFpP6NqaBwT5JY91o,23503
|
4
|
-
gym_examples-3.0.284.dist-info/METADATA,sha256=U9huJCLpn-NIXHhbpD97MFIY_WpCrOxX7ebSgLBsf_w,412
|
5
|
-
gym_examples-3.0.284.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.284.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.284.dist-info/RECORD,,
|
File without changes
|
File without changes
|