Skip to content

About

Optimal UAV Task Offloading in Edge–Cloud Computing using Greedy, Dynamic Programming, Graph Theory and Scheduling Algorithms.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Optimal UAV Task Offloading in Edge–Cloud Computing

Design and Analysis of Algorithms (DAA) Course Project
A mathematically grounded simulation, optimization, and comparison suite evaluating computational offloading decisions for Unmanned Aerial Vehicles (UAVs) across Edge and Cloud computing tiers.


1. Project Overview & Motivation

Unmanned Aerial Vehicles (UAVs or drones) play an essential role in disaster surveillance, search-and-rescue, environmental mapping, and real-time object tracking. However, UAVs have strict onboard hardware constraints:

  • Limited Battery Capacity: High-performance processors drain battery life exponentially, reducing flight duration.
  • Constrained Computational Power: Complex computer vision and image processing algorithms demand billions of CPU cycles that exceed low-power drone hardware.
  • Strict Quality-of-Service (QoS) Deadlines: Mission-critical tasks (such as obstacle detection) must complete within milliseconds to prevent mission failure.

Core Objective:
Build an academically rigorous simulation system that decides where computational tasks generated by UAVs should execute:

  1. Locally on the originating UAV (zero transmission delay, constrained compute capacity, high battery drain).
  2. On an Edge Server (low network latency, medium compute capacity, finite task slots).
  3. On a Central Cloud Server (high compute capacity, infinite virtual scaling, but higher network transmission and backbone latency).

The objective is to minimize total completion delay and deadline violations while strictly respecting computing capacity limits, server task slots, and communication bottlenecks.


2. System Architecture

The simulation models a hierarchical three-tier computing architecture:

+-----------------------------------------------------------------------------------+
|                                TIER 1: UAV FLEET                                  |
|   [ UAV 1 (2.0 GC/s) ]       [ UAV 2 (3.0 GC/s) ]       [ UAV 3 (2.5 GC/s) ]     |
|   Battery: 80%, BW: 10M      Battery: 70%, BW: 15M      Battery: 90%, BW: 12M     |
+--------------------------+------------------------------+-------------------------+
                           | Cellular / Wi-Fi Uplink      |
                           v (Dijkstra Shortest Latency)  v
+-----------------------------------------------------------------------------------+
|                            TIER 2: EDGE SERVERS (MEC)                             |
|               [ Edge Server 1 (10.0 GC/s, 8 Task Slots, 100 Mbps) ]               |
|                      Local low-latency compute at the base station                |
+------------------------------------------+----------------------------------------+
                                           | Core Fiber Backbone (2.5s Latency)
                                           v
+-----------------------------------------------------------------------------------+
|                         TIER 3: CLOUD DATA CENTER                                 |
|               [ Cloud Server 1 (50.0 GC/s, 20 Task Slots, 1000 Mbps) ]            |
|                     High-throughput elastic compute cluster                       |
+-----------------------------------------------------------------------------------+

3. Mathematical Model & Cost Calculations

To ensure scientific correctness, all physical quantities and units are strictly standardized:

Parameter Unit Description
Task Size ($S_i$) Megabytes (MB) Data volume that must be transmitted over the radio link.
CPU Work ($W_i$) Gigacycles ($\text{GC} = 10^9$ cycles) Computational effort required to complete the task.
Computing Capacity ($F_j$) Gigacycles per second ($\text{GC/s}$) Processing speed / compute rate of the execution location.
Bandwidth ($B_{u,j}$) Megabits per second (Mbps) Available channel transmission throughput.
Network Latency ($\tau_{u,j}$) Seconds (s) Shortest routing latency computed via Dijkstra's algorithm.
Task Deadline ($D_i$) Seconds (s) Maximum allowable turnaround time before QoS violation.

3.1 Transmission Delay

$$\text{Time}{\text{trans}}(i, j) = \frac{S_i \times 8}{B{u,j}} \quad [\text{seconds}]$$ (For local UAV execution, $\text{Time}_{\text{trans}} = 0$).

3.2 Processing Delay

