| Algorithm 1. The optimal mode selection |
| 1: Initialize system parameters such as T, , , K, B, , , , , , , |
| 2: Calculate optimal according to Lemma 1, |
| 3: Calculate optimal and according to Theorem 1, |
| 4: Calculate the minimal energy requirement (i.e., ) by substituting , , and into the |
| objective function of Problem , |
| 5: Calculate optimal according to Theorem 2 by using the bisection method, |
| 6: Calculate optimal , , and based on according to Theorem 1, |
| 7: Calculate the minimal energy requirement (i.e., ) by substituting , , , and
|
| into the objective function of Problem , |
| 8: Compare with
|
| If , then trigger the local computing mode, |
| Otherwise, trigger the fog computing mode. |