Reference
API reference for the functions exported by agenet.
av_age_fn(destination_times, generation_times, lambha)
Calculate the AAoI given the parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
destination_times |
list[float]
|
A sorted list of destination times. |
required |
generation_times |
list[float]
|
A list of the generation times. |
required |
lambha |
float
|
The arrival rate of information. |
required |
Returns:
Type | Description |
---|---|
tuple[float, ndarray, ndarray]
|
A tuple containing the AAoI, the array of ages for each time step, and the corresponding time step array. |
Source code in agenet/av_age.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
blercal(snr, n, k)
Calculate the Block Error Rate (BLER) for the given SNR, n, k.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snr |
float
|
Signal-to-Noise Ratio (SNR). |
required |
n |
int
|
Number of bits in the block. |
required |
k |
int
|
Number of bits in the message. |
required |
Returns:
Type | Description |
---|---|
float
|
Block Error Rate (BLER) for the given SNR, n, k. |
Source code in agenet/bler.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
|
blercal_th(snr, n, k)
Calculate the theoretical Block Error Rate (BLER) for the given SNR, n, k.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snr |
float
|
Signal-to-Noise Ratio (SNR). |
required |
n |
int
|
Number of bits in the block. |
required |
k |
int
|
Number of bits in the message. |
required |
Returns:
Type | Description |
---|---|
float
|
Theoretical Block Error Rate (BLER) for the given SNR, n, k. |
Source code in agenet/bler.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
generate_table(num_nodes_const, active_prob_const, n_const, k_const, P_const, d_const, N0_const, fr_const, numevnts, numruns, num_nodes_vals, active_prob_vals, n_vals, k_vals, P_vals, csv_location=None)
Print the simulated and theoretical values for each variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_nodes_const |
int
|
Constant value for the number of nodes. |
required |
active_prob_const |
float
|
Constant value for the active probability. |
required |
n_const |
int
|
Constant value for the block length. |
required |
k_const |
int
|
Constant value for the update size. |
required |
P_const |
float
|
Constant value for the power. |
required |
d_const |
int
|
Constant value for the distance between nodes. |
required |
N0_const |
float
|
Constant value for the noise power. |
required |
fr_const |
float
|
Constant value for the frequency of the signal. |
required |
numevnts |
int
|
Number of events. |
required |
numruns |
int
|
Number of runs. |
required |
num_nodes_vals |
list[int]
|
Values for the number of nodes. |
required |
active_prob_vals |
list[float]
|
Values for the active probability. |
required |
n_vals |
list[int]
|
Values for the block length. |
required |
k_vals |
list[int]
|
Values for the update size. |
required |
P_vals |
list[float]
|
Values for the power. |
required |
csv_location |
Optional[str]
|
Location to save csv file |
None
|
Source code in agenet/printplot.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
plot(args, plots_folder=None)
Plot the simulated and theoretical values for each variable and save the plots.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
args |
Namespace
|
Parsed command-line arguments. |
required |
plots_folder |
str | None
|
Folder to save plots |
None
|
Source code in agenet/printplot.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
plot_generate(num_nodes_const, active_prob_const, n_const, k_const, P_const, d_const, N0_const, fr_const, numevnts, numruns, num_nodes_vals, active_prob_vals, n_vals, k_vals, P_vals, plots_folder=None)
Plot the simulated and theoretical values for each variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_nodes_const |
int
|
Constant value for the number of nodes. |
required |
active_prob_const |
float
|
Constant value for the active probability. |
required |
n_const |
int
|
Constant value for the block length. |
required |
k_const |
int
|
Constant value for the update size. |
required |
P_const |
float
|
Constant value for the power. |
required |
d_const |
int
|
Constant value for the distance between nodes. |
required |
N0_const |
float
|
Constant value for the noise power. |
required |
fr_const |
float
|
Constant value for the frequency of the signal. |
required |
numevnts |
int
|
Number of events. |
required |
numruns |
int
|
Number of runs. |
required |
num_nodes_vals |
list[int]
|
Values for the number of nodes. |
required |
active_prob_vals |
list[float]
|
Values for the active probability. |
required |
n_vals |
list[int]
|
Values for the block length. |
required |
k_vals |
list[int]
|
Values for the update size. |
required |
P_vals |
list[float]
|
Values for the power. |
required |
plots_folder |
str | None
|
Folder to save the plots. |
None
|
Source code in agenet/printplot.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
run_simulation(num_nodes, active_prob, n, k, P, d, N0, fr, numevnts, numruns)
Run the simulation numruns
times and return the AAoI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_nodes |
int
|
Number of nodes in the network. |
required |
active_prob |
float
|
Probability that a node is active in a given time slot. |
required |
n |
int
|
Number of bits in a block. |
required |
k |
int
|
Number of bits in a message. |
required |
P |
float
|
Power of the nodes. |
required |
numevnts |
int
|
Number of events. |
required |
numruns |
int
|
Number of times to run the simulation. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
A tuple containing the theoretical AAoI and the simulation AAoI. |
Source code in agenet/maincom.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
simulation(num_nodes, active_prob, n, k, P, d, N0, fr, numevents)
Simulates a communication system and calculates the AAoI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_nodes |
int
|
Number of nodes in the system |
required |
active_prob |
float
|
Probability that a node is active. |
required |
n |
int
|
Number of bits in a block. |
required |
k |
int
|
Number of bits in a message. |
required |
P |
float
|
Power of the nodes. |
required |
d |
int
|
Distance between nodes. |
required |
N0 |
float
|
Noise power. |
required |
fr |
float
|
Frequency of the signal. |
required |
numevents |
int
|
Number of events to simulate. |
required |
Returns:
Type | Description |
---|---|
tuple[float, float]
|
Theoretical AAoI and simulation AAoI. |
Source code in agenet/maincom.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
snr(N0, d, P, fr)
Computes the SNR of the received signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N0 |
float
|
The power spectral density of the noise. |
required |
d |
float
|
The distance between the transmitter and receiver. |
required |
P |
float
|
The power of the transmitted signal. |
required |
fr |
float
|
The frequency of the signal. |
required |
Returns:
Type | Description |
---|---|
float
|
The SNR of the received signal in linear scale. |
Source code in agenet/snratio.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
snr_th(N0, d, P, fr)
Calculates the theoretical SNR of the received signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N0 |
float
|
The power spectral density of the noise. |
required |
d |
float
|
The distance between the transmitter and receiver. |
required |
P |
float
|
The power of the transmitted signal. |
required |
fr |
float
|
The frequency of the signal. |
required |
Returns:
Type | Description |
---|---|
float
|
The theoretical SNR of the received signal in linear scale. |
Source code in agenet/snratio.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|