*3.2. Problem Formulation*

We have considered the following components for resource allocation in the residential buildings all over the world which are categorized as: set of regions, buildings, VMs, MGs and DCs. Let *VM* indicate the set of VMs and each of them processes the tasks *T*, so the sets of the *VM* and tasks *T* are mathematically represented by Equations (1) and (2):

$$VM = \{vm\_1, vm\_2, \dots, vm\_n\},\tag{1}$$

$$T = \{t\_1, t\_2, \dots, t\_n\}\_\prime \tag{2}$$

here, the set of the VMs (*vm*1, *vm*2, ..., *vmn*) and tasks (*t*1, *t*2, ..., *tn*) are between 1 to *n*. In this environment, all VMs are working in parallel with each other and have the same capacity. The tasks are executed in a non-preemptive fashion on each VM. Through hypervisor, every VM is monitored and it is assigned to certain tasks, if they are required to be processed. The total tasks assigned to each VM are dependent on the number of consumers' requests and their PT, RPH and RT. Each of the aforementioned parameters are formulated using the linear programming [29]. Equation (5) is computed for the PT using the Equations (3) and (4). Equation (3) represents the tasks and VMs assignment states.

$$\text{Tasg}\_{kl} = \begin{cases} \text{a;} & \text{for assigning the tasks,} \\ \text{b;} & \text{for assigning the VMs.} \end{cases} \tag{3}$$

where, "a" indicates the set of the VMs and "b" denotes the set of tasks. *Tasgkl* is used to indicate the assignment of VMs and tasks to each VM. The RPH is evaluated by Equation (4).

$$RPH\_{kl} = \begin{cases} \begin{array}{l} 1; \text{ } if \text{ task is assigned,} \\ 0; \text{ } if \text{ task is not assigned.} \end{array} \end{cases} \tag{4}$$

*RPHkl* indicates the number of VMs assigned to the tasks requested by each consumer in the C2F2C system. After finalizing the RPH and the tasks assignment to each VM in the system, its total PT (*PTtot*) can be computed by Equation (5);

$$P T\_{tot} = \Sigma\_{k=1}^{n} \Sigma\_{l=1}^{m} \left( P T\_{kl} \* R P H\_{kl} \right). \tag{5}$$

*PTkl* represents the PT of the VMs assigned to each task and *RPHkl* indicates the RPH of every VM dedicated to the assigned task. The RT is computed with the help of Equation (6) as given below:

$$RT\_k = \frac{\Sigma\_{kxVMs}(\text{CT}\_k)}{\text{maksespan} \* \text{Number of the VMs}}.\tag{6}$$

Here, *RTk* is used for denoting the total RT of the VMs in the proposed system and *CTk* is the completion time of the tasks. "Makesspan" is a term which describes the aggregated running time of the tasks. The cost of the system is computed via aggregating the VMs cost, MGs cost and data transfer cost. VM cost is computed on the basis of the Multiple Instructions Per Second (MIPS) and the request size, whereas the data transfer cost is computed by considering the total data and the assigned bandwidth to that data. In addition, MG cost is computed based on the number of the installed MGs. So, the total cost of the system is computed by Equation (7):

$$\text{Cost}\_{lat} = \text{Cost}\_{Datterum} + \text{Cost}\_{VM} + \text{Cost}\_{MG}.\tag{7}$$

Here, the variables: *Costtot*, *CostDatatrans*, *CostVM* and *CostMG* used for cost in Equation (7) represent the total cost, data transfer cost, VM cost and MG cost, respectively.
