gym-examples 3.0.178__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 -16
- {gym_examples-3.0.178.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.178.dist-info/RECORD +0 -7
- {gym_examples-3.0.178.dist-info → gym_examples-3.0.179.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.178.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,12 +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
|
63
|
-
episode_return =
|
60
|
+
episode_return = 0
|
64
61
|
self.number_of_steps = 0 # Total number of steps taken by the agent since the beginning of the training
|
65
62
|
self.episode_returns = []
|
66
63
|
self.episode_std_remaining_energy = []
|
@@ -102,10 +99,7 @@ class WSNRoutingEnv(gym.Env):
|
|
102
99
|
self.episode_packet_delivery_ratio.append(self.packet_delivery_ratio)
|
103
100
|
self.episode_network_lifetime.append(self.network_lifetime)
|
104
101
|
self.episode_average_latency.append(self.average_latency)
|
105
|
-
print(f"Episode: {self.episode_count}")
|
106
|
-
print(f"This episode ends with # Steps: {self.log_steps}")
|
107
|
-
print(f"This episode ends with Done: {self.log_done}")
|
108
|
-
print(f"This episode ends with Action: {self.log_action}")
|
102
|
+
print(f"Episode: {self.episode_count}")
|
109
103
|
print(self.get_metrics())
|
110
104
|
self.sensor_positions = np.random.rand(self.n_sensors, 2) * (upper_bound - lower_bound) + lower_bound
|
111
105
|
self.distance_to_base = np.linalg.norm(self.sensor_positions - base_station_position, axis=1)
|
@@ -131,9 +125,7 @@ class WSNRoutingEnv(gym.Env):
|
|
131
125
|
|
132
126
|
def step(self, actions):
|
133
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
|
134
|
-
self.steps += 1
|
135
|
-
if os.getenv('PRINT_STATS') == 'True':
|
136
|
-
self.number_of_steps += 1
|
128
|
+
self.steps += 1
|
137
129
|
rewards = [0] * self.n_sensors
|
138
130
|
dones = [False] * self.n_sensors
|
139
131
|
for i, action in enumerate(actions):
|
@@ -217,12 +209,10 @@ class WSNRoutingEnv(gym.Env):
|
|
217
209
|
rewards = np.mean(rewards) # Average the rewards of all agents
|
218
210
|
# print(f"Step: {self.steps}, Rewards: {rewards}, Done: {dones}")
|
219
211
|
dones = all(dones) # Done if all agents are done
|
220
|
-
|
221
|
-
self.log_action = actions
|
222
|
-
self.log_steps = self.steps
|
223
|
-
episode_return += rewards
|
224
|
-
|
212
|
+
|
225
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
|
226
216
|
if self.number_of_steps >= num_timesteps:
|
227
217
|
self.episode_returns.append(episode_return)
|
228
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=dKB7fxf-b5wOgFhNlcNdhFqGY0_sagdM3FVbJyd2xBM,194
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=MsDYLY0-6ngqgziKcJ5BET701GWX6OU1qoh3FMTezcs,26238
|
4
|
-
gym_examples-3.0.178.dist-info/METADATA,sha256=zRHR4aBsr9tc5dwMeqysMfhLm8823FOnSCj7tph9DaM,412
|
5
|
-
gym_examples-3.0.178.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.178.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.178.dist-info/RECORD,,
|
File without changes
|
File without changes
|