# MEC-Simulator 2 (BigMEC)

This is a simple simulator for distributed, learning service placement strategies for mobile edge computing (MEC).

***

This software was used to evaluate the data for the publication

[BigMEC: Scalable Service Migration for Mobile Edge Computing](https://brandherm.info/wp-content/uploads/2022/11/brandherm2022BigMEC.pdf) (https://doi.org/10.1109/SEC54971.2022.00018)

Florian Brandherm, Julien Gedeon, Osama Abboud, Max Mühlhäuser

Symposium on Edge Computing, 12/2022

### Setup

* Check out the `Dockerfile`/`requirements.txt` for installing dependencies or build the docker image.
* Start the program with `python3 main.py`

| Command Line Parameter           | Explanation                     |
|---------------------------------:|:--------------------------------|
|`-h`, `--help`                    | Documentation of cli parameters |
|`-x`, `--headless`                | Disable GUI. Otherwise a visualization will be displayed. |
|`-c FILE`, `--configuration FILE` | Configuration file. If none is specified, interactive mode will ask to choose one configuration from the folder `defaultExperimentConfigurations`. |
|`-o DIR`, `--output DIR`          | Specify an output directory for the experiment logs. If not specified, the default directory is `./output`. |


### Experiments

The experiment scripts used in the paper evaluation are contained in the folder `experiments/SEC/`

***


### Output Data Formats
Each experiment output folder of methods that do not use reinforcement learning contains the following files:

- `configuration.json`, which is a copy of the used experiment configuration and can be used to reproduce the experiment.
- `statistics.csv`, which contains the raw logs of the simulation.

Experiment folders of methods that use reinforcement learning additionally contain the following files:

- `agent_statistics.csv`, which contains statistics from the reinforcement-learning-agent
- `weights_at_step_<step>.pickle`, which contains a snapshot of the neural network after training step `<step>` in a python-pickle format. These snapshots can be loaded in the configuration file of the test run after learning (However, for the publication of this data, we have deleted the absolute paths in the configuration files due to privacy reasons).
- `histograms.json`, which contains aggregated statistics in terms of histograms and cdfs for diagnostic purposes (unused in the paper). The data format is self-documenting.

The `statistics.csv` files have one row for every simulated step of 1 second, containing the follwoing columns:

- `global cost` the average cost of all service instances (total cost, divided by the number of service instances)
- `avg_latency` the average latency of all service instances recorded in the simulation
- `sim_time` real-time time since simulation start in the format `(D days )HH:MM:SS` (The experiments were performed on different machines, so the times are not comparable across experiments!)
- `num_migrations` number of migrations performed in the current time step
- `num_services` number of services active at the current time step
- `num_services_at_cloud` number of services that are place at the cloud node at the end of the current time step
- `mean_computation_time` Mean measured computation time in milliseconds per decision (The experiments were performed on different machines, so the times are not comparable across experiments!). Unused in non-rl experiments, therefore always -1
- `mean_communication_time` Mean modeled computation time in milliseconds per decision. Unused in non-rl experiments, therefore always -1
- `mean_communication_time_service_at_cloud` Mean modeled computation time in milliseconds per decision for service instances at the cloud. Unused in non-rl experiments, therefore always -1
- `mean_communication_time_service_at_edge` Mean modeled computation time in milliseconds per decision for service instances at the edge. Unused in non-rl experiments, therefore always -1

The `agent_statistics.csv` files were not directly used in the paper since they are mostly relevant for debugging. They contain one row for every training step of the reinforcement learning agents with the following columns:

- `avg_rewards` average rewards achieved by the neural network
- `losses` average training loss. Mostly useful for debugging.
- `Qs` average predicted Q-values. Also mostly useful for debugging.