gym-examples 2.0.22__py3-none-any.whl → 2.0.24__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__ = "2.0.22"
9
+ __version__ = "2.0.24"
@@ -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 # number of individual rewards
13
+ input_dim = 5 # number of individual rewards
14
14
  output_dim = 1 # final reward
15
15
 
16
16
 
@@ -247,6 +247,18 @@ class WSNRoutingEnv(gym.Env):
247
247
 
248
248
  return 1 - normalized_dispersion_remaining_energy
249
249
 
250
+ def compute_reward_number_of_packets(self, i, action, neighbors_i):
251
+ '''
252
+ Compute the reward based on the number of packets to transmit
253
+ '''
254
+ if len(neighbors_i) == 1:
255
+ return 1
256
+ else:
257
+ total_number_of_packets = np.sum([self.number_of_packets[x] for x in neighbors_i])
258
+ normalized_number_of_packets = self.number_of_packets[action] / total_number_of_packets
259
+
260
+ return 1 - normalized_number_of_packets
261
+
250
262
  def compute_individual_rewards(self, i, action, neighbors_i, remaining_energy_before):
251
263
  '''
252
264
  Compute the individual rewards
@@ -255,8 +267,9 @@ class WSNRoutingEnv(gym.Env):
255
267
  reward_distance = self.compute_reward_distance(action, neighbors_i)
256
268
  reward_consumption_energy = self.compute_reward_consumption_energy(action, neighbors_i)
257
269
  reward_dispersion_remaining_energy = self.compute_reward_dispersion_remaining_energy(i, action, neighbors_i, remaining_energy_before)
270
+ reward_number_of_packets = self.compute_reward_number_of_packets(i, action, neighbors_i)
258
271
 
259
- return [reward_angle, reward_distance, reward_consumption_energy, reward_dispersion_remaining_energy]
272
+ return [reward_angle, reward_distance, reward_consumption_energy, reward_dispersion_remaining_energy, reward_number_of_packets]
260
273
 
261
274
  def integrate_mobility(self):
262
275
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gym-examples
3
- Version: 2.0.22
3
+ Version: 2.0.24
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=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,,
@@ -1,7 +0,0 @@
1
- gym_examples/__init__.py,sha256=ASeSKqPowiC-FIiSjINSwqjYGf2llO0u4-wujqJhHGk,193
2
- gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
- gym_examples/envs/wsn_env.py,sha256=NZBpWz34UruMNwuCReQcx_MQlIWRH34dEI53EcpsHSk,15137
4
- gym_examples-2.0.22.dist-info/METADATA,sha256=4OYWgt3dI4n0l8LFSnr5fWoumjRMiQwXEB1eNXY7FEs,411
5
- gym_examples-2.0.22.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
- gym_examples-2.0.22.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
- gym_examples-2.0.22.dist-info/RECORD,,