Skip to content

Repository files navigation

MEC Offloading Visualizer

Tests Python 3.10+ License: MIT

MEC Offloading Visualizer is a lightweight and reproducible Python framework for comparing deterministic baseline task-offloading policies in a simplified mobile edge computing (MEC) scenario. It generates devices, edge servers, cloud servers, and heterogeneous tasks; evaluates latency, device energy, monetary cost, and deadline success; then exports auditable CSV files and headless Matplotlib figures.

This repository provides a lightweight baseline simulator. The RDHO repository contains manuscript-oriented optimization experiments, while the distributed scheduler repository focuses on reliable online execution infrastructure.

Scope

The simulator is a simplified, deterministic baseline model. It is not a production scheduler, a real deployment, a complete RDHO implementation, or an experimentally validated MEC platform. Results apply only to the supplied configuration, modeling assumptions, and seeds.

Key Features

  • YAML configuration with validated command-line overrides.
  • Deterministic scenario generation from an explicit random seed.
  • Three transparent baseline policies: local-only, edge-first, and cloud-first.
  • Task-level results, per-policy summaries, and multi-seed aggregation.
  • Portable output directories and non-interactive figure generation.
  • Editable installation, pytest coverage, and CI smoke tests.

Workflow

flowchart LR
  Config --> Scenario
  Scenario --> Policies
  Policies --> Model
  Model --> Metrics
  Metrics --> CSV
  Metrics --> Figures
Loading

Quick Start

Python 3.10 or newer is required.

python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
python -m pytest -q
mec-offloading-visualizer --config configs/default.yaml

On Windows PowerShell, activate with .venv\Scripts\Activate.ps1.

Run with command-line overrides and isolated output folders:

mec-offloading-visualizer \
  --config configs/default.yaml \
  --tasks 50 --devices 10 --edge-servers 2 --cloud-servers 1 --seed 123 \
  --results-dir results/seed-123 --figures-dir figures/seed-123

Run the import example and the standard five-seed validation:

python examples/run_example.py
python examples/run_multi_seed_validation.py \
  --config configs/default.yaml --seeds 42 43 44 45 46 \
  --results-dir results/multi-seed

Configuration and Baselines

configs/default.yaml defines scenario counts and sampling ranges. The default experiment uses seed 42, 20 devices, four edge servers, one cloud server, and 200 tasks. A supplied YAML file must contain the complete documented fields; unknown, missing, null, incorrectly typed, non-positive, and reversed-range values fail clearly.

Policy Selection rule Fallback behavior
local-only Execute every task on its originating device. Not applicable.
edge-first Deterministic round-robin edge selection by task ID. None.
cloud-first Deterministic round-robin cloud selection by task ID. None.

These are deterministic baselines, not optimization algorithms. Edge-first and cloud-first do not retry a missed deadline on another tier. An unavailable selected tier is an invalid scenario and raises an explicit error.

Metrics and Assumptions

For task workload w in million instructions (MI), device speed f_d in MIPS, input size s in MB, effective upload bandwidth b in Mbps, server speed f_s, and propagation delay p in milliseconds:

  • Local latency (ms): w / f_d * 1000.
  • Upload latency (ms): s * 8 / b * 1000, where b is min(device uplink, server bandwidth).
  • Remote latency (ms): upload latency + p + w / f_s * 1000.
  • Local device energy (J): w * device energy per MI.
  • Offloading device energy (J): transmit power * upload seconds.
  • Local cost is zero; remote cost is w * server cost per MI.
  • A task succeeds when total latency is less than or equal to its deadline.

The model omits result-download and idle-wait energy. It has no task queues, concurrent resource contention, dynamic node load, node failures, task migration, real network communication, or production deployment logic. See docs/design.md for modeling details.

Example Results

The following single-run values were regenerated by v1.0.0 from configs/default.yaml with seed 42. They are stored in summary.csv, with corresponding task rows in task_results.csv.

Policy Average latency (ms) Average energy (J) Average cost Success rate
local-only 7962.30 14.8370 0.0000 30.00%
edge-first 981.75 0.4047 0.1723 98.50%
cloud-first 737.85 0.5463 0.3622 100.00%

MEC baseline metric comparison

Task success rate by baseline policy

Five-seed outputs for 42-46 are in multi_seed_summary_by_seed.csv and multi_seed_aggregated_summary.csv. These observations describe only that simplified configuration and seed set; they do not establish policy superiority in other MEC environments.

Outputs and Reproducibility

A single run writes task_results.csv, summary.csv, metrics_comparison.png, and success_rate.png. Multi-seed validation additionally writes multi_seed_task_results.csv, multi_seed_summary_by_seed.csv, and multi_seed_aggregated_summary.csv. Commands overwrite fixed names in the selected output directory; use separate directories to retain runs. Generated top-level results and figures are ignored by Git. See docs/reproducibility.md for clean-environment reproduction.

Project Structure

configs/default.yaml                 Reproducible default configuration
docs/assets/                         Reproduced v1.0.0 figures
docs/examples/                       Compact CSV evidence
docs/design.md                       Architecture and modeling decisions
docs/reproducibility.md              Clean-environment reproduction guide
examples/                            Import and multi-seed examples
src/mec_offloading_visualizer/       Python package and CLI modules
tests/                               Behavioral and regression tests
.github/workflows/tests.yml          Supported-Python CI checks

Testing

python -m pytest -q

The suite covers configuration validation, scenario determinism and ranges, policy selection and missing tiers, hand-calculated metrics and deadline boundaries, stable CSV schemas, custom output paths, multi-seed aggregation, CLI exit behavior, and headless figure lifecycle.

Future Work Priorities

High priority: latency-aware and least-loaded baselines; configurable network conditions; deadline-violation and utilization analysis; multi-seed comparison reports.

Medium priority: a shared workload schema with the distributed scheduler; workload export; and explicit offline-simulation versus online-execution comparisons.

Lower priority: interactive visualization, additional charts, and a web front end.

Citation and License

See CITATION.cff for software citation metadata. Released under the MIT License.

About

A lightweight and deterministic MEC baseline simulator for comparing local, edge, and cloud execution policies.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages