gym-examples 3.0.83__py3-none-any.whl → 3.0.85__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.83"
9
+ __version__ = "3.0.85"
@@ -23,6 +23,8 @@ base_station_position = np.array([(upper_bound - lower_bound)/2, (upper_bound -
23
23
  initial_number_of_packets = 1 # initial number of packets to transmit
24
24
  latency_per_hop = 1 # latency per hop in seconds
25
25
 
26
+ coef_network_throughput = 2.6 # coefficient for the network throughput reward
27
+ coef_packet_delivery_ratio = 1.6 # coefficient for the packet delivery ratio reward
26
28
 
27
29
  # Define the final reward function using an attention mechanism
28
30
  class Attention(nn.Module):
@@ -151,8 +153,8 @@ class WSNRoutingEnv(gym.Env):
151
153
  self.number_of_packets[action] += self.number_of_packets[i]
152
154
  self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
153
155
  # Calculate final reward
154
- rewards[i] = self.compute_attention_rewards(rewards[i])
155
- # rewards[i] = np.mean(rewards[i])
156
+ # rewards[i] = self.compute_attention_rewards(rewards[i])
157
+ rewards[i] = self.compute_weighted_sum_rewards(rewards[i])
156
158
  for i in range(self.n_sensors):
157
159
  if (self.remaining_energy[i] <= 0) or (self.number_of_packets[i] <= 0):
158
160
  dones[i] = True
@@ -303,6 +305,7 @@ class WSNRoutingEnv(gym.Env):
303
305
 
304
306
  #-- rewards related to the performance metrics
305
307
  reward_latency = self.compute_reward_latency()
308
+
306
309
  reward_network_throughput = self.compute_reward_network_throughput()
307
310
  reward_packet_delivery_ratio = self.compute_reward_packet_delivery_ratio()
308
311
 
@@ -367,11 +370,13 @@ class WSNRoutingEnv(gym.Env):
367
370
  return np.clip(normalized_throughput, 0, 1)
368
371
 
369
372
 
370
- def compute_sum_rewards(self, rewards):
373
+ def compute_weighted_sum_rewards(self, rewards):
371
374
  '''
372
- Compute the sum of the rewards
375
+ Compute the weigthed sum of the rewards
373
376
  '''
374
- return np.sum(rewards)
377
+ weights = np.array([1, 1, 1, 1, 1, coef_network_throughput, coef_packet_delivery_ratio])
378
+ return np.dot(rewards, weights) / np.sum(weights)
379
+ # return np.sum(rewards)
375
380
 
376
381
  def compute_attention_rewards(self, rewards):
377
382
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gym-examples
3
- Version: 3.0.83
3
+ Version: 3.0.85
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=ByDRt4r5RLWZlLnPaP5i24fqifb-NUcAWGiBrjcAuSw,193
2
+ gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
+ gym_examples/envs/wsn_env.py,sha256=aeX-q8c9wDPn2tZDoWPbmeuShAPWLZqMg0BsVOC54NU,21009
4
+ gym_examples-3.0.85.dist-info/METADATA,sha256=umuJFO1kGw8fPQwwElY4EyGxHFmnMuaGas67j2L2qWs,411
5
+ gym_examples-3.0.85.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
+ gym_examples-3.0.85.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
+ gym_examples-3.0.85.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- gym_examples/__init__.py,sha256=QDtvnXb2Mx55f1nDFtydZEG4rBrtql9NsdptzX8iERo,193
2
- gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
- gym_examples/envs/wsn_env.py,sha256=kvQViM19DyTdlmkIAUs_WL2UWIk46EiEV5LrWPCekUA,20630
4
- gym_examples-3.0.83.dist-info/METADATA,sha256=YEoAiSUMbHaInr_ZMK0Nb6XLEByt9O9RfVefbAv1rJs,411
5
- gym_examples-3.0.83.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
- gym_examples-3.0.83.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
- gym_examples-3.0.83.dist-info/RECORD,,