Reference
API reference for the functions exported by agenet.
aaoi_fn(receiving_times, generation_times)
Calculate the average age of information.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
receiving_times
|
NDArray
|
List of receiving times. |
required |
generation_times
|
NDArray
|
List of generation times. |
required |
Returns:
Type | Description |
---|---|
tuple[float, NDArray, NDArray]
|
Average age of information, age, times. |
Source code in agenet/aaoi.py
10 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 |
|
block_error(snr, n, k)
Calculate the Block Error Rate for the given instantaneous SNR, n, k.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snr
|
float
|
Instantaneous signal-to-noise ratio. |
required |
n
|
int
|
Total number of bits. |
required |
k
|
int
|
Number of information bits. |
required |
Returns:
Type | Description |
---|---|
float
|
The Block Error Rate. |
Source code in agenet/blkerr.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
block_error_th(snr_avg, n, k)
Calculate the theoretical Block Error Rate for the given average SNR, n, k.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snr_avg
|
float
|
Average Signal-to-noise ratio. |
required |
n
|
int
|
Total number of bits. |
required |
k
|
int
|
Number of information bits. |
required |
Returns:
Type | Description |
---|---|
float
|
The theoretical Block Error Rate. |
Source code in agenet/blkerr.py
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 |
|
ev_sim(num_runs, frequency, num_events, num_bits, info_bits, power, distance, N0, num_bits_2=None, info_bits_2=None, power_2=None, distance_2=None, N0_2=None, seed=None)
Run the simulation num_runs
times and return the AAoI expected value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_runs
|
int
|
Number of times to run the simulation. |
required |
frequency
|
float
|
Signal frequency in Hertz. |
required |
num_events
|
int
|
Number of events to simulate. |
required |
num_bits
|
int
|
Number of bits in a block. |
required |
info_bits
|
int
|
Number of bits in a message. |
required |
power
|
float
|
Transmission power in Watts. |
required |
distance
|
float
|
Distance between nodes. |
required |
N0
|
float
|
Noise power in Watts. |
required |
num_bits_2
|
int | None
|
Number of bits in a block at relay or access point. |
None
|
info_bits_2
|
int | None
|
Number of bits in a message at relay or access point. |
None
|
power_2
|
float | None
|
Transmission power in Watts at relay or access point. |
None
|
distance_2
|
float | None
|
Distance between relay or access point and the destination. |
None
|
N0_2
|
float | None
|
Noise power in Watts at relay or access point. |
None
|
seed
|
int | signedinteger | None
|
Seed for the random number generator (optional). |
None
|
Returns:
Type | Description |
---|---|
tuple[float, float, float, float, float, float]
|
A tuple containing the expected value for the theoretical AAoI and the simulation AAoI. |
Source code in agenet/simulation.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
|
multi_param_ev_sim(num_runs, frequency, num_events, num_bits, info_bits, power, distance, N0, num_bits_2=[None], info_bits_2=[None], power_2=[None], distance_2=[None], N0_2=[None], seed=None, counter=None, stop_event=None)
Run the simulation for multiple parameters and return the results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_runs
|
int
|
Number of times to run the simulation. |
required |
frequency
|
Sequence[float]
|
List of frequencies. |
required |
num_events
|
Sequence[int]
|
List of number of events. |
required |
num_bits
|
Sequence[int]
|
List of number of bits in a block. |
required |
info_bits
|
Sequence[int]
|
List of number of bits in a message. |
required |
power
|
Sequence[float]
|
List of powers. |
required |
distance
|
Sequence[float]
|
List of distances between nodes. |
required |
N0
|
Sequence[float]
|
List of noise powers. |
required |
num_bits_2
|
Sequence[int | None]
|
List of number of bits in a block for relay or access point (optional, if different than source). |
[None]
|
info_bits_2
|
Sequence[int | None]
|
List of number of bits in a message for relay or access point (optional, if different than source). |
[None]
|
power_2
|
Sequence[float | None]
|
List of powers for relay or access point (optional, if different than source). |
[None]
|
distance_2
|
Sequence[float | None]
|
List of distances between nodes for relay or access point (optional, if different than source). |
[None]
|
N0_2
|
Sequence[float | None]
|
List of noise powers for relay or access point (optional, if different than source). |
[None]
|
seed
|
int | signedinteger | None
|
Seed for the random number generator (optional). |
None
|
counter
|
Synchronized[int] | None
|
An optional |
None
|
stop_event
|
Event | None
|
The simulation will stop if this optional event is set externally. Only relevant if this function is executed in a separate thread. |
None
|
Returns:
Type | Description |
---|---|
tuple[DataFrame, dict[str, Sequence[NamedTuple]]]
|
A tuple containing a DataFrame with the results of the simulation and a log highlighting invalid parameters or parameter combinations. |
Source code in agenet/simulation.py
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 |
|
sim(frequency, num_events, num_bits, info_bits, power, distance, N0, num_bits_2=None, info_bits_2=None, power_2=None, distance_2=None, N0_2=None, seed=None)
Simulates a communication system and calculates the AAoI.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
frequency
|
float
|
Signal frequency in Hertz. |
required |
num_events
|
int
|
Number of events to simulate. |
required |
num_bits
|
int
|
Number of bits in a block. |
required |
info_bits
|
int
|
Number of bits in a message. |
required |
power
|
float
|
Transmission power in Watts. |
required |
distance
|
float
|
Distance between nodes. |
required |
N0
|
float
|
Noise power in Watts. |
required |
num_bits_2
|
int | None
|
Number of bits in a block at relay or access point. |
None
|
info_bits_2
|
int | None
|
Number of bits in a message at relay or access point. |
None
|
power_2
|
float | None
|
Transmission power in Watts at relay or access point. |
None
|
distance_2
|
float | None
|
Distance between relay or access point and the destination. |
None
|
N0_2
|
float | None
|
Noise power in Watts at relay or access point. |
None
|
seed
|
int | signedinteger | None
|
Seed for the random number generator (optional). |
None
|
Returns:
Type | Description |
---|---|
tuple[float, float, float, float, float, float]
|
A tuple containing: theoretical AAoI, simulation AAoI, theoretical SNR at source node, theoretical SNR at relay or access point, theoretical block error at source node, theoretical SNR at relay or access point. |
Source code in agenet/simulation.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
|
snr(N0, d, P, fr, seed=None)
Computes the instantaneous SNR of the received signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N0
|
float
|
Noise power in Watts. |
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 |
seed
|
int | Generator | None
|
Seed for the random number generator or a previously instantied random number generator (optional). |
None
|
Returns:
Type | Description |
---|---|
float
|
The instantaneous SNR of the received signal in linear scale. |
Source code in agenet/snratio.py
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 |
|
snr_avg(N0, d, P, fr)
Computes the average SNR of the received signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
N0
|
float
|
Noise power in Watts. |
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 average SNR of the received signal in linear scale. |
Source code in agenet/snratio.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|