# Power Distribution IoT Tasks Online Scheduling Algorithm Based on Cloud-Edge Dependent Microservice
## 3 Task Scheduling Model for Distribution Stations under Cloud-Edge Collaboration
### Task Model  
A series of power tasks can be generated at any time in any order, and the set of power tasks is denoted as \(\mathrm{S=}\{\mathrm{s_{1},s_{2},s_{3},\ldots,s_{m},\ldots}\}\). The task is denoted as \(\mathrm{s_{m}}=\{\mathrm{at_{m},dt_{m},l_{m},G_{m}}\}\), where \(\mathrm{at_{m}}\) is the arrival time of the task, \(\mathrm{dt_{m}}\) is the deadline of the task, \(\mathrm{l_{m}}\) is task type, and \(0<\mathrm{l_{m}<1}\). Power tasks can be divided into general tasks, alarm tasks, and fault handling tasks [16]. General tasks include load forecasting, electric vehicle charging management, etc. Alarm tasks include the three-phase unbalance alarm, power theft alarm, etc. Fault handling tasks complete functions such as fault confirmation and fault location. The value ranges of the three types of tasks are shown in Section 4.1.2. \(\mathrm{G_{m}}\) denotes the structure of task \(\mathrm{s_{m}}\). The completion of a power task depends on several microservices, and multiple microservices with dependencies can be modeled by a Directed Acyclic Graph (DAG) [13], denoted as \(\mathrm{G_{m}}=\{\mathrm{V_{m},E_{m},W_{m}}\}\), where \(\mathrm{V_{m}}=\left\{\mathrm{v_{1}^{m},v_{2}^{m},\ldots,v_{k}^{m}}\right\}\) is a node of the graph representing the k microservices invoked by the task. \(\mathrm{E_{m}}\) is a set of directed edges that represent dependencies between microservices. For example, a directed edge \(\mathrm{e_{ij}^{m}}=\left(\mathrm{v_{i}^{m},v_{j}^{m}}\right)\in\mathrm{E_{m}}\) indicates that microservice \(\mathrm{v_{j}^{m}}\) depends on \(\mathrm{v_{i}^{m}}\). The set of such microservices as \(\mathrm{v_{i}^{m}}\) is called a predecessor microservice, and \(\mathrm{Pred}\left(\mathrm{v_{P}^{m}}\right)\) denotes the set of all predecessor microservices of \(\mathrm{v_{P}^{m}}\). The set of microservices such as \(\mathrm{v_{j}^{m}}\) is called the successor microservice, and \(\mathrm{Succ}\left(\mathrm{v_{P}^{m}}\right)\) denotes the set of all successor microservices of \(\mathrm{v_{P}^{m}}\). \(\mathrm{W_{m}}\) denotes the set consisting of the weights of each directed edge, where the weight refers to the amount of data transferred between two microservices. \(\mathrm{w_{ij}^{m}}\) denotes the amount of data transferred between \(\mathrm{v_{i}^{m}}\) and \(\mathrm{v_{j}^{m}}\). Microservices that do not contain any predecessor microservices are referred to as entry microservices and microservices that do not contain any successor microservices are referred to as exit microservices. A task often contains multiple entry microservices or exit microservices. During task processing, task data information from the terminal is uploaded to the edge device in the region, and when the task is processed at the co-processing edge device, the result data is sent back to the edge device in the region. In order to calculate the delay caused by the transmission of the input data of the task as well as the result data to the task scheduling, and considering that both the input data and the result data have to reach the edge device in the region, the virtual entry microservice and the virtual exit microservice that do not occupy any time and resources are added. The virtual entry microservice transmits the collected information to the receiving microservice, and the virtual exit microservice receives the result information of task completion. The set of microservices invoked by the task is denoted as \(\mathrm{V_{m}}=\{\mathrm{v_{0}^{m}},\mathrm{v_{1}^{m}},\mathrm{v_{2}^{m}}, \ldots,\mathrm{v_{k}^{m}},\)\(\mathrm{v_{k+1}^{m}}\}\), where the sum of the weights of the edges between the virtual entry microservice \(\mathrm{v_{0}^{m}}\) and each actual entry microservice represents the amount of input data for this power task, and the sum of the weights of the edges between each actual exit microservice and the virtual exit microservice \(\mathrm{v_{k+1}^{m}}\) represents the amount of output data.