gym-examples 3.0.79__py3-none-any.whl → 3.0.80__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.79"
9
+ __version__ = "3.0.80"
@@ -40,6 +40,9 @@ class Attention(nn.Module):
40
40
  x = self.linear2(x) # Pass the result through another linear layer
41
41
  return x
42
42
 
43
+ net = Attention(input_dim, output_dim)
44
+ net = net.double() # Convert the weights to Double
45
+
43
46
  class WSNRoutingEnv(gym.Env):
44
47
  def __init__(self, n_sensors = 20, coverage_radius=(upper_bound - lower_bound)/4):
45
48
 
@@ -121,8 +124,8 @@ class WSNRoutingEnv(gym.Env):
121
124
  self.total_latency += self.packet_latency[i] + latency_per_hop
122
125
  self.packet_latency[i] = 0
123
126
 
124
- # rewards[i] = self.compute_individual_rewards(i, action)
125
- rewards[i] = np.ones(input_dim) # Reward for transmitting data to the base station
127
+ rewards[i] = self.compute_individual_rewards(i, action)
128
+ # rewards[i] = np.ones(input_dim) # Reward for transmitting data to the base station
126
129
  dones[i] = True
127
130
  else:
128
131
  distance = np.linalg.norm(self.sensor_positions[i] - self.sensor_positions[action])
@@ -149,8 +152,8 @@ class WSNRoutingEnv(gym.Env):
149
152
  self.number_of_packets[action] += self.number_of_packets[i]
150
153
  self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
151
154
  # Calculate final reward
152
- # rewards[i] = self.compute_attention_rewards(rewards[i])
153
- rewards[i] = np.mean(rewards[i])
155
+ rewards[i] = self.compute_attention_rewards(rewards[i])
156
+ # rewards[i] = np.mean(rewards[i])
154
157
  for i in range(self.n_sensors):
155
158
  if (self.remaining_energy[i] <= 0) or (self.number_of_packets[i] <= 0):
156
159
  dones[i] = True
@@ -371,10 +374,7 @@ class WSNRoutingEnv(gym.Env):
371
374
  '''
372
375
  Compute the attention-based rewards
373
376
  '''
374
- input_dim = len(rewards)
375
377
  rewards = torch.tensor(rewards, dtype=torch.double)
376
- net = Attention(input_dim, output_dim)
377
- net = net.double() # Convert the weights to Double
378
378
  final_reward = net(rewards)
379
379
  return final_reward
380
380
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gym-examples
3
- Version: 3.0.79
3
+ Version: 3.0.80
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=hNQ05dR9XWqWYLWTRWQYrb94dzR8CeLomp79s3ty4pc,193
2
+ gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
+ gym_examples/envs/wsn_env.py,sha256=0-eIZjWC5qOwEcK3wJsdP9McFn4gptdQdoiI-I5QOlc,20386
4
+ gym_examples-3.0.80.dist-info/METADATA,sha256=FgRrwMYEQGezDhVqtqUdE9HVpABQZtHSd9f3vXMEFRU,411
5
+ gym_examples-3.0.80.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
+ gym_examples-3.0.80.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
+ gym_examples-3.0.80.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- gym_examples/__init__.py,sha256=Zx6apdel9zNMkb769ArqkX8c7CG_d8CHIpz4BQoJUnc,193
2
- gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
3
- gym_examples/envs/wsn_env.py,sha256=z4l1ctB9RlQmtxwb1Nl-QGtERQ1C_YVVhacx8fzfp7o,20434
4
- gym_examples-3.0.79.dist-info/METADATA,sha256=Tk9FJq9C_mAWmJoehqotrD_lB16I1t70kybNMWtHaVA,411
5
- gym_examples-3.0.79.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
6
- gym_examples-3.0.79.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
7
- gym_examples-3.0.79.dist-info/RECORD,,