Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Edge Classification with a Token Bucket MDP

This is a python implementation of the algorithm described in the paper below for computing optimal offloading policies, as well of simulation and testing code to evaluate these policies:

Ayan Chakrabarti, Roch Guérin, Chenyang Lu, and Jiangnan Liu, "Real-time Edge Classification: Optimal Offloading under Token Bucket Constraints," arXiv:2010.13737 [cs.LG], 2020.


We recommend installing a recent Python 3.7+ distribution of Anaconda. The code uses numpy for numeric computation, numba to enable JIT compilation and speed-up of the simulation code, multiprocessing to run tests for different parameters in parallel, and matplotlib to visualize results in jupyter notebooks.

Policy Computation and Simulation

The actual library for computing policies and simulating transmissions and rewards with these policies is in the eomdp directory. Please take a look at its file for documentation.

Simulation Results and Data

You may either download and use our pre-computed results, or re-run experiments yourself.

Download pre-computed results

From the repository directory, run the following commands in your shell:


This will extract all data files into the save/ sub-directory. You should then be able to directly run the note-books in the visualization step.

Generate results

You will need to first download an npz file containing the outputs and performance of the weak and strong OFA classifiers used in our simulations. Do this by running the following command in your shell from the repository directory:


After that, run the following test scripts in sequence for the single device experiments. Note that these scripts will run in parallel spawning a pool of processes based on all available CPU cores on the machine.

./  # Runs tests to fit entropy to metric separately for each fold.
./   # Runs single device simulations for various (r,b) values.
./   # Runs experiments with train-test mismatch to measure robustness.

Then, to run experiments for the multi-device experiments, run the following tests in sequence. Note that since this requires doing a grid-search for every setting of (r_tot, b_tot, #camera) for the hierarchical strategy, this might take a while.

./  # Generate policies for all possible r_i, b_i
./       # Simulate each policy with each setting on training set.
./       # Generate final results.


We provide separate jupyter notebooks to visualize (either downloaded or generated) results, producing the figure included in the paper (and more).


This code is being released under the MIT License. Note that the OFA results file were generated from the models and code provided by its authors.


This work was partially supported by the National Science Foundation under awards no. CPS-1646579 and CNS-1514254. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the authors, and do not necessarily reflect the views of the National Science Foundation.