gym-examples 3.0.284__py3-none-any.whl → 3.0.286__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 +6 -7
- {gym_examples-3.0.284.dist-info → gym_examples-3.0.286.dist-info}/METADATA +1 -1
- gym_examples-3.0.286.dist-info/RECORD +7 -0
- gym_examples-3.0.284.dist-info/RECORD +0 -7
- {gym_examples-3.0.284.dist-info → gym_examples-3.0.286.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.284.dist-info → gym_examples-3.0.286.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -81,10 +81,7 @@ class WSNRoutingEnv(gym.Env):
|
|
81
81
|
)
|
82
82
|
|
83
83
|
# self.action_space = Tuple(tuple([Discrete(self.n_sensors + 1)] * self.n_agents))
|
84
|
-
|
85
|
-
# self.action_space = MultiDiscrete([self.n_agents, self.n_sensors + 1])
|
86
|
-
# self.action_space = Discrete(self.n_sensors + 1) # +1 for the base station
|
87
|
-
self.action_space = Discrete((self.n_sensors + 1)**self.n_agents)
|
84
|
+
self.action_space = MultiDiscrete([self.n_sensors + 1] * self.n_agents)
|
88
85
|
|
89
86
|
self.reset()
|
90
87
|
|
@@ -120,7 +117,6 @@ class WSNRoutingEnv(gym.Env):
|
|
120
117
|
self.steps += 1
|
121
118
|
rewards = [-max_reward] * self.n_sensors
|
122
119
|
dones = [False] * self.n_sensors
|
123
|
-
actions = self.to_base_n(actions, self.n_sensors + 1)
|
124
120
|
for i, action in enumerate(actions):
|
125
121
|
if self.remaining_energy[i] <= 0 or self.number_of_packets[i] <= 0:
|
126
122
|
continue # Skip if sensor has no energy left or no packets to transmit
|
@@ -173,7 +169,7 @@ class WSNRoutingEnv(gym.Env):
|
|
173
169
|
self.packet_latency[action] += self.packet_latency[i] + latency_per_hop
|
174
170
|
self.packet_latency[i] = 0
|
175
171
|
|
176
|
-
rewards = self.compute_individual_rewards(i, action)
|
172
|
+
rewards[i] = self.compute_individual_rewards(i, action)
|
177
173
|
|
178
174
|
# Update the number of packets
|
179
175
|
self.number_of_packets[action] += self.number_of_packets[i]
|
@@ -181,7 +177,7 @@ class WSNRoutingEnv(gym.Env):
|
|
181
177
|
self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
|
182
178
|
# Calculate final reward
|
183
179
|
# rewards[i] = self.compute_attention_rewards(rewards[i])
|
184
|
-
rewards = np.mean(rewards)
|
180
|
+
rewards[i] = np.mean(rewards[i])
|
185
181
|
|
186
182
|
# Integrate the mobility of the sensors
|
187
183
|
# self.integrate_mobility()
|
@@ -194,9 +190,12 @@ class WSNRoutingEnv(gym.Env):
|
|
194
190
|
self.get_metrics()
|
195
191
|
|
196
192
|
rewards = [reward.item() if isinstance(reward, torch.Tensor) else reward for reward in rewards] # Convert the reward to a float
|
193
|
+
rewards = np.mean(rewards) # Average the rewards
|
194
|
+
|
197
195
|
for i in range(self.n_sensors):
|
198
196
|
if not dones[i]:
|
199
197
|
dones[i] = self.remaining_energy[i] <= 0 or self.number_of_packets[i] == 0
|
198
|
+
dones = np.all(dones)
|
200
199
|
|
201
200
|
return self._get_obs(), rewards, dones, self.get_metrics()
|
202
201
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=1GK2OycRc394qAo5oxOKW-VdY8PGCGL8BGGeb7kYZmo,166
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=IxZOztoXNUFBhjzrZ_jw0nRg1EhPtTMYDOj6G2-ZT9U,23292
|
4
|
+
gym_examples-3.0.286.dist-info/METADATA,sha256=Mu-PCSCgadaSrJI2QGlySSqtueil18a73qsvuIwyZxo,412
|
5
|
+
gym_examples-3.0.286.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.286.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.286.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=SbYVbDAngXH8S9SM6aQijqGwMUt-FSXYtOV00-_0ahI,166
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=VzbARUwPIdS6-RkQND3dxx0lLheFpP6NqaBwT5JY91o,23503
|
4
|
-
gym_examples-3.0.284.dist-info/METADATA,sha256=U9huJCLpn-NIXHhbpD97MFIY_WpCrOxX7ebSgLBsf_w,412
|
5
|
-
gym_examples-3.0.284.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.284.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.284.dist-info/RECORD,,
|
File without changes
|
File without changes
|