gym-examples 3.0.84__py3-none-any.whl → 3.0.87__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 +11 -6
- {gym_examples-3.0.84.dist-info → gym_examples-3.0.87.dist-info}/METADATA +1 -1
- gym_examples-3.0.87.dist-info/RECORD +7 -0
- gym_examples-3.0.84.dist-info/RECORD +0 -7
- {gym_examples-3.0.84.dist-info → gym_examples-3.0.87.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.84.dist-info → gym_examples-3.0.87.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -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):
|
@@ -152,7 +154,7 @@ class WSNRoutingEnv(gym.Env):
|
|
152
154
|
self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
|
153
155
|
# Calculate final reward
|
154
156
|
rewards[i] = self.compute_attention_rewards(rewards[i])
|
155
|
-
# 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,8 +305,9 @@ class WSNRoutingEnv(gym.Env):
|
|
303
305
|
|
304
306
|
#-- rewards related to the performance metrics
|
305
307
|
reward_latency = self.compute_reward_latency()
|
306
|
-
|
307
|
-
|
308
|
+
|
309
|
+
reward_network_throughput = self.compute_reward_network_throughput()
|
310
|
+
reward_packet_delivery_ratio = self.compute_reward_packet_delivery_ratio()
|
308
311
|
|
309
312
|
rewards_performance = np.array([reward_latency, reward_network_throughput, reward_packet_delivery_ratio])
|
310
313
|
if self.episode_count == 455:
|
@@ -367,11 +370,13 @@ class WSNRoutingEnv(gym.Env):
|
|
367
370
|
return np.clip(normalized_throughput, 0, 1)
|
368
371
|
|
369
372
|
|
370
|
-
def
|
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
|
-
|
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
|
'''
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=kmxBjfobFw5EHQd_ejxn9bhk6N2-WnNmXpUm81eK2R8,193
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=yYEht3QO9hrMesdRCzA6gTZJhWrmrgfdyQ3__64nR3s,21009
|
4
|
+
gym_examples-3.0.87.dist-info/METADATA,sha256=c01C0upEC9mVW9T03NdYeHBvaJlyP935fxzI_tRKR3s,411
|
5
|
+
gym_examples-3.0.87.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.87.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.87.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=ST4s9tIt_yRybwlLKBLIlKL30PMwUmD-6X2XJakhv_0,193
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=yJyhA_VVM00Pju7fYBBk2HAYas5ws_iZsSfQZBUFb74,20672
|
4
|
-
gym_examples-3.0.84.dist-info/METADATA,sha256=ZGgIUW9Y3i1fJFP8XI6M2ejWyTBzhtu01ZDU7y_2YfA,411
|
5
|
-
gym_examples-3.0.84.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.84.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.84.dist-info/RECORD,,
|
File without changes
|
File without changes
|