This project implements an intelligent edge vs cloud offloading system using:
- Deep Learning (CNN + LSTM + Attention)
- SLA-aware cost optimization
- Reinforcement Learning (RL)
The objective is to minimize total cost (SLA + latency) by deciding whether to execute tasks on the edge or cloud.
- Uses Telecom Italia Milano Grid Dataset
- Extracts:
- square_id
- timestamp
- internet traffic
- Selects top M = 49 grid cells
- Normalizes traffic data
- Creates time windows of size N = 6
- CNN + LSTM + Attention
- Outputs:
- yL → Edge prediction
- z → latent features
- Fully connected network
- Uses latent representation z
- Outputs:
- yR → Cloud prediction
Train only edge model using SLA loss
Train cloud model using edge features
Train both models together
Loss Function: Loss = 0.25MSE(yL, y) + 0.25MSE(yR, y) + alpha * SLA_loss
State: [ (CL - CR), RTT ]
Actions:
0 → Edge
1 → Cloud
Reward:
- Penalizes SLA cost
- Penalizes cloud latency
- Edge / Cloud percentage
- Total cost
- SLA cost
- Latency
- Benefit = CL - CR
project/
│── train.py
│── models.py
│── rl_agent.py
│── utils.py
│── dataset/
│── results/
git clone
cd project
python -m venv venv
Activate:
- Linux/Mac: source venv/bin/activate
- Windows: venv\Scripts\activate
pip install torch numpy pandas matplotlib
-
Create dataset folder: dataset/
-
Add Milano dataset files: sms-call-internet-mi-2013-11-01.txt
...
sms-call-internet-mi-2013-11-30.txt -
Ensure path in code: data_path = "./dataset"
Run the full pipeline: python train.py
The code automatically uses GPU if available: device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
Check GPU: python -c "import torch; print(torch.cuda.is_available())"
All outputs are saved in: results/
Generated files:
- plot1.png → RTT vs Edge/Cloud decisions
- plot_metrics(plot2).png → Metrics comparison
- plot3.png → Spatial attention
- plot4.png → Temporal attention
- offloading_decisions.txt
- edge_cost.txt
- cloud_cost.txt
- Low RTT → Cloud preferred
- High RTT → Edge preferred
- RL learns adaptive offloading
- Attention highlights important regions and time steps
M = 49
N = 6
alpha = 0.3
w = 0.3
lambda_rtt = 0.015
rl_epochs = 350
- Real-time data integration
- Advanced RL algorithms (DQN, PPO)
- Multi-agent systems
- Dynamic network adaptation
122cs0058,122ad0031