gym-examples 3.0.28__py3-none-any.whl → 3.0.29__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 +18 -20
- {gym_examples-3.0.28.dist-info → gym_examples-3.0.29.dist-info}/METADATA +1 -1
- gym_examples-3.0.29.dist-info/RECORD +7 -0
- gym_examples-3.0.28.dist-info/RECORD +0 -7
- {gym_examples-3.0.28.dist-info → gym_examples-3.0.29.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.28.dist-info → gym_examples-3.0.29.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -69,30 +69,29 @@ class WSNRoutingEnv(gym.Env):
|
|
69
69
|
|
70
70
|
|
71
71
|
def reset(self):
|
72
|
-
#
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
72
|
+
# Save the metrics to a CSV file
|
73
|
+
if self.episode_count > 0:
|
74
|
+
with open('metrics.csv', mode='a') as file:
|
75
|
+
writer = csv.writer(file)
|
76
|
+
if self.episode_count == 1:
|
77
|
+
writer.writerow(['Episode', 'Network throughput', 'Energy efficiency', 'Packet delivery ratio', 'Network lifetime', 'Average latency', 'First node dead time'])
|
78
|
+
writer.writerow([self.episode_count - 1, self.network_throughput, self.energy_efficiency, self.packet_delivery_ratio, self.network_lifetime, self.average_latency, self.first_node_dead_time])
|
79
|
+
|
80
|
+
if self.episode_count % 50 == 0 and self.episode_count > 0:
|
81
|
+
print(f"\n========================================")
|
82
|
+
print(f"Episode {self.episode_count} with previous number of steps = {self.steps}")
|
83
|
+
print(f"Network throughput = {self.network_throughput}")
|
84
|
+
print(f"Energy efficiency = {self.energy_efficiency}")
|
85
|
+
print(f"Packet delivery ratio = {self.packet_delivery_ratio}")
|
86
|
+
print(f"Network lifetime = {self.network_lifetime}")
|
87
|
+
print(f"Average latency = {self.average_latency}")
|
88
|
+
print(f"First node dead time = {self.first_node_dead_time}")
|
89
|
+
print(f"========================================\n")
|
90
90
|
self.sensor_positions = np.random.rand(self.n_sensors, 2) * (upper_bound - lower_bound) + lower_bound
|
91
91
|
self.distance_to_base = np.linalg.norm(self.sensor_positions - base_station_position, axis=1)
|
92
92
|
self.remaining_energy = np.ones(self.n_sensors) * initial_energy
|
93
93
|
self.number_of_packets = np.ones(self.n_sensors, dtype=int) * initial_number_of_packets # number of packets to transmit
|
94
94
|
self.episode_count += 1
|
95
|
-
print(f"Episode = {self.episode_count}")
|
96
95
|
|
97
96
|
self.packets_delivered = 0
|
98
97
|
self.total_energy_consumed = 0
|
@@ -112,7 +111,6 @@ class WSNRoutingEnv(gym.Env):
|
|
112
111
|
|
113
112
|
def step(self, actions):
|
114
113
|
self.steps += 1
|
115
|
-
print(f"Step = {self.steps}")
|
116
114
|
rewards = [0] * self.n_sensors
|
117
115
|
dones = [False] * self.n_sensors
|
118
116
|
# if self.episode_count >= 599:
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=kjxQh1V3vNafWtrGjEAWspS0vT9jGH8kmGmDnPcUxpk,193
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=oFnj-yRCNBywQGr8hJ06KJ5JTmhb-upzX3B3_CwlAUw,19422
|
4
|
+
gym_examples-3.0.29.dist-info/METADATA,sha256=YPpF8dCRhKJRhsnbBv5Bl8UY037kVd3PFXxapuBmf6M,411
|
5
|
+
gym_examples-3.0.29.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.29.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.29.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=cV7VZCHK-HyU1olBmWIL6QuUos4gA5dKdALWflNMmgg,193
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=mPeQ5Dwhg2uQEZrBOQliDN-Lng2DTlIRbWDss9Fip04,19571
|
4
|
-
gym_examples-3.0.28.dist-info/METADATA,sha256=FiGGJ4VDZudykxepmHcAedzcmzGJ1CqernPoFn1p55k,411
|
5
|
-
gym_examples-3.0.28.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.28.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.28.dist-info/RECORD,,
|
File without changes
|
File without changes
|