# Efficient Dynamic Deployment of Simulation Tasks in Collaborative Cloud and Edge Environments
## 3 Problem Statements
### Problem Modeling
With the assumption that user \(i\) is located in region \(r\) at time \(\tau\), we use binary variables \(z_{h\!r}^{\tau}\), \(x_{hc}^{\tau}\) and \(y_{he}^{\tau}\) to indicate whether task \(i\) is assigned to host \(h\), whether host \(h\) belongs to data center \(c\) and whether host \(h\) belongs to edge node \(e\), respectively. The variables are set at \(1\) for true, and \(0\) otherwise. Suppose the centralized management node of a distributed simulation is located in data center \(o\). Since the values of \(x_{hc}^{\tau}\) and \(y_{he}^{\tau}\) are known before, the overall communication cost of all tasks at time \(\tau\) can be described by Equation (1), where \(s_{i}^{\tau}=\sum_{j\in\mathbb{T},j\
eq i}s_{ij}^{\tau}+\sum_{j\in\mathbb{T}, j\
eq i}s_{ji}^{\tau}\). In Equation (1), the first part represents the communication cost between tasks and users while the second part denotes the communication cost between tasks. \[ \begin{split}\text{comu\_cost}^{\tau}&=\sum_{i\in \mathbb{T}}(d_{i}^{\tau}\cdot(\sum_{h\in\mathbb{H}}\sum_{c\in\mathbb{C}}z_{ ih}^{\tau}\cdot x_{hc}^{\tau}\cdot\alpha_{rc}+\sum_{h\in\mathbb{H}}\sum_{c\in \mathbb{E}}z_{ih}^{\tau}\cdot y_{he}^{\tau}\cdot\beta_{rc})\\ &+s_{i}^{\tau}\cdot(\sum_{h\in\mathbb{H}}\sum_{c\in\mathbb{C}}z_{ ih}^{\tau}\cdot x_{hc}^{\tau}\cdot\lambda_{co}+\sum_{h\in\mathbb{H}}\sum_{c\in \mathbb{E}}z_{ih}^{\tau}\cdot y_{he}^{\tau}\cdot\gamma_{co}))\end{split}  \tag{1}\]  
When the status of tasks and hosts changes at time \(\tau+1\), some tasks may need to be rescheduled. To migrate a task dynamically, a new container or VM needs to be firstly initialized on the target host. Time consumed in this process is proportional to the size of image [35] and the coefficient is denoted as \(\omega 1\). After that, data about this task should be transferred and the status data should also be restored to memory and cache. \(\omega 2\) is used to represent the cost for transferring unit data between hosts. Intuitively, the longer a task is running in a host, the more resources are wasted when migrating this task. This part of migration cost for task \(i\) is embodied by \(\rho_{i}^{\tau}\) and the corresponding coefficient is denoted as \(\omega 3\). Binary variable \(v_{i}^{\tau}\) is used to indicate whether task \(i\) is migrated to other hosts at time \(\tau\), \(1\) for true and \(0\) otherwise. Thus, the overall migration cost of all tasks at time \(\tau\) can be expressed as Equation (2). \[\text{migra\_cost}^{\tau}=\sum_{i\in\mathbb{T}}v_{i}^{\tau}\cdot(\omega 1 \cdot\zeta_{i}^{\tau}+\omega 2\cdot l_{i}^{\tau}+\omega 3\cdot\rho_{i}^{\tau}) \tag{2}\]It should be noted that the total resource requirements of tasks must not exceed the capacity of the corresponding host. Thus, the scheduling goal and the constraints of this optimization problem can be denoted as Equations (3)-(6). \[\text{Minimize}\quad g^{\tau}=\text{comu\_cost}^{\tau}+\text{migra\_cost}^{\tau} \quad\text{subjected to} \tag{3}\]  
\[\sum_{i\in\mathbb{T}}z_{ih}^{\tau}\cdot\pi_{i}^{\tau}\leq\Pi_{h},\ \forall\,h\in\mathbb{H} \tag{4}\]  
\[\sum_{h\in\mathbb{H}}z_{ih}^{\tau}=1,\ \forall\,i\in\mathbb{T} \tag{5}\]  
\[z_{ih}^{\tau}\in\{0,1\} \tag{6}\]