{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## TriScale\n", "# Case Study - Video Streaming\n", "\n", "This notebook presents a case study of the TriScale framework. It revisits the analysis of [Pensieve](https://dl.acm.org/doi/10.1145/3098822.3098843), a system that generates adaptive bitrate algorithms for video streaming using reinforcement learning. Parts of this case study are described in the [TriScale paper](https://doi.org/10.5281/zenodo.3464273).\n", "\n", "## Evaluation objectives\n", "\n", "In this case study, various adaptive bitrate algorithms are compared using a user quality of experimence (QoE) as metric.\n", "\n", "The experiment has been designed and performed by the authors of [the Pensieve paper](https://dl.acm.org/doi/10.1145/3098822.3098843). In this case study, we show how _TriScale_ can be used to provide confidence intervals not only on single KPIs, but on entire cumulative distribution functions (CDFs).\n", "\n", "## List of Imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "import copy\n", "from pathlib import Path\n", "import zipfile\n", "\n", "import pandas as pd\n", "import numpy as np\n", "import plotly.graph_objects as go\n", "\n", "import triscale\n", "import triplots" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Download Source Files and Data\n", "[[Back to top](#TriScale)]\n", "\n", "The dataset for this case study is available on Zenodo: \n", "\n", "[](https://doi.org/10.5281/zenodo.3451417)\n", "\n", "\n", "The wget commands below download the required files to reproduce this case study.\n", "\n", "> **The .zip file is ~620 kB**" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Nothing to download\n" ] } ], "source": [ "# Set `download = True` to download (and extract) the data from this case study\n", "# Eventually, adjust the record_id for the file version you are interested in.\n", "\n", "# For reproducing the results of the TriScale paper, set `record_id = 3666724`\n", "\n", "download = True\n", "record_id = 3666724 # v3.0.1 (https://doi.org/10.5281/zenodo.3666724)\n", "\n", "files= ['UseCase_VideoStreaming.zip']\n", "if download:\n", " for file in files:\n", " print(file)\n", " url = 'https://zenodo.org/record/'+str(record_id)+'/files/'+file \n", " os.system('wget %s' %url)\n", " if file[-4:] == '.zip': \n", " with zipfile.ZipFile(file,\"r\") as zip_file:\n", " zip_file.extractall()\n", " print('Done.')\n", "else: \n", " print('Nothing to download')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We now import the custom module for the case study. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "import UseCase_VideoStreaming.videostreaming as vs" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Compute KPIs\n", "\n", "The metric values are given (retrieved from the Pensieve paper experiments). For each algorithm, we compute a set of KPIs which range from the 5th to the 98th percentile. Since our metric is QoE (larger is better) we compute lower-bounds for all KPIs." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Output retrieved from file. Skipping computation.\n" ] } ], "source": [ "# Construct the path to the different test results\n", "result_dir_path = Path('UseCase_VideoStreaming/FCC/linear')\n", "protocol_list = [x.stem for x in result_dir_path.iterdir()]\n", "protocol_list = list(set(protocol_list))\n", "config_file = Path('UseCase_VideoStreaming/config.yml')\n", "\n", "# Define the KPIs\n", "KPI_percentiles = np.arange(5,100,2) # percentiles\n", "KPI_confidence = 95 # confidence level\n", "KPI_base = {'confidence': KPI_confidence,\n", " 'bound': 'lower',\n", " 'unit': '',\n", " }\n", "KPI_list = []\n", "for p in KPI_percentiles:\n", " kpi = copy.deepcopy(KPI_base)\n", " kpi['percentile'] = p\n", " kpi['name'] = 'P%d'%p\n", " KPI_list.append(kpi)\n", " \n", "# Compute and store KPIs\n", "out_name = Path('UseCase_VideoStreaming') / 'kpis.csv'\n", "QoE = vs.compute_kpi(\n", " protocol_list,\n", " KPI_list,\n", " result_dir_path,\n", " out_name=out_name\n", ")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | Protocol | \n", "Network | \n", "QoE | \n", "Percentile | \n", "KPI | \n", "
|---|---|---|---|---|---|
| 0 | \n", "robust_mpc | \n", "FCC | \n", "linear | \n", "2 | \n", "-0.760 | \n", "
| 1 | \n", "robust_mpc | \n", "FCC | \n", "linear | \n", "4 | \n", "-0.033 | \n", "
| 2 | \n", "robust_mpc | \n", "FCC | \n", "linear | \n", "6 | \n", "0.114 | \n", "
| 3 | \n", "robust_mpc | \n", "FCC | \n", "linear | \n", "8 | \n", "0.140 | \n", "
| 4 | \n", "robust_mpc | \n", "FCC | \n", "linear | \n", "10 | \n", "0.163 | \n", "
| ... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
| 338 | \n", "buffer | \n", "FCC | \n", "linear | \n", "90 | \n", "1.073 | \n", "
| 339 | \n", "buffer | \n", "FCC | \n", "linear | \n", "92 | \n", "1.134 | \n", "
| 340 | \n", "buffer | \n", "FCC | \n", "linear | \n", "94 | \n", "1.197 | \n", "
| 341 | \n", "buffer | \n", "FCC | \n", "linear | \n", "96 | \n", "1.614 | \n", "
| 342 | \n", "buffer | \n", "FCC | \n", "linear | \n", "98 | \n", "2.237 | \n", "
343 rows × 5 columns
\n", "