gym-examples 3.0.177__py3-none-any.whl → 3.0.179__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 -15
- {gym_examples-3.0.177.dist-info → gym_examples-3.0.179.dist-info}/METADATA +1 -1
- gym_examples-3.0.179.dist-info/RECORD +7 -0
- gym_examples-3.0.177.dist-info/RECORD +0 -7
- {gym_examples-3.0.177.dist-info → gym_examples-3.0.179.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.177.dist-info → gym_examples-3.0.179.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -55,11 +55,9 @@ class WSNRoutingEnv(gym.Env):
|
|
55
55
|
def __init__(self, n_sensors = 20, coverage_radius=(upper_bound - lower_bound)/4):
|
56
56
|
|
57
57
|
super(WSNRoutingEnv, self).__init__()
|
58
|
-
self.log_done = None # Log the done status of the environment
|
59
|
-
self.log_action = None # Log the action taken by the agent
|
60
|
-
self.log_steps = None # Log the number of steps taken by the agent
|
61
58
|
|
62
59
|
# Initialize list of episode metrics
|
60
|
+
episode_return = 0
|
63
61
|
self.number_of_steps = 0 # Total number of steps taken by the agent since the beginning of the training
|
64
62
|
self.episode_returns = []
|
65
63
|
self.episode_std_remaining_energy = []
|
@@ -101,10 +99,7 @@ class WSNRoutingEnv(gym.Env):
|
|
101
99
|
self.episode_packet_delivery_ratio.append(self.packet_delivery_ratio)
|
102
100
|
self.episode_network_lifetime.append(self.network_lifetime)
|
103
101
|
self.episode_average_latency.append(self.average_latency)
|
104
|
-
print(f"Episode: {self.episode_count}")
|
105
|
-
print(f"This episode ends with # Steps: {self.log_steps}")
|
106
|
-
print(f"This episode ends with Done: {self.log_done}")
|
107
|
-
print(f"This episode ends with Action: {self.log_action}")
|
102
|
+
print(f"Episode: {self.episode_count}")
|
108
103
|
print(self.get_metrics())
|
109
104
|
self.sensor_positions = np.random.rand(self.n_sensors, 2) * (upper_bound - lower_bound) + lower_bound
|
110
105
|
self.distance_to_base = np.linalg.norm(self.sensor_positions - base_station_position, axis=1)
|
@@ -130,9 +125,7 @@ class WSNRoutingEnv(gym.Env):
|
|
130
125
|
|
131
126
|
def step(self, actions):
|
132
127
|
actions = [actions[i] for i in range(self.n_agents)] # We want to go back from the MultiDiscrete action space to a tuple of tuple of Discrete action spaces
|
133
|
-
self.steps += 1
|
134
|
-
if os.getenv('PRINT_STATS') == 'True':
|
135
|
-
self.number_of_steps += 1
|
128
|
+
self.steps += 1
|
136
129
|
rewards = [0] * self.n_sensors
|
137
130
|
dones = [False] * self.n_sensors
|
138
131
|
for i, action in enumerate(actions):
|
@@ -216,12 +209,10 @@ class WSNRoutingEnv(gym.Env):
|
|
216
209
|
rewards = np.mean(rewards) # Average the rewards of all agents
|
217
210
|
# print(f"Step: {self.steps}, Rewards: {rewards}, Done: {dones}")
|
218
211
|
dones = all(dones) # Done if all agents are done
|
219
|
-
|
220
|
-
self.log_action = actions
|
221
|
-
self.log_steps = self.steps
|
222
|
-
episode_return += rewards
|
223
|
-
|
212
|
+
|
224
213
|
if os.getenv('PRINT_STATS') == 'True': # We are trying to extract only the statistics for the PPO algorithm
|
214
|
+
self.number_of_steps += 1
|
215
|
+
episode_return += rewards
|
225
216
|
if self.number_of_steps >= num_timesteps:
|
226
217
|
self.episode_returns.append(episode_return)
|
227
218
|
self.episode_std_remaining_energy.append(np.std(self.remaining_energy))
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=yWn262J5hkFmXghnz7ERGnccBp9JEKqIZpFj1-w6zPM,194
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=5FKrURpUWGU5FAzX45F4TbThyGTKbVnkO6Em9yoD_vk,25668
|
4
|
+
gym_examples-3.0.179.dist-info/METADATA,sha256=fFWcwa3cq8RtdyFWjehbkAXWNbdOLOsnEisEOFdfIZ4,412
|
5
|
+
gym_examples-3.0.179.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.179.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.179.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=j60kGbCc8FuDrR2oC1Aj0dXR1XU7IFCPNOHTRS7pqSw,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=iTa-ZOhp1dcQD01KfqB70UbJQI79B9wQeY6fkRpz_rE,26207
|
4
|
-
gym_examples-3.0.177.dist-info/METADATA,sha256=m1AYDNC878oKPiGZ4dJcOEaxak6JFdLUvEuvSU31yoc,412
|
5
|
-
gym_examples-3.0.177.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.177.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.177.dist-info/RECORD,,
|
File without changes
|
File without changes
|