mapc_optimal.utils

Utility functions, including the function for calculation of the path loss from node positions using the TGax channel model.

Attributes

CENTRAL_FREQUENCY

WALL_LOSS

BREAKING_POINT

REFERENCE_DISTANCE

Classes

OptimizationType

Create a collection of name/value pairs.

Functions

dbm_to_lin(x)

Converts dBm to a linear scale.

lin_to_dbm(x)

Converts linear scale to dBm.

tgax_path_loss(distance, walls)

Calculates the path loss according to the TGax channel model [1].

positions_to_path_loss(pos, walls[, path_loss_fn])

Calculates the path loss for all nodes based on their positions and the wall positions.

Module Contents

class mapc_optimal.utils.OptimizationType(*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

SUM
MAX_MIN
MAX_MIN_BASELINE
PROPORTIONAL
mapc_optimal.utils.dbm_to_lin(x)

Converts dBm to a linear scale.

Parameters:

x (array_like) – Input in dBm.

Returns:

Output in a linear scale.

Return type:

NDArray

mapc_optimal.utils.lin_to_dbm(x)

Converts linear scale to dBm.

Parameters:

x (array_like) – Input in a linear scale.

Returns:

Output in dBm.

Return type:

NDArray

mapc_optimal.utils.CENTRAL_FREQUENCY = 5.16
mapc_optimal.utils.WALL_LOSS = 7.0
mapc_optimal.utils.BREAKING_POINT = 10.0
mapc_optimal.utils.REFERENCE_DISTANCE = 1.0
mapc_optimal.utils.tgax_path_loss(distance, walls)

Calculates the path loss according to the TGax channel model [1].

Parameters:
  • distance (array_like) – Distance between nodes.

  • walls (array_like) – Adjacency matrix describing walls between nodes (1 if there is a wall, 0 otherwise).

Returns:

Two dimensional array of path losses (dB) between all nodes.

Return type:

array_like

References

mapc_optimal.utils.positions_to_path_loss(pos, walls, path_loss_fn=tgax_path_loss)

Calculates the path loss for all nodes based on their positions and the wall positions. Channel is modeled using the TGax path loss model.

Parameters:
  • pos (array_like) – Two dimensional array of node positions. Each row corresponds to X and Y coordinates of a node.

  • walls (array_like) – Adjacency matrix describing walls between nodes (1 if there is a wall, 0 otherwise).

  • path_loss_fn (Callable) – A function that calculates the path loss between two nodes. The function signature should be path_loss_fn(distance: Array, walls: Array) -> Array, where distance is the matrix of distances between nodes and walls is the adjacency matrix of walls. By default, the simulator uses the residential TGax path loss model.

Returns:

Two-dimensional array of path losses (dB) between all nodes.

Return type:

NDArray