xDRL-RCS-Python is a Python-based simulation and training environment designed for xDRL-driven RAN slicing.
It enables simulation, training, and evaluation of advanced Reinforcement Learning (RL) algorithms with SHAP-based explainability and XAI-PPO integration.
The framework provides visual and quantitative KPI comparisons, supporting end-to-end explainable AI evaluation for 5G RAN slicing scenarios.
In multi-slice 5G networks, maintaining high performance and efficiency across diverse service types requires continuous monitoring and intelligent resource management.
This project provides a Deep Reinforcement Learning (DRL)–based xApp integrated into the O-RAN architecture to achieve automated and adaptive RAN slicing optimization.
The xApp dynamically adjusts Physical Resource Block (PRB) and bandwidth allocations across multiple network slices to ensure fairness, performance stability, and optimal utilization.
It operates in coordination with a customized KPM (Key Performance Measurement) monitoring xApp, which continuously collects real-time KPI metrics - such as throughput, latency, and PRB usage - from connected User Equipment (UE) devices.
All collected KPIs are stored in a MySQL database, forming the data backbone for DRL training, evaluation, and decision-making.
This architecture enables a closed-loop control system, where measured performance metrics directly inform learning-based optimization decisions, resulting in self-adaptive, explainable, and data-driven RAN management.
The xDRL-RCS-Python environment extends this framework by simulating the 5G RAN slicing process, incorporating explainable AI (XAI) techniques such as SHAP and XAI-PPO to provide deeper interpretability and transparency in DRL-based network control decisions.
The XAI pipeline in xDRL-RCS-Python consists of several structured steps that together form a full simulation, explainability, and evaluation workflow.
Description:
- Initialize the working environment and runtime configuration.
- Import and configure all required dependencies.
- Define and register the feature names used throughout the pipeline for training, evaluation, and interpretability tasks.
This step ensures a reproducible environment and consistent feature mapping across all modules.
Description:
- Implement the evaluation functions responsible for model assessment and performance scoring.
- Define sampling utilities to generate representative feature subsets for SHAP analysis.
- Provide supporting utilities for:
- Feature preprocessing and encoding.
- Seamless integration between the RL models and SHAP explainability components.
The SHAP sampler acts as a bridge between the trained RL model and the interpretability layer, allowing for precise estimation of feature importance.
Description:
- Compute SHAP values to determine per-feature contribution to the model’s decisions.
- Use the SHAP-derived attributions to prune the environment, removing less relevant features or states.
- Instantiate a new, pruned environment optimized for XAI-specific training and evaluation.
This selective pruning enhances interpretability while preserving essential performance characteristics.
Description:
-
Execute the complete XAI workflow, including:
- Training of baseline RL algorithms.
- Performance evaluation on initial (non-pruned) environment.
- SHAP analysis and environment pruning.
- Re-training of XAI-augmented models (e.g., XAI-PPO).
- Comparative evaluation between baseline and explainable models.
-
Visualization and Comparative Analysis:
- Generate detailed plots illustrating:
- Feature attributions.
- KPI trends.
- Slice-wise performance differences across methods.
- Present side-by-side comparisons for better interpretability and explainability insights.
- Generate detailed plots illustrating:
The final outcome is a transparent and analytically rich view of how explainable RL models behave in dynamic 5G RAN slicing environments.
The drl_learning_service and xdrl_learning_service directories contain two modular, end-to-end Python service frameworks designed for DRL and xDRL model development. These modules include:
-
Complete DRL/xDRL pipelines
Full implementations covering environment configuration, model training loops, evaluation routines, and experiment orchestration. -
Explainability & Interpretation Toolkit
Integrated XAI components - SHAP, XAI, and XAI-PPO - to provide feature attribution, policy interpretation, and insight into model decision-making. -
Utility & Helper Modules
Tools for dataset preprocessing, KPI extraction/management, logging, and visualization of training dynamics and learned policies. -
Reproducible Environment Setup
Clearly defined package and dependency specifications required to recreate the experimental environment. -
Inline Documentation & Workflow Guidance
Concise notes throughout the codebase outlining the logic, workflow stages, and function responsibilities to improve readability, onboarding, and reproducibility.
The xdrl_inference_service directory contains a lightweight, production-oriented Python module for running inference with pretrained xDRL models. This component is designed to operate independently from the training pipeline while seamlessly consuming its outputs.
After executing the xDRL learning service, a trained model is stored under the trained_models directory inside xdrl_learning_service. The inference module loads this pretrained model and performs:
- A continuous decision-making loop, applying the learned policy to incoming data.
- A short-term adaptive learning phase triggered approximately every 50 iterations, allowing the agent to refine its decisions based on recent observations.
- Final output generation, produced after the quick adaptation phase stabilizes, enabling real-time or near-real-time decision support.
This structure enables efficient deployment of xDRL models with minimal overhead while preserving adaptability during operation.
Before running any service, ensure that all required Python dependencies are installed. Each service directory includes its own requirements.txt, so installation should be done per service:
pip install --upgrade pip
pip install -r requirements.txtOnce dependencies are installed, you can launch the xDRL or DRL learning services by simply executing:
python3 main.pyEach service will initialize its internal modules, load configurations, and begin the corresponding training or inference workflow.
To run the inference service, first place the pretrained model directory (trained_models) - produced by the xDRL learning service - inside the xdrl_inference_service folder.
The main.py file includes three example scenario functions, each demonstrating a different inference workflow. You may comment/uncomment these functions to experiment with the scenarios individually.
To execute the inference module, use the same run command:
python3 main.pyThe service will load the pretrained model, run the decision-making loop, and perform short-term adaptive learning during inference.
Note: All learning and inference modules involve computationally intensive operations, especially during training and short-term adaptation phases.
For optimal performance, it is strongly recommended to run these services on a machine equipped with a GPU (preferably CUDA-enabled).
Below are representative outputs generated from running the xDRL-RCS-Python simulation and training environment.
These examples illustrate the training process, model performance, and slice-level KPI evaluations across various DRL algorithms.
Shows the runtime progress and performance updates during model training and evaluation.
Demonstrates the convergence behavior of the DRL agent by visualizing accuracy trends and loss reduction over time.
Comparative visualization of Service Level Agreement (SLA) compliance across different DRL algorithms (PPO, A2C, and DQN).
Each plot represents slice-level KPI performance and the effectiveness of the corresponding learning policy.
| PPO | A2C | DQN |
|---|---|---|
![]() |
![]() |
![]() |
These visual results collectively demonstrate the explainable, performance-driven optimization achieved by the DRL-based xApp within the 5G RAN slicing simulation environment.





