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.
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:
- Locally on the originating UAV (zero transmission delay, constrained compute capacity, high battery drain).
- On an Edge Server (low network latency, medium compute capacity, finite task slots).
- 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.
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 |
+-----------------------------------------------------------------------------------+
To ensure scientific correctness, all physical quantities and units are strictly standardized:
| Parameter | Unit | Description |
|---|---|---|
|
Task Size ( |
Megabytes (MB) | Data volume that must be transmitted over the radio link. |
|
CPU Work ( |
Gigacycles ( |
Computational effort required to complete the task. |
|
Computing Capacity ( |
Gigacycles per second ( |
Processing speed / compute rate of the execution location. |
|
Bandwidth ( |
Megabits per second (Mbps) | Available channel transmission throughput. |
|
Network Latency ( |
Seconds (s) | Shortest routing latency computed via Dijkstra's algorithm. |
|
Task Deadline ( |
Seconds (s) | Maximum allowable turnaround time before QoS violation. |
$$\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$).
- 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}$).
| Algorithm | DAA Paradigm | Time Complexity | Space Complexity | Optimality Guarantee |
|---|---|---|---|---|
| Dijkstra Routing | Greedy (Min-Heap Priority Queue) | Globally optimal network latency paths | ||
| Greedy Offloading | Greedy Heuristic | Local optimum only; no global guarantee | ||
| Dynamic Programming | Multidimensional Knapsack (MMKP) | Mathematically optimal for stated discrete model |
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$ .
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
- Python 3.10+ (tested on Python 3.14 on Windows 11/10).
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.txtpython app.pyOpen your browser and navigate to:
http://127.0.0.1:5000/
python main.pypython -m pytest -v- 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:
- Total Completion Delay Comparison (Greedy vs. Exact DP).
- Algorithm Runtime in Milliseconds (demonstrating the speed of Greedy vs. the complexity of DP).
- Deadline Violations vs. Successfully Completed Tasks.
- CPU Resource Utilization by Computing Location.
- Academic Theory & Complexity Guide:
- In-app explanations of algorithm recurrences, decision rules, and asymptotic notations.
-
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. - Deterministic Mobility: The current model evaluates stationary UAV communication hops during the offloading window; dynamic kinematic 3D trajectory tracking is left as future work.
- Queue Independence: Independent single-core FIFO queues are modeled per node; multi-core thread preemption is simulated at the server level.
- 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.