gym-examples 3.0.42__py3-none-any.whl → 3.0.43__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 CHANGED
@@ -6,4 +6,4 @@ register(
6
6
  max_episode_steps=50,
7
7
  )
8
8
 
9
- __version__ = "3.0.42"
9
+ __version__ = "3.0.43"
@@ -10,7 +10,7 @@ import torch.nn as nn
10
10
  import torch.nn.functional as F
11
11
 
12
12
  # Define the network parameters for the final reward function
13
- input_dim = 4 # lenght of the individual rewards vector
13
+ input_dim = 7 # lenght of the individual rewards vector
14
14
  output_dim = 1 # final reward
15
15
 
16
16
  Eelec = 50e-9 # energy consumption per bit in joules
@@ -146,9 +146,12 @@ class WSNRoutingEnv(gym.Env):
146
146
 
147
147
  # Compute individual rewards
148
148
  rewards[i] = self.compute_individual_rewards(i, action)
149
- reward_packet_delivery_ratio = self.compute_reward_packet_delivery_ratio()
150
149
  reward_latency = self.compute_reward_latency()
151
- rewards[i] = np.append(rewards[i], [reward_packet_delivery_ratio, reward_latency])
150
+ reward_network_throughput = self.compute_reward_network_throughput()
151
+ reward_packet_delivery_ratio = self.compute_reward_packet_delivery_ratio()
152
+
153
+ rewards[i] = np.append(rewards[i], [reward_latency, reward_network_throughput, reward_packet_delivery_ratio])
154
+ print(f"Rewards for sensor {i}: {rewards[i]}")
152
155
  # Update the number of packets
153
156
  self.number_of_packets[action] += self.number_of_packets[i]
154
157
  self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
@@ -301,8 +304,8 @@ class WSNRoutingEnv(gym.Env):
301
304
  reward_dispersion_remaining_energy = self.compute_reward_dispersion_remaining_energy()
302
305
  reward_number_of_packets = self.compute_reward_number_of_packets(action)
303
306
 
304
- # return [reward_angle, reward_consumption_energy, reward_dispersion_remaining_energy, reward_number_of_packets]
305
- return [reward_consumption_energy, reward_dispersion_remaining_energy]
307
+ return [reward_angle, reward_consumption_energy, reward_dispersion_remaining_energy, reward_number_of_packets]
308
+ # return [reward_consumption_energy, reward_dispersion_remaining_energy]
306
309
 
307
310
  def network_reward_dispersion_remaining_energy(self):
308
311
  '''
@@ -343,6 +346,15 @@ class WSNRoutingEnv(gym.Env):
343
346
 
344
347
  return np.clip(1 - normalized_latency, 0, 1)
345
348
 
349
+ def compute_reward_network_throughput(self):
350
+ '''
351
+ Compute the reward based on the network throughput
352
+ '''
353
+ network_throughput = self.packets_delivered / self.steps if self.steps > 0 else 0
354
+ maximum_throughput = self.n_sensors * initial_number_of_packets
355
+ normalized_throughput = network_throughput / maximum_throughput
356
+ return np.clip(normalized_throughput, 0, 1)
357
+
346
358
 
347
359
  def compute_sum_rewards(self, rewards):
348
360
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gym-examples
3
- Version: 3.0.42
3
+ Version: 3.0.43
4
4
  Summary: A custom environment for multi-agent reinforcement learning focused on WSN routing.
5
5
  Home-page: https://github.com/gedji/CODES.git
6
6
  Author: Georges Djimefo
@@ -0,0 +1,7 @@
1
+ gym_examples/__init__.py,sha256=v16UW-Z-uwXvUYm4QHBNqhWNXR60wfJm4p2JkJlUz78,193
2
+ gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
+ gym_examples/envs/wsn_env.py,sha256=MXuHoi82JRleOBG5aXpUjlf58L_QeXCBeWNSceyBcGA,20145
4
+ gym_examples-3.0.43.dist-info/METADATA,sha256=zyEgD6YW1AooTqez0qIsvvApqcqswdHfMtzQJ0V0TAQ,411
5
+ gym_examples-3.0.43.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
+ gym_examples-3.0.43.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
+ gym_examples-3.0.43.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- gym_examples/__init__.py,sha256=kLTFJhJe48NKPRenv6nTfwR9FbFVrCMz4hzeIhHTrgI,193
2
- gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
- gym_examples/envs/wsn_env.py,sha256=P3-MHflhQ29pLwrDb2oY7NjJvbpDXuTz6bPX2_mbqPQ,19522
4
- gym_examples-3.0.42.dist-info/METADATA,sha256=T4wmhIiKxlhX7Mccah7D-kCaZap2pgJPtrVgyo0rMPI,411
5
- gym_examples-3.0.42.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
- gym_examples-3.0.42.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
- gym_examples-3.0.42.dist-info/RECORD,,