$$\text{Time}_{\text{proc}}(i, j) = \frac{W_i}{F_j} \quad [\text{seconds}]$$

3.3 Total Response Time

$$\text{Delay}_{\text{total}}(i, j) = \text{Time}_{\text{trans}}(i, j) + \tau_{u,j} + \text{Time}_{\text{proc}}(i, j)$$

3.4 UAV Energy Consumption

  • Local execution: $E_i = P_{\text{cpu}} \times \text{Time}{\text{proc}}$ (where $P{\text{cpu}} = 2.0\text{ W}$).
  • Offloaded execution: $E_i = P_{\text{tx}} \times \text{Time}{\text{trans}} + P{\text{idle}} \times (\tau + \text{Time}{\text{proc}})$ ($P{\text{tx}} = 1.2\text{ W}, P_{\text{idle}} = 0.2\text{ W}$).

4. Algorithms Implemented & Complexity Analysis

Algorithm DAA Paradigm Time Complexity Space Complexity Optimality Guarantee
Dijkstra Routing Greedy (Min-Heap Priority Queue) $\mathcal{O}((V + E) \log V)$ $\mathcal{O}(V + E)$ Globally optimal network latency paths
Greedy Offloading Greedy Heuristic $\mathcal{O}(N \cdot (1 + E + C))$ $\mathcal{O}(N + U + E + C)$ Local optimum only; no global guarantee
Dynamic Programming Multidimensional Knapsack (MMKP) $\mathcal{O}(N \cdot W_E \cdot W_C \cdot \prod W_U)$ $\mathcal{O}(N \cdot W_E \cdot W_C)$ Mathematically optimal for stated discrete model

4.1 Dynamic Programming Formulation (MMKP)

The offloading decision is formulated as a Multiple-Choice Multidimensional Knapsack Problem:

  • Let $N$ tasks be indexed $i \in {1, \dots, N}$.
  • Let discrete CPU capacities be $W_E = \lfloor C_E / \Delta \rfloor$, $W_C = \lfloor C_C / \Delta \rfloor$, and $W_{u} = \lfloor C_{u} / \Delta \rfloor$ with quantum $\Delta$ (default 1.0 GC).
  • State Representation: $(i, e, c, \mathbf{u})$, where $i$ is the task stage, $e$ is Edge CPU consumed, $c$ is Cloud CPU consumed, and $\mathbf{u} = (u_1, \dots, u_K)$ is the vector of UAV local capacities.
  • Bellman Recurrence: $$\text{DP}[i, e, c, \mathbf{u}] = \min_{d \in \mathcal{D}i} \Big{ \text{DP}[i-1, e - r{i,e}, c - r_{i,c}, \mathbf{u} - \mathbf{r}_{i,u}] + \text{Cost}(i, d) \Big}$$ where $\text{Cost}(i, d)$ is $\text{Delay}(i, d)$ for feasible allocations or penalty $P = 1000\text{s}$ for unallocated tasks.
  • Reconstruction: Every transition stores backpointers to trace back the exact optimal assignment vector without heuristics.
  • Instance Bound: To guard against exponential memory explosion, DP is bounded to instances where $N \le 25$ and total reachable states $\le 150,000$.

5. Project Directory Structure

UAV-Task-Offloading/
├── algorithms/
│   ├── __init__.py
│   ├── dynamic_programming.py    # Exact MMKP DP with capacity guards & reconstruction
│   ├── graph.py                  # Adjacency list & Min-Heap Dijkstra with path reconstruction
│   └── greedy.py                 # Isolated greedy heuristic with full metrics
├── data/                         # Workload data stores
├── results/                      # Output simulation benchmarks
├── simulation/
│   ├── __init__.py
│   └── simulator.py              # Unified simulation engine & fair comparison suite
├── static/
│   ├── css/
│   │   └── style.css             # Responsive dark navy & blue professional dashboard CSS
│   └── js/
│       └── app.js                # Vanilla JS client, Chart.js charts, Canvas visualizer
├── templates/
│   └── index.html                # Interactive single-page dashboard UI
├── tests/
│   ├── test_api.py               # Flask REST API integration tests
│   ├── test_cost.py              # Cost, delay, and energy unit verification
│   ├── test_dp.py                # Exact DP recurrence, base cases, and threshold guards
│   ├── test_graph.py             # Dijkstra, negative weight validation, and path checks
│   ├── test_greedy.py            # Greedy feasibility, capacity constraints, non-mutation
│   └── test_simulator.py         # Workload generator seeds and benchmark comparisons
├── app.py                        # Flask backend web application
├── cost.py                       # Validated physical cost and delay equations
├── main.py                       # Standalone CLI demonstration script
├── models.py                     # Object-oriented domain entities (Task, UAV, Edge, Cloud)
├── requirements.txt              # Production dependency specifications
└── README.md                     # Comprehensive academic documentation

