Models API
Vectorized Urban Map Generator
Radio Channel Model
UrbanMARL Radio Channel Model.
Vectorized mmWave radio channel propagation model calculating Friis path loss, LoS/NLoS attenuation exponent shifts, interference, and Shannon channel capacity.
- class urbanmarl.models.channel.VectorizedChannelModel(config, device)[source]
Bases:
objectComputes batched path loss, received power, interference, and data rates.
- Variables:
device (
torch.device) – Compute device for PyTorch tensor calculations.freq_ghz (
float) – Carrier frequency in Gigahertz (e.g. 29.0 GHz mmWave).bandwidth (
float) – Transmit channel bandwidth in Hertz.noise_figure_db (
float) – Receiver noise figure in decibels.noise_power (
float) – Receiver thermal noise power in Watts.
- Parameters:
config (dict)
device (torch.device)
- __init__(config, device)[source]
Initializes the VectorizedChannelModel.
- Parameters:
config (
dict) – Channel configuration dictionary containing optional keys: - ‘frequency_ghz’: carrier frequency in GHz (default: 29.0). - ‘g2a_bandwidth’: channel bandwidth in Hz (default: 10e6). - ‘noise_figure_db’: noise figure in dB (default: 7.0).device (
torch.device) – Compute device.
- Return type:
None
- compute_data_rates(tx_pos, rx_pos, tx_power, los_mask)[source]
Calculates achievable transmission data rates (bps) using Shannon capacity.
- Parameters:
tx_pos (
torch.Tensor) – Transmitter positions (UEs) of shape (B, M, 3).rx_pos (
torch.Tensor) – Receiver positions (UAVs) of shape (B, N, 3).tx_power (
torch.Tensor) – Transmission power (Watts) of shape (B, M).los_mask (
torch.Tensor) – Line-of-sight boolean tensor of shape (B, N, M).
- Returns:
Achievable channel capacity data rates in bps of shape (B, N, M).
- Return type:
MEC Queue Model
UrbanMARL Mobile Edge Computing (MEC) M/M/c Queue Model.
Pure PyTorch implementation of M/M/c queuing theory calculating server utilization, queue lengths, waiting times, and total system processing delay across parallel environments.
- class urbanmarl.models.mec_queue.VectorizedMECQueue(device, max_cores=64)[source]
Bases:
objectPyTorch tensor M/M/c queuing model for edge servers.
- Variables:
device (
torch.device) – Compute device.max_cores (
int) – Maximum server processing core capacity.log_fact (
torch.Tensor) – Precomputed log-factorial array for numerical stability.
- Parameters:
device (torch.device)
max_cores (int)
- __init__(device, max_cores=64)[source]
Initializes the VectorizedMECQueue model.
- Parameters:
device (
torch.device) – Compute device for PyTorch operations.max_cores (
int) – Maximum core count upper bound (default: 64).
- Return type:
None
- compute_delays(arrival_rates, service_rates, num_cores)[source]
Computes M/M/c queuing delays and utilization metrics for a batch of UAVs.
- Parameters:
arrival_rates (
torch.Tensor) – Task arrival rates (lambda) of shape (B, N).service_rates (
torch.Tensor) – Service rates per core (mu) of shape (B, N).num_cores (
torch.Tensor) – Number of allocated server cores (c) of shape (B, N).
- Returns:
- Dictionary containing tensors for:
’utilization’: server traffic intensity rho of shape (B, N).
’avg_queue_length’: expected number of queued tasks of shape (B, N).
’avg_waiting_time’: expected queue waiting time in seconds of shape (B, N).
’avg_system_time’: total system response time (wait + service) of shape (B, N).
- Return type:
DTLCM Offloading Assignment
UrbanMARL Dynamic Distance-Task-Load Capacity Matching (DTLCM).
Provides continuous tensor heuristic matching for UAV-MEC task offloading assignments.
- urbanmarl.models.dtlcm.compute_batched_dtlcm_assignment(uav_pos, ue_pos, uav_caps, uav_loads, task_workloads, distance_weight=0.7)[source]
Executes batched heuristic DTLCM assignment for task offloading.
- Parameters:
uav_pos (
torch.Tensor) – UAV 3D positions of shape (B, N, 3).ue_pos (
torch.Tensor) – UE 3D positions of shape (B, M, 3).uav_caps (
torch.Tensor) – UAV compute capacities of shape (B, N).uav_loads (
torch.Tensor) – Current UAV load levels of shape (B, N).task_workloads (
torch.Tensor) – Offloaded task workloads of shape (B, M).distance_weight (
float) – Weight assigned to spatial distance score (default: 0.7).
- Returns:
Long tensor of assigned UAV indices per UE of shape (B, M).
- Return type:
Network Digital Twin (NDT) & REM
UrbanMARL Network Digital Twin (NDT) Architecture & Telemetry Model.
Provides a unified, 4-layer synchronized digital twin model for 6G multi-UAV assisted Mobile Edge Computing (MEC) networks: 1. Geospatial & Structural Twin: 3D urban terrain, ITU-R P.1410 parameters, buildings. 2. Radio Environment Map (REM) Twin: Spatial SINR coverage, LoS/NLoS paths, channel capacity. 3. Computational & Queuing Twin: M/M/c server utilization, queue lengths, task latency. 4. Aerial Mobility & Energy Twin: UAV kinematics, battery state, aerodynamic energy, sojourn time.
Includes vectorized Radio Environment Map (REM) generators, live telemetry extraction, and JSON-compliant serialization for 3D digital twin visualization engines.
- class urbanmarl.models.digital_twin.GeospatialTwinState(volume_size, alpha, beta, gamma, e_param, n_buildings, building_width, street_width, building_count)[source]
Bases:
objectGeospatial and structural digital twin layer state.
- Parameters:
- class urbanmarl.models.digital_twin.REMTwinState(frequency_ghz, bandwidth_hz, coverage_ratio, mean_sinr_db, los_link_count, nlos_link_count, mean_data_rate_mbps)[source]
Bases:
objectRadio Environment Map (REM) and wireless propagation digital twin state.
- Parameters:
- class urbanmarl.models.digital_twin.ComputeQueuingTwinState(mean_utilization, max_utilization, mean_queue_length, mean_waiting_time_ms, mean_system_time_ms, total_completed_tasks, total_dropped_tasks)[source]
Bases:
objectMEC computation and queuing dynamics digital twin state.
- Parameters:
- class urbanmarl.models.digital_twin.AerialMobilityTwinState(n_uavs, n_ues, mean_uav_altitude, mean_uav_speed, mean_battery_pct, mean_propulsion_power_w, mean_sojourn_time_steps, collision_count)[source]
Bases:
objectUAV swarm kinematics, energy, and sojourn coverage digital twin state.
- Parameters:
- class urbanmarl.models.digital_twin.NDTTelemetryFrame(frame_id, timestamp_s, geospatial, rem, compute, mobility, uav_positions, ue_positions, uav_telemetry, active_links)[source]
Bases:
objectUnified Network Digital Twin (NDT) telemetry snapshot for a single step.
- Parameters:
frame_id (int)
timestamp_s (float)
geospatial (GeospatialTwinState)
rem (REMTwinState)
compute (ComputeQueuingTwinState)
mobility (AerialMobilityTwinState)
- geospatial: GeospatialTwinState
- rem: REMTwinState
- compute: ComputeQueuingTwinState
- mobility: AerialMobilityTwinState
- class urbanmarl.models.digital_twin.RadioEnvironmentMap(volume_size, grid_resolution=50, frequency_ghz=29.0, bandwidth_hz=10000000.0, noise_figure_db=7.0, sinr_threshold_db=0.0, device='cpu')[source]
Bases:
objectVectorized 2D/3D Radio Environment Map (REM) generator.
Computes spatial received signal power, interference, and Signal-to-Interference-plus-Noise Ratio (SINR) across a uniform spatial evaluation grid over the urban volume.
- Parameters:
- __init__(volume_size, grid_resolution=50, frequency_ghz=29.0, bandwidth_hz=10000000.0, noise_figure_db=7.0, sinr_threshold_db=0.0, device='cpu')[source]
Initializes the RadioEnvironmentMap generator.
- Parameters:
volume_size (
Tuple[float,float,float]) – Urban dimensions (sim_x, sim_y, sim_z).grid_resolution (
int) – Spatial grid points along each horizontal axis. Defaults to 50.frequency_ghz (
float) – Carrier frequency in GHz. Defaults to 29.0.bandwidth_hz (
float) – Channel bandwidth in Hz. Defaults to 10e6.noise_figure_db (
float) – Receiver noise figure in dB. Defaults to 7.0.sinr_threshold_db (
float) – Minimum SINR in dB for valid coverage. Defaults to 0.0.device (
Union[torch.device,str]) – PyTorch compute device.
- Return type:
None
- compute_rem(uav_positions, tx_power=2.0, urban_map=None, env_idx=0)[source]
Computes spatial SINR and coverage ratio for active UAV positions.
- Parameters:
uav_positions (
torch.Tensor) – UAV 3D coordinates of shape (N, 3) or (B, N, 3).tx_power (
float) – Transmit power per UAV in Watts. Defaults to 2.0.urban_map (Any | None) – Optional VectorizedUrbanMap instance for LoS ray-casting.
env_idx (
int) – Batch index if uav_positions has batch dimension.
- Returns:
‘sinr_grid’: 2D tensor of shape (grid_res, grid_res) in dB.
’coverage_mask’: 2D boolean tensor indicating SINR >= threshold.
’coverage_ratio’: Float percentage in [0.0, 1.0].
’mean_sinr_db’: Average SINR across all grid points in dB.
- Return type:
Dict[str, Union[torch.Tensor, float]]
- class urbanmarl.models.digital_twin.NetworkDigitalTwin(volume_size=(500.0, 500.0, 200.0), frequency_ghz=29.0, bandwidth_hz=10000000.0, noise_figure_db=7.0, rem_resolution=40, device='cpu')[source]
Bases:
objectCentral Network Digital Twin (NDT) manager for UrbanMARL simulations.
Synchronizes physical, wireless, computing, and mobility layers and extracts structured telemetry frames and serialization exports.
- Parameters:
- __init__(volume_size=(500.0, 500.0, 200.0), frequency_ghz=29.0, bandwidth_hz=10000000.0, noise_figure_db=7.0, rem_resolution=40, device='cpu')[source]
Initializes the NetworkDigitalTwin manager.
- Parameters:
volume_size (
Tuple[float,float,float]) – 3D urban simulation bounds.frequency_ghz (
float) – mmWave carrier frequency.bandwidth_hz (
float) – Channel bandwidth.noise_figure_db (
float) – Receiver noise figure.rem_resolution (
int) – Spatial grid resolution for Radio Environment Maps.device (
Union[torch.device,str]) – Compute device.
- Return type:
None
- capture_frame(env, env_idx=0, step=None, compute_rem_heatmap=False)[source]
Captures a complete digital twin telemetry frame from an active UrbanEnv.
- Parameters:
- Returns:
Structured telemetry snapshot.
- Return type:
- export_telemetry_json(frame, filepath=None)[source]
Exports a single telemetry frame to JSON string or file.
- Parameters:
frame (
NDTTelemetryFrame) – Telemetry snapshot.filepath (
Optional[str]) – Target file path to write to.
- Returns:
Serialized JSON payload string.
- Return type: