kaira.channels.UplinkMACChannel

Inheritance diagram of UplinkMACChannel

Inheritance diagram for UplinkMACChannel

class kaira.channels.UplinkMACChannel(user_channels: BaseChannel | List[BaseChannel], num_users: int | None = None, user_gains: float | List[float] | None = None, interference_power: float = 0.0, combine_method: str = 'sum', *args: Any, **kwargs: Any)[source]

Bases: BaseChannel

Uplink Multiple Access Channel (MAC) for modeling multi-user uplink communications.

This channel models uplink communication scenarios where multiple users transmit simultaneously to a single receiver. The channel uses a composition pattern, accepting existing channel implementations (e.g., FlatFadingChannel, AWGNChannel) as parameters to model different channel conditions for individual user transmissions.

The channel applies per-user channel effects, models inter-user interference, and combines the signals according to the MAC model. This enables realistic simulation of uplink scenarios with different channel conditions per user.

Mathematical Model:

For N users, the received signal is: y = Σᵢ₌₁ᴺ hᵢ(xᵢ) + interference + noise

where hᵢ(xᵢ) is the channel response for user i’s signal xᵢ.

Parameters:
  • user_channels (Union[BaseChannel, List[BaseChannel]]) – Channel instances for each user. Can be a single channel to be shared among all users, or a list of channels (one per user).

  • num_users (Optional[int]) – Number of users. Required if user_channels is a single channel instance. Inferred from the list length if user_channels is a list.

  • user_gains (Optional[Union[float, List[float]]]) – Per-user channel gains. Can be a single gain applied to all users or a list of gains (one per user). Defaults to 1.0 for all users.

  • interference_power (float) – Power of inter-user interference. Defaults to 0.0.

  • combine_method (str) – Method for combining user signals. Options: ‘sum’, ‘weighted_sum’. Defaults to ‘sum’.

Example

>>> # Using the same AWGN channel for all users
>>> from kaira.channels import AWGNChannel, UplinkMACChannel
>>> base_channel = AWGNChannel(avg_noise_power=0.1)
>>> uplink_channel = UplinkMACChannel(
...     user_channels=base_channel,
...     num_users=3,
...     user_gains=[1.0, 0.8, 0.6]
... )
>>> # Using different channels for each user
>>> from kaira.channels import FlatFadingChannel, RayleighFadingChannel
>>> user_channels = [
...     AWGNChannel(avg_noise_power=0.1),
...     FlatFadingChannel(fading_type="rayleigh", coherence_time=10, avg_noise_power=0.05),
...     RayleighFadingChannel(coherence_time=5, avg_noise_power=0.15)
... ]
>>> uplink_channel = UplinkMACChannel(user_channels=user_channels)

Methods

__init__

Initialize the UplinkMAC channel.

forward

Apply uplink MAC channel effects to user signals.

get_config

Get a dictionary of the channel's configuration.

get_user_csi

Get channel state information for a specific user.

update_interference_power

Update the inter-user interference power.

update_user_gain

Update the channel gain for a specific user.

__init__(user_channels: BaseChannel | List[BaseChannel], num_users: int | None = None, user_gains: float | List[float] | None = None, interference_power: float = 0.0, combine_method: str = 'sum', *args: Any, **kwargs: Any)[source]

Initialize the UplinkMAC channel.

Parameters:
  • user_channels (Union[BaseChannel, List[BaseChannel]]) – Channel instances for each user.

  • num_users (Optional[int]) – Number of users. Required if user_channels is a single channel.

  • user_gains (Optional[Union[float, List[float]]]) – Per-user channel gains.

  • interference_power (float) – Power of inter-user interference. Defaults to 0.0.

  • combine_method (str) – Method for combining user signals. Defaults to ‘sum’.

  • *args – Variable length argument list passed to the base class.

  • **kwargs – Arbitrary keyword arguments passed to the base class.

forward(x: List[Tensor], *args: Any, user_csi: List[Tensor] | None = None, user_noise: List[Tensor] | None = None, **kwargs: Any) Tensor[source]

Apply uplink MAC channel effects to user signals.

Parameters:
  • x (List[torch.Tensor]) – List of input signals, one per user. Each tensor should have the same shape.

  • *args – Additional positional arguments passed to individual channels.

  • user_csi (Optional[List[torch.Tensor]]) – Per-user channel state information. If provided, should be a list of CSI tensors (one per user).

  • user_noise (Optional[List[torch.Tensor]]) – Per-user noise tensors. If provided, should be a list of noise tensors (one per user).

  • **kwargs – Additional keyword arguments passed to individual channels.

Returns:

Combined received signal after applying channel effects

and inter-user interference.

Return type:

torch.Tensor

Raises:
  • ValueError – If the number of input signals doesn’t match num_users.

  • ValueError – If user_csi or user_noise lists don’t match num_users.

get_user_csi(user_idx: int) Tensor | None[source]

Get channel state information for a specific user.

Parameters:

user_idx (int) – Index of the user (0-based).

Returns:

CSI for the specified user, if available.

Return type:

Optional[torch.Tensor]

Raises:

ValueError – If user_idx is out of range.

update_user_gain(user_idx: int, new_gain: float) None[source]

Update the channel gain for a specific user.

Parameters:
  • user_idx (int) – Index of the user (0-based).

  • new_gain (float) – New gain value.

Raises:

ValueError – If user_idx is out of range.

update_interference_power(new_power: float) None[source]

Update the inter-user interference power.

Parameters:

new_power (float) – New interference power.

Raises:

ValueError – If new_power is negative.

get_config() Dict[str, Any][source]

Get a dictionary of the channel’s configuration.

Returns:

Dictionary of parameter names and values.

Return type:

Dict[str, Any]