gym-examples 3.0.220__py3-none-any.whl → 3.0.221__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 +30 -32
- {gym_examples-3.0.220.dist-info → gym_examples-3.0.221.dist-info}/METADATA +1 -1
- gym_examples-3.0.221.dist-info/RECORD +7 -0
- gym_examples-3.0.220.dist-info/RECORD +0 -7
- {gym_examples-3.0.220.dist-info → gym_examples-3.0.221.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.220.dist-info → gym_examples-3.0.221.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -213,37 +213,37 @@ class WSNRoutingEnv(gym.Env):
|
|
213
213
|
|
214
214
|
rewards = [r.item() if isinstance(r, torch.Tensor) else r for r in rewards] # Convert the rewards to a list of floats
|
215
215
|
# rewards = np.sum(rewards) # Sum the rewards of all agents
|
216
|
-
|
217
|
-
rewards = np.mean(self.compute_network_rewards()) # Average the rewards of all agents
|
216
|
+
rewards = np.mean(rewards) # Average the rewards of all agents
|
217
|
+
# rewards = np.mean(self.compute_network_rewards()) # Average the rewards of all agents
|
218
218
|
# print(f"Step: {self.steps}, Rewards: {rewards}, Done: {dones}")
|
219
219
|
dones = all(dones) # Done if all agents are done
|
220
220
|
|
221
|
-
if os.getenv('PRINT_STATS') == 'True': # We are trying to extract only the statistics for the PPO algorithm
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
221
|
+
# if os.getenv('PRINT_STATS') == 'True': # We are trying to extract only the statistics for the PPO algorithm
|
222
|
+
# self.number_of_steps += 1
|
223
|
+
# self.episode_return += rewards
|
224
|
+
# if self.number_of_steps >= self.num_timesteps:
|
225
|
+
# self.episode_returns.append(self.episode_return)
|
226
|
+
# self.episode_std_remaining_energy.append(np.std(self.remaining_energy))
|
227
|
+
# self.episode_mean_remaining_energy.append(np.mean(self.remaining_energy))
|
228
|
+
# self.episode_total_consumption_energy.append(np.sum(initial_energy - self.remaining_energy))
|
229
|
+
# self.episode_network_throughput.append(self.network_throughput)
|
230
|
+
# self.episode_packet_delivery_ratio.append(self.packet_delivery_ratio)
|
231
|
+
# self.episode_network_lifetime.append(self.network_lifetime)
|
232
|
+
# self.episode_average_latency.append(self.average_latency)
|
233
|
+
|
234
|
+
# metrics = {
|
235
|
+
# "returns_PPO": self.episode_returns,
|
236
|
+
# "std_remaining_energy_PPO": self.episode_std_remaining_energy,
|
237
|
+
# "total_consumption_energy_PPO": self.episode_total_consumption_energy,
|
238
|
+
# "mean_remaining_energy_PPO": self.episode_mean_remaining_energy,
|
239
|
+
# "network_throughput_PPO": self.episode_network_throughput,
|
240
|
+
# "packet_delivery_ratio_PPO": self.episode_packet_delivery_ratio,
|
241
|
+
# "network_lifetime_PPO": self.episode_network_lifetime,
|
242
|
+
# "average_latency_PPO": self.episode_average_latency
|
243
|
+
# }
|
244
|
+
|
245
|
+
# for metric_name, metric_value in metrics.items():
|
246
|
+
# np.save(f"{base_back_up_dir}{metric_name}_{self.version}.npy", np.array(metric_value))
|
247
247
|
|
248
248
|
return self._get_obs(), rewards, dones, {}
|
249
249
|
|
@@ -387,7 +387,7 @@ class WSNRoutingEnv(gym.Env):
|
|
387
387
|
rewards_performance = np.array([reward_latency, reward_network_throughput, reward_packet_delivery_ratio])
|
388
388
|
|
389
389
|
return np.concatenate((rewards_energy, rewards_performance))
|
390
|
-
|
390
|
+
|
391
391
|
|
392
392
|
def compute_network_rewards(self):
|
393
393
|
|
@@ -400,9 +400,7 @@ class WSNRoutingEnv(gym.Env):
|
|
400
400
|
reward_packet_delivery_ratio = self.compute_reward_packet_delivery_ratio()
|
401
401
|
rewards_performance = np.array([reward_latency, reward_network_throughput, reward_packet_delivery_ratio])
|
402
402
|
|
403
|
-
|
404
|
-
# return rewards_energy
|
405
|
-
return np.array([reward_consumption_energy])
|
403
|
+
return np.concatenate((rewards_energy, rewards_performance))
|
406
404
|
|
407
405
|
def network_reward_dispersion_remaining_energy(self):
|
408
406
|
'''
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=e3IzKZG7FDVeQeid5naFn1PzaMlIKk94FSEIIRc4DOk,194
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=9QXOPbuHBEAA4X24dYgYRWQdayupNxTv_Pmyh6PzmRk,26254
|
4
|
+
gym_examples-3.0.221.dist-info/METADATA,sha256=geg1ENQ3KH6mdK_BF8opzQPDwil7KcCp-OXBsbrIP-8,412
|
5
|
+
gym_examples-3.0.221.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.221.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.221.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=MEYnbGONT9nEeGjf_5eFPpnFuoYOFSHCwbl4ZhogWlo,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=KaqAWRQ9hG_Q46r60GwUu0p92D9lWcRwOerHHRP9CXo,26322
|
4
|
-
gym_examples-3.0.220.dist-info/METADATA,sha256=iM7DTB1bT5TB-MkxbZcm9wf_8hFrLgrOVRgzTmYRENU,412
|
5
|
-
gym_examples-3.0.220.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.220.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.220.dist-info/RECORD,,
|
File without changes
|
File without changes
|