gym-examples 3.0.662__py3-none-any.whl → 3.0.664__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 +22 -1
- {gym_examples-3.0.662.dist-info → gym_examples-3.0.664.dist-info}/METADATA +1 -1
- gym_examples-3.0.664.dist-info/RECORD +7 -0
- gym_examples-3.0.662.dist-info/RECORD +0 -7
- {gym_examples-3.0.662.dist-info → gym_examples-3.0.664.dist-info}/WHEEL +0 -0
- {gym_examples-3.0.662.dist-info → gym_examples-3.0.664.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -58,8 +58,9 @@ class WSNRoutingEnv(gym.Env):
|
|
58
58
|
|
59
59
|
ALGO_NAME = "" # Global flag to control the algorithm name
|
60
60
|
gym_examples_current_version = "" # Global flag to control the gym_examples version
|
61
|
+
coefficients = [] # Global flag for the weights of all the agents
|
61
62
|
|
62
|
-
def __init__(self, n_sensors =
|
63
|
+
def __init__(self, n_sensors = 30, coverage_radius=(upper_bound - lower_bound) * 3/20, num_timesteps = None, version = None):
|
63
64
|
|
64
65
|
super(WSNRoutingEnv, self).__init__()
|
65
66
|
# Create filenames to save statistics for evaluation
|
@@ -97,6 +98,8 @@ class WSNRoutingEnv(gym.Env):
|
|
97
98
|
self.reset()
|
98
99
|
|
99
100
|
def reset(self):
|
101
|
+
print("\n============================================")
|
102
|
+
print(f"Episode count: {self.episode_count}")
|
100
103
|
if self.number_of_steps > 30000: # Change 30000 to a parameter taken from args or kwargs
|
101
104
|
self.episode_returns.append(self.episode_return)
|
102
105
|
observations = self._get_obs()
|
@@ -140,6 +143,9 @@ class WSNRoutingEnv(gym.Env):
|
|
140
143
|
|
141
144
|
self.get_metrics()
|
142
145
|
|
146
|
+
if self.episode_count > 1:
|
147
|
+
print(f"Episode return: {self.episode_return}")
|
148
|
+
|
143
149
|
return self._get_obs()
|
144
150
|
|
145
151
|
|
@@ -231,6 +237,7 @@ class WSNRoutingEnv(gym.Env):
|
|
231
237
|
dones = bool(np.all(dones))
|
232
238
|
|
233
239
|
self.episode_return += rewards
|
240
|
+
|
234
241
|
return self._get_obs(), rewards, dones, self.get_metrics()
|
235
242
|
|
236
243
|
|
@@ -258,6 +265,20 @@ class WSNRoutingEnv(gym.Env):
|
|
258
265
|
def get_avail_actions(self):
|
259
266
|
return [list(range(self.n_sensors + 1)) for _ in range(self.n_sensors)]
|
260
267
|
|
268
|
+
def build_weigths_agents(self, coefficients):
|
269
|
+
'''
|
270
|
+
We would like to compute the similarity score between the agents and the base station:
|
271
|
+
For this, we consider that each agent is represented by a vector constituted of:
|
272
|
+
- number of packets after the action
|
273
|
+
- remaining energy after the action
|
274
|
+
- distance to the base station
|
275
|
+
The vector of the base station is constituted of:
|
276
|
+
- number of packets after the action: all the times, we consider is equal to 0
|
277
|
+
- remaining energy after the action: all the times, we consider is equal to initial_energy
|
278
|
+
- distance to the base station: all the times, we consider is equal to 0
|
279
|
+
'''
|
280
|
+
vector_referee = [0, 0, 1] # Vector of the base station
|
281
|
+
|
261
282
|
|
262
283
|
def update_sensor_energies(self, i, delta_energy):
|
263
284
|
self.remaining_energy[i] -= delta_energy
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=nf1oj2PGof0ZMExWKFk05GXrJ4fwkgUTbCkIKEv3nr8,166
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=tc7KB1SIzx-7Ee1kd3Qttf1LhmvBy5GdqZTa1MFldaI,26363
|
4
|
+
gym_examples-3.0.664.dist-info/METADATA,sha256=H_DM3iYfLc7732DNu4rfn_h-keZQ_IXycxctRHh9pHM,412
|
5
|
+
gym_examples-3.0.664.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-3.0.664.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-3.0.664.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=C4ZusYlaub4xCgqI-7ThaSoyGMMSTO1oJxBIyMCyTMw,166
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=CELBjrF9LYLOItWv7jr8CoUyH8nWRvrFwxzfVl96Tbs,25280
|
4
|
-
gym_examples-3.0.662.dist-info/METADATA,sha256=VRNcl8g9c_I3hj0-i3QbjSCUQYtmYDzH8m02HrrFxqA,412
|
5
|
-
gym_examples-3.0.662.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-3.0.662.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-3.0.662.dist-info/RECORD,,
|
File without changes
|
File without changes
|