gym-examples 2.0.8__py3-none-any.whl → 2.0.10__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 +5 -8
- {gym_examples-2.0.8.dist-info → gym_examples-2.0.10.dist-info}/METADATA +1 -1
- gym_examples-2.0.10.dist-info/RECORD +7 -0
- gym_examples-2.0.8.dist-info/RECORD +0 -7
- {gym_examples-2.0.8.dist-info → gym_examples-2.0.10.dist-info}/WHEEL +0 -0
- {gym_examples-2.0.8.dist-info → gym_examples-2.0.10.dist-info}/top_level.txt +0 -0
gym_examples/__init__.py
CHANGED
gym_examples/envs/wsn_env.py
CHANGED
@@ -47,7 +47,7 @@ net = net.double() # Convert the weights to Double
|
|
47
47
|
|
48
48
|
|
49
49
|
class WSNRoutingEnv(gym.Env):
|
50
|
-
def __init__(self, n_sensors =
|
50
|
+
def __init__(self, n_sensors = 30, coverage_radius=50):
|
51
51
|
|
52
52
|
super(WSNRoutingEnv, self).__init__()
|
53
53
|
|
@@ -76,14 +76,11 @@ class WSNRoutingEnv(gym.Env):
|
|
76
76
|
self.consumption_energy = np.zeros(self.n_sensors)
|
77
77
|
self.number_of_packets = np.ones(self.n_sensors, dtype=int) # Number of packets to transmit
|
78
78
|
self.episode_count += 1
|
79
|
-
self.step_count = 0
|
80
79
|
return self._get_obs()
|
81
80
|
|
82
81
|
def step(self, actions):
|
83
|
-
print(f"Actions: {actions}")
|
84
82
|
rewards = [0] * self.n_sensors
|
85
83
|
dones = [False] * self.n_sensors
|
86
|
-
self.step_count += 1
|
87
84
|
for i, action in enumerate(actions):
|
88
85
|
|
89
86
|
if action not in range(self.n_sensors + 1):
|
@@ -119,9 +116,9 @@ class WSNRoutingEnv(gym.Env):
|
|
119
116
|
rewards[i] = self.compute_individual_rewards(i, action, neighbors_i, remaining_energy_before)
|
120
117
|
self.number_of_packets[i] = 0 # Reset the number of packets of the sensor i
|
121
118
|
# Calculate final reward
|
122
|
-
|
123
|
-
|
124
|
-
final_reward = sum(rewards[i])
|
119
|
+
rewards_individual = torch.tensor(rewards[i], dtype=torch.double)
|
120
|
+
final_reward = net(rewards_individual)
|
121
|
+
# final_reward = sum(rewards[i])
|
125
122
|
rewards[i] = final_reward
|
126
123
|
|
127
124
|
for i in range(self.n_sensors):
|
@@ -129,7 +126,7 @@ class WSNRoutingEnv(gym.Env):
|
|
129
126
|
dones[i] = True
|
130
127
|
|
131
128
|
# Integrate the mobility of the sensors
|
132
|
-
|
129
|
+
self.integrate_mobility()
|
133
130
|
|
134
131
|
return self._get_obs(), rewards, dones, {}
|
135
132
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+
gym_examples/__init__.py,sha256=Xv8KufaWTkDnJ2noVaDh4OFIlwTqFk5KrsxPDNtkDKM,193
|
2
|
+
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
+
gym_examples/envs/wsn_env.py,sha256=Qc2oUPLVpbyEdBMHEhpxuBd-CcLHvfcIEV37WP2mkU0,15135
|
4
|
+
gym_examples-2.0.10.dist-info/METADATA,sha256=YOCYFjDkD2d9uVAYmKQNDI3V-Ib_G-zPrSH_WrYcjGo,411
|
5
|
+
gym_examples-2.0.10.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
+
gym_examples-2.0.10.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
+
gym_examples-2.0.10.dist-info/RECORD,,
|
@@ -1,7 +0,0 @@
|
|
1
|
-
gym_examples/__init__.py,sha256=fIbIs37EHyLkQTZ5Ms2Qa1NGVpG3opspoUbt_BgWriY,192
|
2
|
-
gym_examples/envs/__init__.py,sha256=lgMe4pyOuUTgTBUddM0iwMlETsYTwFShny6ifm8PGM8,53
|
3
|
-
gym_examples/envs/wsn_env.py,sha256=cpqNN2fOEBE-_w-E4stAPH1VLsxPlIGtoZVV3dHmvhU,15236
|
4
|
-
gym_examples-2.0.8.dist-info/METADATA,sha256=XlQxAfb-C0awmiUAIbEmsli6nSJPMWGZiqJYl1y_UUk,410
|
5
|
-
gym_examples-2.0.8.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
6
|
-
gym_examples-2.0.8.dist-info/top_level.txt,sha256=rJRksoAF32M6lTLBEwYzRdo4PgtejceaNnnZ3HeY_Rk,13
|
7
|
-
gym_examples-2.0.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|