gym-examples 3.0.765__py3-none-any.whl → 3.0.766__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 +10 -7
- {gym_examples-3.0.765.dist-info → gym_examples-3.0.766.dist-info}/METADATA +1 -1
- gym_examples-3.0.766.dist-info/RECORD +7 -0
- gym_examples-3.0.765.dist-info/RECORD +0 -7
- {gym_examples-3.0.765.dist-info → gym_examples-3.0.766.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.765.dist-info → gym_examples-3.0.766.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -167,7 +167,7 @@ class WSNRoutingEnv(gym.Env):
|
|
167
167
|
# Calculate the energy consumption for transmitting data to the base station
|
168
168
|
transmission_energy = self.transmission_energy(self.number_of_packets[i], self.distance_to_base[i])
|
169
169
|
if self.remaining_energy[i] < transmission_energy:
|
170
|
-
self.remaining_energy[i] = 0
|
170
|
+
# self.remaining_energy[i] = 0
|
171
171
|
continue # Skip if the sensor does not have enough energy to transmit data to the base station
|
172
172
|
|
173
173
|
self.update_sensor_energies(i, transmission_energy)
|
@@ -179,6 +179,8 @@ class WSNRoutingEnv(gym.Env):
|
|
179
179
|
self.total_latency += self.packet_latency[i] + latency_per_hop
|
180
180
|
self.packet_latency[i] = 0
|
181
181
|
|
182
|
+
self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
|
183
|
+
|
182
184
|
rewards[i] = np.array([max_reward] * input_dim) # Reward for transmitting data to the base station
|
183
185
|
dones[i] = True
|
184
186
|
else:
|
@@ -189,14 +191,15 @@ class WSNRoutingEnv(gym.Env):
|
|
189
191
|
transmission_energy = self.transmission_energy(self.number_of_packets[i], distance)
|
190
192
|
reception_energy = self.reception_energy(self.number_of_packets[i])
|
191
193
|
if self.remaining_energy[i] < transmission_energy:
|
192
|
-
self.remaining_energy[i] = 0
|
194
|
+
# self.remaining_energy[i] = 0
|
193
195
|
continue # Skip if the sensor does not have enough energy to transmit data to the next hop
|
196
|
+
|
197
|
+
self.update_sensor_energies(i, transmission_energy)
|
198
|
+
|
194
199
|
if self.remaining_energy[action] < reception_energy:
|
195
|
-
self.
|
196
|
-
self.remaining_energy[action] = 0
|
200
|
+
# self.remaining_energy[action] = 0
|
197
201
|
continue # Skip if the next hop does not have enough energy to receive data
|
198
202
|
|
199
|
-
self.update_sensor_energies(i, transmission_energy)
|
200
203
|
self.update_sensor_energies(action, reception_energy)
|
201
204
|
|
202
205
|
# Update the metrics
|
@@ -210,7 +213,7 @@ class WSNRoutingEnv(gym.Env):
|
|
210
213
|
# Update the number of packets
|
211
214
|
self.number_of_packets[action] += self.number_of_packets[i]
|
212
215
|
|
213
|
-
|
216
|
+
self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
|
214
217
|
|
215
218
|
# Integrate the mobility of the sensors
|
216
219
|
# self.integrate_mobility()
|
@@ -497,7 +500,7 @@ class WSNRoutingEnv(gym.Env):
|
|
497
500
|
# Weighted sum of the rewards
|
498
501
|
final_reward = sum([attention_weight * reward for attention_weight, reward in zip(attention_weights, rewards)])
|
499
502
|
|
500
|
-
return np.
|
503
|
+
return np.sum(final_reward)
|
501
504
|
|
502
505
|
|
503
506
|
def integrate_mobility(self):
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=oGBLNhUkMsxNUxrD6aMbIe9qHF4IwLFTzFobdBSE9pM,166
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=YyPRExlOFIEDI0NLhaAX6LwOmJgGLw5WU8G-pvD8wVc,26532
|
4
|
+
gym_examples-3.0.766.dist-info/METADATA,sha256=QMrQjl8_UfOylLp1Aw0TvEtriDzm576Rji5sTS2gtZk,412
|
5
|
+
gym_examples-3.0.766.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.766.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.766.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=lAcZyNHFpvqay_Ku_ZPsmDHzPBLETVDYUAJlyG-Et30,166
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=P0SHQeeyYeLUW6XxQTQ5fiDhsOr2IJVxGVjr8FzF0Eg,26461
|
4
|
-
gym_examples-3.0.765.dist-info/METADATA,sha256=QZEeaeItoN1ALsY08KtHUnzCZoNOqlk9slZuSfnX3fw,412
|
5
|
-
gym_examples-3.0.765.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.765.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.765.dist-info/RECORD,,
|
File without changes
|
File without changes
|