6. How to Run on Windows

6.1 Prerequisites

  • Python 3.10+ (tested on Python 3.14 on Windows 11/10).

6.2 Setup Virtual Environment (Recommended)

Open PowerShell or Command Prompt:

# Navigate to project directory
cd d:\TY\DAA\DAA_CP\UAV-Task-Offloading

# Create virtual environment
python -m venv .venv

# Activate virtual environment
# In PowerShell:
.\.venv\Scripts\Activate.ps1
# Or in Command Prompt (cmd.exe):
.venv\Scripts\activate.bat

# Install dependencies
python -m pip install -r requirements.txt

6.3 Run the Web Dashboard

python app.py

Open your browser and navigate to: http://127.0.0.1:5000/

6.4 Run the CLI Demonstration

python main.py

6.5 Run the Automated Test Suite

python -m pytest -v

7. Web Dashboard Features

  • Top KPI Cards: Real-time overview of active UAV fleet count, task volume, Edge servers, and Cloud data centers.
  • Scenario Presets:
    • Academic Benchmark: Canonical 4-task workload from academic baseline.
    • Edge Capacity Stress Test: Heavy workload testing Cloud vs. local offloading under edge saturation.
    • Strict Deadlines Scenario: High-load scenario with constrained deadlines comparing Greedy vs. Exact DP offloading compliance.
    • DP Verifiable Small Instance: Compact 5-task instance for step-by-step mathematical verification.
  • Interactive Network Visualizer:
    • Live Canvas rendering of UAV nodes, Edge nodes, and Cloud servers.
    • Directional communication links and shortest-latency routing paths computed by Dijkstra.
  • Task Allocation Matrix:
    • Live table listing Task ID, Origin, Type, Priority, Location, Transmission Delay, Network Latency, Processing Delay, Total Response Time, Deadline, and Status.
  • Four Dynamic Chart.js Analytics:
    1. Total Completion Delay Comparison (Greedy vs. Exact DP).
    2. Algorithm Runtime in Milliseconds (demonstrating the speed of Greedy vs. the complexity of DP).
    3. Deadline Violations vs. Successfully Completed Tasks.
    4. CPU Resource Utilization by Computing Location.
  • Academic Theory & Complexity Guide:
    • In-app explanations of algorithm recurrences, decision rules, and asymptotic notations.

8. Limitations & Future Scope

Limitations

  1. Discretization Trade-off: The exact DP discretizes CPU cycles using a finite step size ($\Delta$). Smaller step sizes yield higher precision at the cost of larger state-space tables.
  2. Deterministic Mobility: The current model evaluates stationary UAV communication hops during the offloading window; dynamic kinematic 3D trajectory tracking is left as future work.
  3. Queue Independence: Independent single-core FIFO queues are modeled per node; multi-core thread preemption is simulated at the server level.

Future Scope

  • Integration of Reinforcement Learning (Deep Q-Networks / PPO) for time-varying multi-agent UAV swarms.
  • Doppler effect and Rayleigh fading RF wireless channel modeling.
  • Real-time flight trajectory battery drainage coupling.

About

Optimal UAV Task Offloading in Edge–Cloud Computing using Greedy, Dynamic Programming, Graph Theory and Scheduling Algorithms.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages