vlcSim 0.2.5__tar.gz → 0.3.0__tar.gz
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.
- {vlcSim-0.2.5 → vlcSim-0.3.0}/PKG-INFO +26 -26
- {vlcSim-0.2.5 → vlcSim-0.3.0}/README.md +25 -25
- {vlcSim-0.2.5 → vlcSim-0.3.0}/setup.py +1 -1
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcSim.egg-info/PKG-INFO +26 -26
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcsim/controller.py +16 -2
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcsim/scene.py +130 -1
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcsim/simulator.py +55 -13
- {vlcSim-0.2.5 → vlcSim-0.3.0}/LICENSE.md +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/setup.cfg +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/test/test_receiver.py +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/test/test_scenario.py +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/test/test_vled.py +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcSim.egg-info/SOURCES.txt +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcSim.egg-info/dependency_links.txt +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcSim.egg-info/not-zip-safe +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcSim.egg-info/requires.txt +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcSim.egg-info/top_level.txt +0 -0
- {vlcSim-0.2.5 → vlcSim-0.3.0}/vlcsim/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vlcSim
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python Package of Event-Oriented Simulation for visible light communication
|
|
5
5
|
Home-page: https://gitlab.com/DaniloBorquez/simvlc/
|
|
6
6
|
Author: Danilo Bórquez-Paredes
|
|
@@ -45,17 +45,28 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
45
45
|
for vled in vleds:
|
|
46
46
|
capacities.append(scenario.capacityVled(receiver, vled))
|
|
47
47
|
posBestCapacity = capacities.index(max(capacities))
|
|
48
|
-
|
|
48
|
+
numberOfSlices = 0
|
|
49
|
+
if (
|
|
50
|
+
controller.numberOfActiveConnections(vleds[posBestCapacity]) > 5
|
|
51
|
+
or capacities[posBestCapacity] == 0
|
|
52
|
+
):
|
|
49
53
|
connection.AP = scenario.rfs[0]
|
|
54
|
+
connection.receiver.capacityFromAP = scenario.capacityRf(
|
|
55
|
+
receiver, connection.AP
|
|
56
|
+
)
|
|
57
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
58
|
+
connection.capacityRequired, connection.receiver.capacityFromAP
|
|
59
|
+
)
|
|
50
60
|
else:
|
|
51
61
|
connection.AP = vleds[posBestCapacity]
|
|
62
|
+
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
63
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
64
|
+
connection.capacityRequired, capacities[posBestCapacity]
|
|
65
|
+
)
|
|
52
66
|
|
|
53
|
-
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
54
|
-
connection.capacityRequired, capacities[posBestCapacity]
|
|
55
|
-
)
|
|
56
|
-
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
57
67
|
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP)
|
|
58
68
|
aux = 0
|
|
69
|
+
auxFrame = 0
|
|
59
70
|
|
|
60
71
|
# Actual frame
|
|
61
72
|
for slice in range(actualSlice, connection.AP.slicesInFrame):
|
|
@@ -73,18 +84,13 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
73
84
|
if controller.framesState(connection.AP)[frameIndex][slice] == False:
|
|
74
85
|
connection.assignFrameSlice(frameIndex, slice)
|
|
75
86
|
aux += 1
|
|
87
|
+
auxFrame = frameIndex
|
|
76
88
|
break
|
|
77
89
|
|
|
78
90
|
if aux == numberOfSlices:
|
|
79
91
|
break
|
|
80
92
|
|
|
81
|
-
frameIndex =
|
|
82
|
-
1
|
|
83
|
-
if len(controller.framesState(connection.AP)) == 0
|
|
84
|
-
else len(controller.framesState(connection.AP))
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
frameIndex = len(controller.framesState(connection.AP))
|
|
93
|
+
frameIndex = auxFrame + 1
|
|
88
94
|
while aux < numberOfSlices:
|
|
89
95
|
connection.assignFrameSlice(frameIndex, 0)
|
|
90
96
|
frameIndex += 1
|
|
@@ -95,25 +101,25 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
95
101
|
if __name__ == "__main__":
|
|
96
102
|
# Simulator Constructor: size of the room, with the numbrer of grids and the rho parameter
|
|
97
103
|
|
|
98
|
-
sim = Simulator(
|
|
104
|
+
sim = Simulator(20.0, 20.0, 2.15, 10, 0.8)
|
|
99
105
|
|
|
100
106
|
# Adding Vleds to the room
|
|
101
|
-
vled = VLed(-
|
|
107
|
+
vled = VLed(-7.5, -7.5, 2.15, 60, 60, 20, 70)
|
|
102
108
|
vled.sliceTime = 0.2
|
|
103
109
|
vled.slicesInFrame = 10
|
|
104
110
|
vled.B = 0.5e5
|
|
105
111
|
sim.scenario.addVLed(vled)
|
|
106
|
-
vled = VLed(-
|
|
112
|
+
vled = VLed(-7.5, 7.5, 2.15, 60, 60, 20, 70)
|
|
107
113
|
vled.sliceTime = 0.2
|
|
108
114
|
vled.slicesInFrame = 10
|
|
109
115
|
vled.B = 0.5e5
|
|
110
116
|
sim.scenario.addVLed(vled)
|
|
111
|
-
vled = VLed(
|
|
117
|
+
vled = VLed(7.5, -7.5, 2.15, 60, 60, 20, 70)
|
|
112
118
|
vled.sliceTime = 0.2
|
|
113
119
|
vled.slicesInFrame = 10
|
|
114
120
|
vled.B = 0.5e5
|
|
115
121
|
sim.scenario.addVLed(vled)
|
|
116
|
-
vled = VLed(
|
|
122
|
+
vled = VLed(7.5, 7.5, 2.15, 60, 60, 20, 70)
|
|
117
123
|
vled.sliceTime = 0.2
|
|
118
124
|
vled.slicesInFrame = 10
|
|
119
125
|
vled.B = 0.5e5
|
|
@@ -128,11 +134,11 @@ if __name__ == "__main__":
|
|
|
128
134
|
|
|
129
135
|
# setting algorithm and number of connections
|
|
130
136
|
sim.set_allocation_algorithm(alloc)
|
|
131
|
-
sim.goalConnections =
|
|
137
|
+
sim.goalConnections = 60
|
|
132
138
|
|
|
133
139
|
# changing Dynamic
|
|
134
140
|
sim.lambdaS = 1
|
|
135
|
-
sim.mu =
|
|
141
|
+
sim.mu = 30
|
|
136
142
|
|
|
137
143
|
# changing random wait limits
|
|
138
144
|
|
|
@@ -145,9 +151,3 @@ if __name__ == "__main__":
|
|
|
145
151
|
# initialize and run
|
|
146
152
|
sim.init()
|
|
147
153
|
sim.run()
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
|
|
@@ -31,17 +31,28 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
31
31
|
for vled in vleds:
|
|
32
32
|
capacities.append(scenario.capacityVled(receiver, vled))
|
|
33
33
|
posBestCapacity = capacities.index(max(capacities))
|
|
34
|
-
|
|
34
|
+
numberOfSlices = 0
|
|
35
|
+
if (
|
|
36
|
+
controller.numberOfActiveConnections(vleds[posBestCapacity]) > 5
|
|
37
|
+
or capacities[posBestCapacity] == 0
|
|
38
|
+
):
|
|
35
39
|
connection.AP = scenario.rfs[0]
|
|
40
|
+
connection.receiver.capacityFromAP = scenario.capacityRf(
|
|
41
|
+
receiver, connection.AP
|
|
42
|
+
)
|
|
43
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
44
|
+
connection.capacityRequired, connection.receiver.capacityFromAP
|
|
45
|
+
)
|
|
36
46
|
else:
|
|
37
47
|
connection.AP = vleds[posBestCapacity]
|
|
48
|
+
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
49
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
50
|
+
connection.capacityRequired, capacities[posBestCapacity]
|
|
51
|
+
)
|
|
38
52
|
|
|
39
|
-
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
40
|
-
connection.capacityRequired, capacities[posBestCapacity]
|
|
41
|
-
)
|
|
42
|
-
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
43
53
|
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP)
|
|
44
54
|
aux = 0
|
|
55
|
+
auxFrame = 0
|
|
45
56
|
|
|
46
57
|
# Actual frame
|
|
47
58
|
for slice in range(actualSlice, connection.AP.slicesInFrame):
|
|
@@ -59,18 +70,13 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
59
70
|
if controller.framesState(connection.AP)[frameIndex][slice] == False:
|
|
60
71
|
connection.assignFrameSlice(frameIndex, slice)
|
|
61
72
|
aux += 1
|
|
73
|
+
auxFrame = frameIndex
|
|
62
74
|
break
|
|
63
75
|
|
|
64
76
|
if aux == numberOfSlices:
|
|
65
77
|
break
|
|
66
78
|
|
|
67
|
-
frameIndex =
|
|
68
|
-
1
|
|
69
|
-
if len(controller.framesState(connection.AP)) == 0
|
|
70
|
-
else len(controller.framesState(connection.AP))
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
frameIndex = len(controller.framesState(connection.AP))
|
|
79
|
+
frameIndex = auxFrame + 1
|
|
74
80
|
while aux < numberOfSlices:
|
|
75
81
|
connection.assignFrameSlice(frameIndex, 0)
|
|
76
82
|
frameIndex += 1
|
|
@@ -81,25 +87,25 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
81
87
|
if __name__ == "__main__":
|
|
82
88
|
# Simulator Constructor: size of the room, with the numbrer of grids and the rho parameter
|
|
83
89
|
|
|
84
|
-
sim = Simulator(
|
|
90
|
+
sim = Simulator(20.0, 20.0, 2.15, 10, 0.8)
|
|
85
91
|
|
|
86
92
|
# Adding Vleds to the room
|
|
87
|
-
vled = VLed(-
|
|
93
|
+
vled = VLed(-7.5, -7.5, 2.15, 60, 60, 20, 70)
|
|
88
94
|
vled.sliceTime = 0.2
|
|
89
95
|
vled.slicesInFrame = 10
|
|
90
96
|
vled.B = 0.5e5
|
|
91
97
|
sim.scenario.addVLed(vled)
|
|
92
|
-
vled = VLed(-
|
|
98
|
+
vled = VLed(-7.5, 7.5, 2.15, 60, 60, 20, 70)
|
|
93
99
|
vled.sliceTime = 0.2
|
|
94
100
|
vled.slicesInFrame = 10
|
|
95
101
|
vled.B = 0.5e5
|
|
96
102
|
sim.scenario.addVLed(vled)
|
|
97
|
-
vled = VLed(
|
|
103
|
+
vled = VLed(7.5, -7.5, 2.15, 60, 60, 20, 70)
|
|
98
104
|
vled.sliceTime = 0.2
|
|
99
105
|
vled.slicesInFrame = 10
|
|
100
106
|
vled.B = 0.5e5
|
|
101
107
|
sim.scenario.addVLed(vled)
|
|
102
|
-
vled = VLed(
|
|
108
|
+
vled = VLed(7.5, 7.5, 2.15, 60, 60, 20, 70)
|
|
103
109
|
vled.sliceTime = 0.2
|
|
104
110
|
vled.slicesInFrame = 10
|
|
105
111
|
vled.B = 0.5e5
|
|
@@ -114,11 +120,11 @@ if __name__ == "__main__":
|
|
|
114
120
|
|
|
115
121
|
# setting algorithm and number of connections
|
|
116
122
|
sim.set_allocation_algorithm(alloc)
|
|
117
|
-
sim.goalConnections =
|
|
123
|
+
sim.goalConnections = 60
|
|
118
124
|
|
|
119
125
|
# changing Dynamic
|
|
120
126
|
sim.lambdaS = 1
|
|
121
|
-
sim.mu =
|
|
127
|
+
sim.mu = 30
|
|
122
128
|
|
|
123
129
|
# changing random wait limits
|
|
124
130
|
|
|
@@ -131,9 +137,3 @@ if __name__ == "__main__":
|
|
|
131
137
|
# initialize and run
|
|
132
138
|
sim.init()
|
|
133
139
|
sim.run()
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
|
|
@@ -10,7 +10,7 @@ long_description = (this_directory / "README.md").read_text()
|
|
|
10
10
|
|
|
11
11
|
setup(
|
|
12
12
|
name="vlcSim",
|
|
13
|
-
version="0.
|
|
13
|
+
version="0.3.0",
|
|
14
14
|
license="MIT",
|
|
15
15
|
description="Python Package of Event-Oriented Simulation for visible light communication",
|
|
16
16
|
author="Danilo Bórquez-Paredes",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: vlcSim
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python Package of Event-Oriented Simulation for visible light communication
|
|
5
5
|
Home-page: https://gitlab.com/DaniloBorquez/simvlc/
|
|
6
6
|
Author: Danilo Bórquez-Paredes
|
|
@@ -45,17 +45,28 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
45
45
|
for vled in vleds:
|
|
46
46
|
capacities.append(scenario.capacityVled(receiver, vled))
|
|
47
47
|
posBestCapacity = capacities.index(max(capacities))
|
|
48
|
-
|
|
48
|
+
numberOfSlices = 0
|
|
49
|
+
if (
|
|
50
|
+
controller.numberOfActiveConnections(vleds[posBestCapacity]) > 5
|
|
51
|
+
or capacities[posBestCapacity] == 0
|
|
52
|
+
):
|
|
49
53
|
connection.AP = scenario.rfs[0]
|
|
54
|
+
connection.receiver.capacityFromAP = scenario.capacityRf(
|
|
55
|
+
receiver, connection.AP
|
|
56
|
+
)
|
|
57
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
58
|
+
connection.capacityRequired, connection.receiver.capacityFromAP
|
|
59
|
+
)
|
|
50
60
|
else:
|
|
51
61
|
connection.AP = vleds[posBestCapacity]
|
|
62
|
+
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
63
|
+
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
64
|
+
connection.capacityRequired, capacities[posBestCapacity]
|
|
65
|
+
)
|
|
52
66
|
|
|
53
|
-
numberOfSlices = connection.numberOfSlicesNeeded(
|
|
54
|
-
connection.capacityRequired, capacities[posBestCapacity]
|
|
55
|
-
)
|
|
56
|
-
connection.receiver.capacityFromAP = capacities[posBestCapacity]
|
|
57
67
|
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP)
|
|
58
68
|
aux = 0
|
|
69
|
+
auxFrame = 0
|
|
59
70
|
|
|
60
71
|
# Actual frame
|
|
61
72
|
for slice in range(actualSlice, connection.AP.slicesInFrame):
|
|
@@ -73,18 +84,13 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
73
84
|
if controller.framesState(connection.AP)[frameIndex][slice] == False:
|
|
74
85
|
connection.assignFrameSlice(frameIndex, slice)
|
|
75
86
|
aux += 1
|
|
87
|
+
auxFrame = frameIndex
|
|
76
88
|
break
|
|
77
89
|
|
|
78
90
|
if aux == numberOfSlices:
|
|
79
91
|
break
|
|
80
92
|
|
|
81
|
-
frameIndex =
|
|
82
|
-
1
|
|
83
|
-
if len(controller.framesState(connection.AP)) == 0
|
|
84
|
-
else len(controller.framesState(connection.AP))
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
frameIndex = len(controller.framesState(connection.AP))
|
|
93
|
+
frameIndex = auxFrame + 1
|
|
88
94
|
while aux < numberOfSlices:
|
|
89
95
|
connection.assignFrameSlice(frameIndex, 0)
|
|
90
96
|
frameIndex += 1
|
|
@@ -95,25 +101,25 @@ def alloc(receiver, connection: Connection, scenario: Scenario, controller: Cont
|
|
|
95
101
|
if __name__ == "__main__":
|
|
96
102
|
# Simulator Constructor: size of the room, with the numbrer of grids and the rho parameter
|
|
97
103
|
|
|
98
|
-
sim = Simulator(
|
|
104
|
+
sim = Simulator(20.0, 20.0, 2.15, 10, 0.8)
|
|
99
105
|
|
|
100
106
|
# Adding Vleds to the room
|
|
101
|
-
vled = VLed(-
|
|
107
|
+
vled = VLed(-7.5, -7.5, 2.15, 60, 60, 20, 70)
|
|
102
108
|
vled.sliceTime = 0.2
|
|
103
109
|
vled.slicesInFrame = 10
|
|
104
110
|
vled.B = 0.5e5
|
|
105
111
|
sim.scenario.addVLed(vled)
|
|
106
|
-
vled = VLed(-
|
|
112
|
+
vled = VLed(-7.5, 7.5, 2.15, 60, 60, 20, 70)
|
|
107
113
|
vled.sliceTime = 0.2
|
|
108
114
|
vled.slicesInFrame = 10
|
|
109
115
|
vled.B = 0.5e5
|
|
110
116
|
sim.scenario.addVLed(vled)
|
|
111
|
-
vled = VLed(
|
|
117
|
+
vled = VLed(7.5, -7.5, 2.15, 60, 60, 20, 70)
|
|
112
118
|
vled.sliceTime = 0.2
|
|
113
119
|
vled.slicesInFrame = 10
|
|
114
120
|
vled.B = 0.5e5
|
|
115
121
|
sim.scenario.addVLed(vled)
|
|
116
|
-
vled = VLed(
|
|
122
|
+
vled = VLed(7.5, 7.5, 2.15, 60, 60, 20, 70)
|
|
117
123
|
vled.sliceTime = 0.2
|
|
118
124
|
vled.slicesInFrame = 10
|
|
119
125
|
vled.B = 0.5e5
|
|
@@ -128,11 +134,11 @@ if __name__ == "__main__":
|
|
|
128
134
|
|
|
129
135
|
# setting algorithm and number of connections
|
|
130
136
|
sim.set_allocation_algorithm(alloc)
|
|
131
|
-
sim.goalConnections =
|
|
137
|
+
sim.goalConnections = 60
|
|
132
138
|
|
|
133
139
|
# changing Dynamic
|
|
134
140
|
sim.lambdaS = 1
|
|
135
|
-
sim.mu =
|
|
141
|
+
sim.mu = 30
|
|
136
142
|
|
|
137
143
|
# changing random wait limits
|
|
138
144
|
|
|
@@ -145,9 +151,3 @@ if __name__ == "__main__":
|
|
|
145
151
|
# initialize and run
|
|
146
152
|
sim.init()
|
|
147
153
|
sim.run()
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
|
|
@@ -5,6 +5,7 @@ The :mod:`vlcsim.controller` module is in charge of managing the connections and
|
|
|
5
5
|
from .scene import *
|
|
6
6
|
from enum import Enum
|
|
7
7
|
import math
|
|
8
|
+
import sys
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class Connection:
|
|
@@ -32,6 +33,15 @@ class Connection:
|
|
|
32
33
|
self.__goalTime = None
|
|
33
34
|
self.__time = time
|
|
34
35
|
self.__capacityRequired = None
|
|
36
|
+
self.__snr = sys.float_info.min
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def snr(self):
|
|
40
|
+
return self.__snr
|
|
41
|
+
|
|
42
|
+
@snr.setter
|
|
43
|
+
def snr(self, value):
|
|
44
|
+
self.__snr = value
|
|
35
45
|
|
|
36
46
|
@property
|
|
37
47
|
def capacityRequired(self) -> float:
|
|
@@ -250,6 +260,7 @@ class Controller:
|
|
|
250
260
|
|
|
251
261
|
if self.__allocationStatus == Controller.status.ALLOCATED:
|
|
252
262
|
index = self.APPosition(connection.AP)
|
|
263
|
+
self.__numberActiveConnections[index] += 1
|
|
253
264
|
actualSlice = connection.nextSliceInAPWhenArriving(connection.AP) - 1
|
|
254
265
|
actualTime = (
|
|
255
266
|
(time // (connection.AP.slicesInFrame * connection.AP.sliceTime))
|
|
@@ -357,6 +368,7 @@ class Controller:
|
|
|
357
368
|
flag = True
|
|
358
369
|
if flag:
|
|
359
370
|
self.__activeConnections[index].pop(self.__activeConnection[index])
|
|
371
|
+
self.__numberActiveConnections[index] -= 1
|
|
360
372
|
return Controller.nextStatus.IDLE, time, None
|
|
361
373
|
|
|
362
374
|
def init(self):
|
|
@@ -364,12 +376,14 @@ class Controller:
|
|
|
364
376
|
Initializatrion of this controller. This methods must be invoked before to start the simulation.
|
|
365
377
|
"""
|
|
366
378
|
self.__activeConnections = []
|
|
379
|
+
self.__numberActiveConnections = []
|
|
367
380
|
|
|
368
381
|
nvleds = 0
|
|
369
382
|
nrfs = 0
|
|
370
383
|
actual = None
|
|
371
384
|
|
|
372
385
|
for i in range(len(self.__scenario.vleds) + len(self.__scenario.rfs)):
|
|
386
|
+
self.__numberActiveConnections.append(0)
|
|
373
387
|
self.__activeConnections.append([])
|
|
374
388
|
if (
|
|
375
389
|
len(self.__scenario.vleds) > nvleds
|
|
@@ -411,7 +425,7 @@ class Controller:
|
|
|
411
425
|
|
|
412
426
|
return self.__activeConnections
|
|
413
427
|
|
|
414
|
-
def numberOfActiveConnections(self,
|
|
428
|
+
def numberOfActiveConnections(self, ap: int):
|
|
415
429
|
"""
|
|
416
430
|
The number of active connections in this AP.
|
|
417
431
|
|
|
@@ -420,7 +434,7 @@ class Controller:
|
|
|
420
434
|
:return: The number of active connections in this AP.
|
|
421
435
|
:rtype: int
|
|
422
436
|
"""
|
|
423
|
-
return
|
|
437
|
+
return self.__numberActiveConnections[self.APPosition(ap)]
|
|
424
438
|
|
|
425
439
|
def assignSlice(self, apIndex, frame, slice, connection):
|
|
426
440
|
numberOfFrames = len(self.__activeConnections[apIndex])
|
|
@@ -5,6 +5,7 @@ This module work with the classes belonging to the Scene. It manages the physica
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import math as m
|
|
7
7
|
from enum import Enum
|
|
8
|
+
import warnings
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class AccessPoint:
|
|
@@ -51,6 +52,12 @@ class AccessPoint:
|
|
|
51
52
|
|
|
52
53
|
@property
|
|
53
54
|
def B(self) -> float:
|
|
55
|
+
"""
|
|
56
|
+
Gets the Bandwith of this AccessPoint
|
|
57
|
+
|
|
58
|
+
:return: The B of this AccessPoint
|
|
59
|
+
:rtype: float
|
|
60
|
+
"""
|
|
54
61
|
return self._B
|
|
55
62
|
|
|
56
63
|
@B.setter
|
|
@@ -164,6 +171,12 @@ class AccessPoint:
|
|
|
164
171
|
|
|
165
172
|
@property
|
|
166
173
|
def slicesInFrame(self) -> int:
|
|
174
|
+
"""
|
|
175
|
+
The number of slices in the frame. This is used to determine how many slices will be in the frame.
|
|
176
|
+
|
|
177
|
+
:return: The number of slices in the frame
|
|
178
|
+
:rtype: int
|
|
179
|
+
"""
|
|
167
180
|
return self._slicesInFrame
|
|
168
181
|
|
|
169
182
|
@slicesInFrame.setter
|
|
@@ -177,6 +190,9 @@ class VLed(AccessPoint):
|
|
|
177
190
|
"""
|
|
178
191
|
|
|
179
192
|
numberOfVLeds = 0
|
|
193
|
+
"""
|
|
194
|
+
number of VLeds created
|
|
195
|
+
"""
|
|
180
196
|
|
|
181
197
|
def __init__(
|
|
182
198
|
self,
|
|
@@ -318,7 +334,14 @@ class VLed(AccessPoint):
|
|
|
318
334
|
|
|
319
335
|
|
|
320
336
|
class RF(AccessPoint):
|
|
337
|
+
"""
|
|
338
|
+
Class that represents a RF object
|
|
339
|
+
"""
|
|
340
|
+
|
|
321
341
|
numberOfRFs = 0
|
|
342
|
+
"""
|
|
343
|
+
Number of RFs created
|
|
344
|
+
"""
|
|
322
345
|
|
|
323
346
|
def __init__(
|
|
324
347
|
self,
|
|
@@ -353,6 +376,12 @@ class RF(AccessPoint):
|
|
|
353
376
|
|
|
354
377
|
@property
|
|
355
378
|
def bf(self) -> float:
|
|
379
|
+
"""
|
|
380
|
+
femtocell bandwidth
|
|
381
|
+
|
|
382
|
+
:return: Value of BF property
|
|
383
|
+
:rtype: float
|
|
384
|
+
"""
|
|
356
385
|
return self.__bf
|
|
357
386
|
|
|
358
387
|
@bf.setter
|
|
@@ -361,6 +390,13 @@ class RF(AccessPoint):
|
|
|
361
390
|
|
|
362
391
|
@property
|
|
363
392
|
def pf(self) -> float:
|
|
393
|
+
"""
|
|
394
|
+
Femtobase power transmission
|
|
395
|
+
|
|
396
|
+
:return: Femtobase power transmission
|
|
397
|
+
:rtype: float
|
|
398
|
+
|
|
399
|
+
"""
|
|
364
400
|
return self.__pf
|
|
365
401
|
|
|
366
402
|
@pf.setter
|
|
@@ -369,6 +405,12 @@ class RF(AccessPoint):
|
|
|
369
405
|
|
|
370
406
|
@property
|
|
371
407
|
def BERf(self) -> float:
|
|
408
|
+
"""
|
|
409
|
+
BER desired in femto network
|
|
410
|
+
|
|
411
|
+
:return: BER
|
|
412
|
+
:rtype: float
|
|
413
|
+
"""
|
|
372
414
|
return self.__BERf
|
|
373
415
|
|
|
374
416
|
@BERf.setter
|
|
@@ -377,6 +419,12 @@ class RF(AccessPoint):
|
|
|
377
419
|
|
|
378
420
|
@property
|
|
379
421
|
def Af(self) -> float:
|
|
422
|
+
"""
|
|
423
|
+
Pathloss constant
|
|
424
|
+
|
|
425
|
+
:return: Pathloss constant
|
|
426
|
+
:rtype: float
|
|
427
|
+
"""
|
|
380
428
|
return self.__Af
|
|
381
429
|
|
|
382
430
|
@Af.setter
|
|
@@ -385,6 +433,12 @@ class RF(AccessPoint):
|
|
|
385
433
|
|
|
386
434
|
@property
|
|
387
435
|
def Ef(self) -> float:
|
|
436
|
+
"""
|
|
437
|
+
Pathloss exponent
|
|
438
|
+
|
|
439
|
+
:return: Pathloss exponent
|
|
440
|
+
:rtype: float
|
|
441
|
+
"""
|
|
388
442
|
return self.__Ef
|
|
389
443
|
|
|
390
444
|
@Ef.setter
|
|
@@ -393,6 +447,12 @@ class RF(AccessPoint):
|
|
|
393
447
|
|
|
394
448
|
@property
|
|
395
449
|
def R_awgn(self) -> float:
|
|
450
|
+
"""
|
|
451
|
+
Normalized AWGN noise power
|
|
452
|
+
|
|
453
|
+
:return: Normalized AWGN noise power
|
|
454
|
+
:rtype: float
|
|
455
|
+
"""
|
|
396
456
|
return self.__R_awgn
|
|
397
457
|
|
|
398
458
|
@R_awgn.setter
|
|
@@ -409,6 +469,12 @@ class RF(AccessPoint):
|
|
|
409
469
|
|
|
410
470
|
@property
|
|
411
471
|
def N_rf(self) -> int:
|
|
472
|
+
"""
|
|
473
|
+
Number of cells using this femtocell
|
|
474
|
+
|
|
475
|
+
:return: Number of cells using this femtocell
|
|
476
|
+
:rtype: int
|
|
477
|
+
"""
|
|
412
478
|
return self.__N_rf
|
|
413
479
|
|
|
414
480
|
@N_rf.setter
|
|
@@ -458,6 +524,30 @@ class Receiver:
|
|
|
458
524
|
i1: float = 0.562,
|
|
459
525
|
i2: float = 0.0868,
|
|
460
526
|
) -> None:
|
|
527
|
+
"""
|
|
528
|
+
Initializes the object with the values. This is the constructor for the Schrodinger model
|
|
529
|
+
|
|
530
|
+
:param x: x coordinate of the object
|
|
531
|
+
:param y: y coordinate of the object's coordinate.
|
|
532
|
+
:param z: z coordinate of the object's coordinate.
|
|
533
|
+
:param aDet: aDet value of the object's coordinate.
|
|
534
|
+
:param ts: time of the object's coordinate. Default is 10 seconds.
|
|
535
|
+
:param index
|
|
536
|
+
:param fov: q of the object. Default is 1. 6e - 19.
|
|
537
|
+
:param q
|
|
538
|
+
:param s: ibg b - parameter of the Ib - Galactic model. Default i 5 seconds.
|
|
539
|
+
:param b: c b - parameter of the Ib - Galactic model. Default is 5 seconds.
|
|
540
|
+
:param ibg
|
|
541
|
+
:param cb
|
|
542
|
+
:param tk
|
|
543
|
+
:param a: n n - prameter of the B - parameter. Default is 10 seconds.
|
|
544
|
+
:param gv
|
|
545
|
+
:param n
|
|
546
|
+
:param fr
|
|
547
|
+
:param gm
|
|
548
|
+
:param i1
|
|
549
|
+
:param i2
|
|
550
|
+
"""
|
|
461
551
|
self.__x = x
|
|
462
552
|
self.__y = y
|
|
463
553
|
self.__z = z
|
|
@@ -492,6 +582,12 @@ class Receiver:
|
|
|
492
582
|
|
|
493
583
|
@property
|
|
494
584
|
def capacityFromAP(self):
|
|
585
|
+
"""
|
|
586
|
+
Get the capacity from AP.
|
|
587
|
+
|
|
588
|
+
:return: capacity from AP
|
|
589
|
+
:rtype: float
|
|
590
|
+
"""
|
|
495
591
|
return self.__capacityFromAP
|
|
496
592
|
|
|
497
593
|
@capacityFromAP.setter
|
|
@@ -500,6 +596,12 @@ class Receiver:
|
|
|
500
596
|
|
|
501
597
|
@property
|
|
502
598
|
def ID(self) -> int:
|
|
599
|
+
"""
|
|
600
|
+
Return the ID of the object. This is used to distinguish between different objects that are part of the same object group.
|
|
601
|
+
|
|
602
|
+
:return: The ID of the object
|
|
603
|
+
:rtype: int
|
|
604
|
+
"""
|
|
503
605
|
return self.__ID
|
|
504
606
|
|
|
505
607
|
@ID.setter
|
|
@@ -508,6 +610,12 @@ class Receiver:
|
|
|
508
610
|
|
|
509
611
|
@property
|
|
510
612
|
def x(self) -> float:
|
|
613
|
+
"""
|
|
614
|
+
Get the x coordinate.
|
|
615
|
+
|
|
616
|
+
:return: The x coordinate
|
|
617
|
+
:rtype: float
|
|
618
|
+
"""
|
|
511
619
|
return self.__x
|
|
512
620
|
|
|
513
621
|
@x.setter
|
|
@@ -516,6 +624,12 @@ class Receiver:
|
|
|
516
624
|
|
|
517
625
|
@property
|
|
518
626
|
def y(self) -> float:
|
|
627
|
+
"""
|
|
628
|
+
Gets the y coordinate .
|
|
629
|
+
|
|
630
|
+
:return: The y coordinate
|
|
631
|
+
:rtype: float
|
|
632
|
+
"""
|
|
519
633
|
return self.__y
|
|
520
634
|
|
|
521
635
|
@y.setter
|
|
@@ -524,6 +638,12 @@ class Receiver:
|
|
|
524
638
|
|
|
525
639
|
@property
|
|
526
640
|
def z(self) -> float:
|
|
641
|
+
"""
|
|
642
|
+
Z coordinate .
|
|
643
|
+
|
|
644
|
+
:return: the z coordinate
|
|
645
|
+
:rtype: float
|
|
646
|
+
"""
|
|
527
647
|
return self.__z
|
|
528
648
|
|
|
529
649
|
@z.setter
|
|
@@ -568,6 +688,12 @@ class Receiver:
|
|
|
568
688
|
|
|
569
689
|
@property
|
|
570
690
|
def position(self):
|
|
691
|
+
"""
|
|
692
|
+
Return the position of the object. This is a tuple of ( x y z)
|
|
693
|
+
|
|
694
|
+
:return: the position of the object
|
|
695
|
+
:rtype: tuple
|
|
696
|
+
"""
|
|
571
697
|
return self.__position
|
|
572
698
|
|
|
573
699
|
@property
|
|
@@ -709,6 +835,9 @@ class Receiver:
|
|
|
709
835
|
|
|
710
836
|
class Scenario:
|
|
711
837
|
numberOfAPs = 0
|
|
838
|
+
warnings.filterwarnings(
|
|
839
|
+
"ignore", message="invalid value encountered in double_scalars"
|
|
840
|
+
)
|
|
712
841
|
|
|
713
842
|
def __init__(
|
|
714
843
|
self, width: float, length: float, height: float, nGrids: int, rho: float
|
|
@@ -944,4 +1073,4 @@ class Scenario:
|
|
|
944
1073
|
return vled.B * m.log2(1 + self.snrVled(receiver, vled))
|
|
945
1074
|
|
|
946
1075
|
def capacityRf(self, receiver: Receiver, rf: RF) -> float:
|
|
947
|
-
return rf.B * m.log2(1 + self.
|
|
1076
|
+
return rf.B * m.log2(1 + self.snrRf(receiver, rf))
|
|
@@ -92,6 +92,9 @@ class Simulator:
|
|
|
92
92
|
self.__upper_capacity_required = None
|
|
93
93
|
self.__lower_capacity_required = None
|
|
94
94
|
|
|
95
|
+
self.__users_by_vlc = []
|
|
96
|
+
self.__users_by_rf = []
|
|
97
|
+
|
|
95
98
|
self.default_values()
|
|
96
99
|
|
|
97
100
|
def default_values(self):
|
|
@@ -273,7 +276,30 @@ class Simulator:
|
|
|
273
276
|
)
|
|
274
277
|
)
|
|
275
278
|
|
|
276
|
-
print("
|
|
279
|
+
print(f"Number of VLeds: {self.__controller.scenario.numberOfVLeds}")
|
|
280
|
+
print("Positions:")
|
|
281
|
+
print(" ID | X | Y | Z |")
|
|
282
|
+
print("-" * 47)
|
|
283
|
+
for vled in self.__controller.scenario.vleds:
|
|
284
|
+
print(
|
|
285
|
+
"{:>10} | {:8.4f} | {:8.4f} | {:8.4f} |".format(
|
|
286
|
+
vled.ID, vled.x, vled.y, vled.z
|
|
287
|
+
)
|
|
288
|
+
)
|
|
289
|
+
print()
|
|
290
|
+
print(f"Number of RFs: {self.__controller.scenario.numberOfRFs}")
|
|
291
|
+
print("Positions:")
|
|
292
|
+
print(" ID | X | Y | Z |")
|
|
293
|
+
print("-" * 47)
|
|
294
|
+
for rf in self.__controller.scenario.rfs:
|
|
295
|
+
print(
|
|
296
|
+
"{:>10} | {:8.4f} | {:8.4f} | {:8.4f} |".format(
|
|
297
|
+
rf.ID, rf.x, rf.y, rf.z
|
|
298
|
+
)
|
|
299
|
+
)
|
|
300
|
+
print()
|
|
301
|
+
|
|
302
|
+
print("=" * 146)
|
|
277
303
|
print("| Time ", end="")
|
|
278
304
|
print("| Event ", end="")
|
|
279
305
|
print("| Receiver ", end="")
|
|
@@ -282,8 +308,10 @@ class Simulator:
|
|
|
282
308
|
print("| Z ", end="")
|
|
283
309
|
print("| Access Point (A.C.) ", end="")
|
|
284
310
|
print("| Goal time ", end="")
|
|
285
|
-
print("| Elapsed time
|
|
286
|
-
print("="
|
|
311
|
+
print("| Elapsed time ", end="")
|
|
312
|
+
print("| SNR ", end="")
|
|
313
|
+
print("| Req. Cap. |")
|
|
314
|
+
print("=" * 146)
|
|
287
315
|
|
|
288
316
|
def print_row(self, event):
|
|
289
317
|
text = ""
|
|
@@ -306,11 +334,7 @@ class Simulator:
|
|
|
306
334
|
text += (
|
|
307
335
|
" VLed: {:>5}".format(event.connection.AP.ID)
|
|
308
336
|
+ " ({:^5})".format(
|
|
309
|
-
|
|
310
|
-
self.__controller.activeConnections[
|
|
311
|
-
self.__controller.APPosition(event.connection.AP)
|
|
312
|
-
]
|
|
313
|
-
)
|
|
337
|
+
self.__controller.numberOfActiveConnections(event.connection.AP)
|
|
314
338
|
)
|
|
315
339
|
+ " |"
|
|
316
340
|
)
|
|
@@ -318,11 +342,7 @@ class Simulator:
|
|
|
318
342
|
text += (
|
|
319
343
|
" RF: {:>5}".format(event.connection.AP.ID)
|
|
320
344
|
+ " ({:^5})".format(
|
|
321
|
-
|
|
322
|
-
self.__controller.activeConnections[
|
|
323
|
-
self.__controller.APPosition(event.connection.AP)
|
|
324
|
-
]
|
|
325
|
-
)
|
|
345
|
+
self.__controller.numberOfActiveConnections(event.connection.AP)
|
|
326
346
|
)
|
|
327
347
|
+ " |"
|
|
328
348
|
)
|
|
@@ -347,6 +367,8 @@ class Simulator:
|
|
|
347
367
|
# event.type,
|
|
348
368
|
# event.id_connection,
|
|
349
369
|
# )
|
|
370
|
+
text += "{:10.2e}".format(event.connection.snr) + " |"
|
|
371
|
+
text += "{:10.2e}".format(event.connection.capacityRequired) + " |"
|
|
350
372
|
print(text)
|
|
351
373
|
|
|
352
374
|
def event_routine(self):
|
|
@@ -403,6 +425,10 @@ class Simulator:
|
|
|
403
425
|
next_status == Controller.nextStatus.RESUME
|
|
404
426
|
or next_status == Controller.nextStatus.PAUSE
|
|
405
427
|
):
|
|
428
|
+
if type(connection.AP) == VLed:
|
|
429
|
+
self.__users_by_vlc[connection.AP.ID] += 1
|
|
430
|
+
elif type(connection.AP) == RF:
|
|
431
|
+
self.__users_by_rf[connection.AP.ID] += 1
|
|
406
432
|
self.__current_event.connection = connection
|
|
407
433
|
if next_status == Controller.nextStatus.RESUME:
|
|
408
434
|
for pos in range(len(self.__events) - 1, -1, -1):
|
|
@@ -553,6 +579,10 @@ class Simulator:
|
|
|
553
579
|
and self.__controller.scenario.numberOfRFs == 0
|
|
554
580
|
):
|
|
555
581
|
raise ("The scenario does not have any Vleds or RFs")
|
|
582
|
+
for _ in range(self.__controller.scenario.numberOfVLeds):
|
|
583
|
+
self.__users_by_vlc.append(0)
|
|
584
|
+
for _ in range(self.__controller.scenario.numberOfRFs):
|
|
585
|
+
self.__users_by_rf.append(0)
|
|
556
586
|
return
|
|
557
587
|
|
|
558
588
|
def run(self):
|
|
@@ -560,6 +590,7 @@ class Simulator:
|
|
|
560
590
|
while self.__numberOfConnections <= self.__goalConnections:
|
|
561
591
|
# for i in range(self.__goalConnections):
|
|
562
592
|
self.event_routine()
|
|
593
|
+
self.aggregated_metrics()
|
|
563
594
|
|
|
564
595
|
def time_duration(self):
|
|
565
596
|
return self.__time_duration
|
|
@@ -576,3 +607,14 @@ class Simulator:
|
|
|
576
607
|
@property
|
|
577
608
|
def scenario(self):
|
|
578
609
|
return self.__controller.scenario
|
|
610
|
+
|
|
611
|
+
def aggregated_metrics(self):
|
|
612
|
+
print("Number of users connected to each VLed")
|
|
613
|
+
for i in range(self.__controller.scenario.numberOfVLeds):
|
|
614
|
+
id = self.__controller.scenario.vleds[i].ID
|
|
615
|
+
print(f"VLed {id}: {self.__users_by_vlc[id]}")
|
|
616
|
+
|
|
617
|
+
print("Number of users connected to each RF")
|
|
618
|
+
for i in range(self.__controller.scenario.numberOfRFs):
|
|
619
|
+
id = self.__controller.scenario.rfs[i].ID
|
|
620
|
+
print(f"RF {id}: {self.__users_by_rf[id]}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|