Ihabaa commited on
Commit
a65256f
·
verified ·
1 Parent(s): 3488bcd

undefined - Initial Deployment

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +377 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Mdp
3
- emoji: 🏢
4
- colorFrom: blue
5
- colorTo: red
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: mdp
3
+ emoji: 🐳
4
+ colorFrom: gray
5
+ colorTo: green
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,377 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>UWSN Routing Environment Explained</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
9
+ <style>
10
+ .gradient-bg {
11
+ background: linear-gradient(135deg, #1e3a8a 0%, #0ea5e9 100%);
12
+ }
13
+ .node-card:hover {
14
+ transform: translateY(-5px);
15
+ box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
16
+ }
17
+ .code-block {
18
+ font-family: 'Courier New', monospace;
19
+ background-color: #1e293b;
20
+ color: #f8fafc;
21
+ border-radius: 0.5rem;
22
+ overflow-x: auto;
23
+ }
24
+ </style>
25
+ </head>
26
+ <body class="bg-gray-50 min-h-screen">
27
+ <!-- Header -->
28
+ <header class="gradient-bg text-white py-12">
29
+ <div class="container mx-auto px-4">
30
+ <div class="flex flex-col items-center">
31
+ <i class="fas fa-water text-6xl mb-4"></i>
32
+ <h1 class="text-4xl md:text-5xl font-bold text-center mb-4">Underwater Wireless Sensor Network Routing</h1>
33
+ <p class="text-xl text-center max-w-3xl opacity-90">
34
+ A Reinforcement Learning Environment for Optimal Packet Routing in UWSNs
35
+ </p>
36
+ </div>
37
+ </div>
38
+ </header>
39
+
40
+ <!-- Main Content -->
41
+ <main class="container mx-auto px-4 py-12">
42
+ <!-- Overview Section -->
43
+ <section class="mb-16">
44
+ <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-2">Environment Overview</h2>
45
+ <div class="grid md:grid-cols-2 gap-8">
46
+ <div class="bg-white p-6 rounded-lg shadow-md">
47
+ <h3 class="text-xl font-semibold mb-4 text-blue-600">
48
+ <i class="fas fa-network-wired mr-2"></i> Network Structure
49
+ </h3>
50
+ <p class="text-gray-700 mb-4">
51
+ The environment models an Underwater Wireless Sensor Network (UWSN) with:
52
+ </p>
53
+ <ul class="list-disc pl-6 space-y-2 text-gray-700">
54
+ <li><span class="font-medium">N sensor nodes</span> randomly positioned in 3D space</li>
55
+ <li>One <span class="font-medium">sink node (destination)</span> at a fixed position</li>
56
+ <li>Each node has <span class="font-medium">limited energy</span> that depletes with transmissions</li>
57
+ <li>Nodes can only communicate within a <span class="font-medium">transmission range</span></li>
58
+ </ul>
59
+ </div>
60
+ <div class="bg-white p-6 rounded-lg shadow-md">
61
+ <h3 class="text-xl font-semibold mb-4 text-blue-600">
62
+ <i class="fas fa-robot mr-2"></i> Reinforcement Learning Setup
63
+ </h3>
64
+ <p class="text-gray-700 mb-4">
65
+ The environment follows the standard Gymnasium interface for RL:
66
+ </p>
67
+ <ul class="list-disc pl-6 space-y-2 text-gray-700">
68
+ <li><span class="font-medium">State space:</span> Local node info + neighbor metrics</li>
69
+ <li><span class="font-medium">Action space:</span> Forward to neighbor or drop packet</li>
70
+ <li><span class="font-medium">Reward function:</span> Balances success with energy, distance, and link quality</li>
71
+ <li><span class="font-medium">Termination:</span> When packet reaches sink or is dropped</li>
72
+ </ul>
73
+ </div>
74
+ </div>
75
+ </section>
76
+
77
+ <!-- Visualization Section -->
78
+ <section class="mb-16">
79
+ <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-2">Network Visualization</h2>
80
+ <div class="bg-white p-6 rounded-lg shadow-md">
81
+ <div class="relative h-96 w-full bg-gray-100 rounded-lg overflow-hidden">
82
+ <!-- This would be a 3D visualization in a real implementation -->
83
+ <div class="absolute inset-0 flex items-center justify-center">
84
+ <div class="text-center">
85
+ <i class="fas fa-water text-6xl text-blue-300 mb-4"></i>
86
+ <p class="text-gray-600">Interactive 3D network visualization would appear here</p>
87
+ </div>
88
+ </div>
89
+
90
+ <!-- Simulated nodes -->
91
+ <div class="absolute top-1/4 left-1/4 w-8 h-8 bg-blue-500 rounded-full flex items-center justify-center text-white font-bold shadow-lg">
92
+ S
93
+ </div>
94
+ <div class="absolute top-1/3 left-1/3 w-6 h-6 bg-green-500 rounded-full flex items-center justify-center text-white font-bold shadow-md">
95
+ 1
96
+ </div>
97
+ <div class="absolute top-1/2 left-1/2 w-6 h-6 bg-green-500 rounded-full flex items-center justify-center text-white font-bold shadow-md">
98
+ 2
99
+ </div>
100
+ <div class="absolute top-2/3 left-2/3 w-6 h-6 bg-green-500 rounded-full flex items-center justify-center text-white font-bold shadow-md">
101
+ 3
102
+ </div>
103
+ <div class="absolute top-3/4 left-1/4 w-6 h-6 bg-green-500 rounded-full flex items-center justify-center text-white font-bold shadow-md">
104
+ 4
105
+ </div>
106
+
107
+ <!-- Simulated connections -->
108
+ <div class="absolute top-1/4 left-1/4 w-px h-16 bg-blue-300 transform rotate-45 origin-top"></div>
109
+ <div class="absolute top-1/4 left-1/4 w-px h-24 bg-blue-300 transform -rotate-30 origin-top"></div>
110
+ <div class="absolute top-1/3 left-1/3 w-px h-16 bg-green-300 transform rotate-15 origin-top"></div>
111
+ </div>
112
+
113
+ <div class="mt-6 grid grid-cols-2 md:grid-cols-4 gap-4">
114
+ <div class="bg-blue-50 p-3 rounded-lg flex items-center">
115
+ <div class="w-3 h-3 bg-blue-500 rounded-full mr-2"></div>
116
+ <span>Sink Node</span>
117
+ </div>
118
+ <div class="bg-green-50 p-3 rounded-lg flex items-center">
119
+ <div class="w-3 h-3 bg-green-500 rounded-full mr-2"></div>
120
+ <span>Sensor Nodes</span>
121
+ </div>
122
+ <div class="bg-blue-100 p-3 rounded-lg flex items-center">
123
+ <div class="w-3 h-3 bg-blue-300 rounded-full mr-2"></div>
124
+ <span>Active Links</span>
125
+ </div>
126
+ <div class="bg-gray-100 p-3 rounded-lg flex items-center">
127
+ <div class="w-3 h-3 bg-gray-400 rounded-full mr-2"></div>
128
+ <span>Inactive Links</span>
129
+ </div>
130
+ </div>
131
+ </div>
132
+ </section>
133
+
134
+ <!-- Key Components Section -->
135
+ <section class="mb-16">
136
+ <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-2">Key Environment Components</h2>
137
+
138
+ <!-- State Space -->
139
+ <div class="bg-white p-6 rounded-lg shadow-md mb-8">
140
+ <h3 class="text-2xl font-semibold mb-4 text-blue-600">
141
+ <i class="fas fa-database mr-2"></i> State Space
142
+ </h3>
143
+ <p class="text-gray-700 mb-4">
144
+ The observation space provides the agent with information about:
145
+ </p>
146
+
147
+ <div class="grid md:grid-cols-2 gap-6">
148
+ <div>
149
+ <h4 class="font-medium text-lg mb-2 text-gray-800">Local Node Information</h4>
150
+ <div class="code-block p-4 mb-4">
151
+ <pre>{
152
+ "energy": 50.0, # Current node's remaining energy
153
+ "position": [x, y, z] # 3D coordinates of current node
154
+ }</pre>
155
+ </div>
156
+ </div>
157
+ <div>
158
+ <h4 class="font-medium text-lg mb-2 text-gray-800">Neighbor Information</h4>
159
+ <div class="code-block p-4">
160
+ <pre>{
161
+ "energy": 45.0, # Neighbor's remaining energy
162
+ "distance": 25.3, # Distance to neighbor
163
+ "RSSI": -75.2, # Received Signal Strength
164
+ "SNR": 15.8, # Signal-to-Noise Ratio
165
+ "PDR": 0.92 # Packet Delivery Ratio
166
+ }</pre>
167
+ </div>
168
+ </div>
169
+ </div>
170
+ </div>
171
+
172
+ <!-- Action Space -->
173
+ <div class="bg-white p-6 rounded-lg shadow-md mb-8">
174
+ <h3 class="text-2xl font-semibold mb-4 text-blue-600">
175
+ <i class="fas fa-running mr-2"></i> Action Space
176
+ </h3>
177
+ <p class="text-gray-700 mb-4">
178
+ The agent can choose from the following actions:
179
+ </p>
180
+
181
+ <div class="grid md:grid-cols-3 gap-4">
182
+ <div class="node-card bg-green-50 p-4 rounded-lg border border-green-200 transition-all duration-300">
183
+ <div class="flex items-center mb-2">
184
+ <div class="w-8 h-8 bg-green-500 rounded-full flex items-center justify-center text-white font-bold mr-3">N</div>
185
+ <h4 class="font-medium">Forward to Neighbor N</h4>
186
+ </div>
187
+ <p class="text-sm text-gray-600">Transmit packet to selected neighbor node</p>
188
+ </div>
189
+ <div class="node-card bg-blue-50 p-4 rounded-lg border border-blue-200 transition-all duration-300">
190
+ <div class="flex items-center mb-2">
191
+ <div class="w-8 h-8 bg-blue-500 rounded-full flex items-center justify-center text-white font-bold mr-3">0</div>
192
+ <h4 class="font-medium">Forward to Sink</h4>
193
+ </div>
194
+ <p class="text-sm text-gray-600">Direct transmission to destination node</p>
195
+ </div>
196
+ <div class="node-card bg-red-50 p-4 rounded-lg border border-red-200 transition-all duration-300">
197
+ <div class="flex items-center mb-2">
198
+ <div class="w-8 h-8 bg-red-500 rounded-full flex items-center justify-center text-white font-bold mr-3">X</div>
199
+ <h4 class="font-medium">Drop Packet</h4>
200
+ </div>
201
+ <p class="text-sm text-gray-600">Terminate transmission (penalized)</p>
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <!-- Reward Function -->
207
+ <div class="bg-white p-6 rounded-lg shadow-md">
208
+ <h3 class="text-2xl font-semibold mb-4 text-blue-600">
209
+ <i class="fas fa-coins mr-2"></i> Reward Function
210
+ </h3>
211
+ <p class="text-gray-700 mb-4">
212
+ The reward balances multiple objectives to encourage efficient routing:
213
+ </p>
214
+
215
+ <div class="code-block p-4 mb-6">
216
+ <pre>reward = R_success # Base reward for success
217
+ - β * distance² # Penalize long distances
218
+ - η * energy_consumed # Penalize high energy use
219
+ - δ * (1 - PDR) # Penalize poor link quality
220
+ - θ * (1 / residual_energy) # Penalize low-energy nodes</pre>
221
+ </div>
222
+
223
+ <div class="grid md:grid-cols-2 gap-6">
224
+ <div>
225
+ <h4 class="font-medium text-lg mb-2 text-gray-800">Reward Components</h4>
226
+ <ul class="space-y-3">
227
+ <li class="flex items-start">
228
+ <div class="bg-blue-100 p-1 rounded-full mr-3 mt-1">
229
+ <i class="fas fa-check-circle text-blue-500 text-sm"></i>
230
+ </div>
231
+ <span><span class="font-medium">R_success:</span> Fixed reward for reaching sink</span>
232
+ </li>
233
+ <li class="flex items-start">
234
+ <div class="bg-red-100 p-1 rounded-full mr-3 mt-1">
235
+ <i class="fas fa-times-circle text-red-500 text-sm"></i>
236
+ </div>
237
+ <span><span class="font-medium">Distance penalty:</span> Discourages long hops</span>
238
+ </li>
239
+ <li class="flex items-start">
240
+ <div class="bg-red-100 p-1 rounded-full mr-3 mt-1">
241
+ <i class="fas fa-times-circle text-red-500 text-sm"></i>
242
+ </div>
243
+ <span><span class="font-medium">Energy penalty:</span> Conserves network energy</span>
244
+ </li>
245
+ <li class="flex items-start">
246
+ <div class="bg-red-100 p-1 rounded-full mr-3 mt-1">
247
+ <i class="fas fa-times-circle text-red-500 text-sm"></i>
248
+ </div>
249
+ <span><span class="font-medium">Link quality penalty:</span> Encourages reliable paths</span>
250
+ </li>
251
+ </ul>
252
+ </div>
253
+ <div>
254
+ <h4 class="font-medium text-lg mb-2 text-gray-800">Example Scenarios</h4>
255
+ <ul class="space-y-3">
256
+ <li class="flex items-start">
257
+ <div class="bg-green-100 p-1 rounded-full mr-3 mt-1">
258
+ <i class="fas fa-arrow-up text-green-500 text-sm"></i>
259
+ </div>
260
+ <span><span class="font-medium">Short, efficient path:</span> High reward</span>
261
+ </li>
262
+ <li class="flex items-start">
263
+ <div class="bg-yellow-100 p-1 rounded-full mr-3 mt-1">
264
+ <i class="fas fa-equals text-yellow-500 text-sm"></i>
265
+ </div>
266
+ <span><span class="font-medium">Long but reliable path:</span> Moderate reward</span>
267
+ </li>
268
+ <li class="flex items-start">
269
+ <div class="bg-red-100 p-1 rounded-full mr-3 mt-1">
270
+ <i class="fas fa-arrow-down text-red-500 text-sm"></i>
271
+ </div>
272
+ <span><span class="font-medium">Dropped packet:</span> Significant penalty</span>
273
+ </li>
274
+ </ul>
275
+ </div>
276
+ </div>
277
+ </div>
278
+ </section>
279
+
280
+ <!-- Technical Details Section -->
281
+ <section>
282
+ <h2 class="text-3xl font-bold mb-6 text-gray-800 border-b pb-2">Technical Implementation</h2>
283
+
284
+ <div class="grid md:grid-cols-2 gap-8">
285
+ <!-- Initialization -->
286
+ <div class="bg-white p-6 rounded-lg shadow-md">
287
+ <h3 class="text-xl font-semibold mb-4 text-blue-600">
288
+ <i class="fas fa-cogs mr-2"></i> Environment Initialization
289
+ </h3>
290
+ <div class="code-block p-4 mb-4">
291
+ <pre>def __init__(self, num_nodes=10, max_energy=100,
292
+ initial_energy=50, transmission_range=100):
293
+ # Initialize node positions randomly in 3D space
294
+ self.node_positions = np.random.uniform(0, 100, size=(num_nodes, 3))
295
+
296
+ # Set initial energies
297
+ self.node_energies = np.full(num_nodes, initial_energy)
298
+
299
+ # Define action space (forward to any node or drop)
300
+ self.action_space = gym.spaces.Discrete(num_nodes + 1)
301
+
302
+ # Define observation space (local + neighbor info)
303
+ self.observation_space = gym.spaces.Dict(...)</pre>
304
+ </div>
305
+ <p class="text-gray-700">
306
+ The environment is initialized with configurable parameters for network size, energy levels, and transmission range.
307
+ </p>
308
+ </div>
309
+
310
+ <!-- Step Function -->
311
+ <div class="bg-white p-6 rounded-lg shadow-md">
312
+ <h3 class="text-xl font-semibold mb-4 text-blue-600">
313
+ <i class="fas fa-code-branch mr-2"></i> Step Function
314
+ </h3>
315
+ <div class="code-block p-4 mb-4">
316
+ <pre>def step(self, action):
317
+ if action == "drop":
318
+ reward = -10
319
+ terminated = True
320
+ elif action == sink_node:
321
+ reward = R_success
322
+ terminated = True
323
+ else:
324
+ # Calculate multi-component reward
325
+ reward = compute_reward(current_node, action)
326
+ # Update node energy
327
+ self.node_energies[action] -= 1
328
+
329
+ return observation, reward, terminated, truncated, info</pre>
330
+ </div>
331
+ <p class="text-gray-700">
332
+ The step function handles packet forwarding, energy consumption, and computes the multi-objective reward.
333
+ </p>
334
+ </div>
335
+ </div>
336
+ </section>
337
+ </main>
338
+
339
+ <!-- Footer -->
340
+ <footer class="gradient-bg text-white py-8">
341
+ <div class="container mx-auto px-4">
342
+ <div class="flex flex-col md:flex-row justify-between items-center">
343
+ <div class="mb-4 md:mb-0">
344
+ <h3 class="text-xl font-bold">UWSN Routing Environment</h3>
345
+ <p class="text-blue-100">A Gymnasium-compatible RL environment</p>
346
+ </div>
347
+ <div class="flex space-x-4">
348
+ <a href="#" class="text-white hover:text-blue-200 transition">
349
+ <i class="fab fa-github text-2xl"></i>
350
+ </a>
351
+ <a href="#" class="text-white hover:text-blue-200 transition">
352
+ <i class="fab fa-python text-2xl"></i>
353
+ </a>
354
+ <a href="#" class="text-white hover:text-blue-200 transition">
355
+ <i class="fas fa-book text-2xl"></i>
356
+ </a>
357
+ </div>
358
+ </div>
359
+ <div class="mt-6 text-center text-blue-100 text-sm">
360
+ <p>© 2023 Underwater Wireless Sensor Network RL Project</p>
361
+ </div>
362
+ </div>
363
+ </footer>
364
+
365
+ <script>
366
+ // Simple animation for node cards
367
+ document.querySelectorAll('.node-card').forEach(card => {
368
+ card.addEventListener('mouseenter', () => {
369
+ card.classList.add('shadow-lg');
370
+ });
371
+ card.addEventListener('mouseleave', () => {
372
+ card.classList.remove('shadow-lg');
373
+ });
374
+ });
375
+ </script>
376
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Ihabaa/mdp" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
377
+ </html>