## 3 Materials and Methods
### Proposed Approach
#### 3.1.5 Fuzzy Controller  
Algorithm 2 describes the operation of the fuzzy controller that was used in Algorithm 1 to generate the task-to-VM assignment mapping. The fuzzy controller proposed in the present work uses Mamdani fuzzy inference and three fuzzy inputs to make a decision regarding the VM that should execute a given task. The input consists of the crisp-valued inputs for task length and task priority. In line 1, the singleton VM set is created. More VMs are later added to it based on the outputs of the fuzzy controller. The outer for loop iterating over the set of tasks runs from lines 3 to 20. For each task, the approach then iterates over the available VMs in the inner loop and checks the feasibility of assigning the task to each VM. The task is assigned to the first VM that is considered feasible by the fuzzy controller. The fuzzy controller takes as input the fuzzy values for task length, total task length assigned to the current VM, and number of high-priority tasks on the current VM. A fourth input for priority of the current task is used without fuzzification. Its role is to refer to relevant parts of the rule base, since the rule base has two sets of rules: one for each priority type. The applicable rules from the rule base are determined next in line 8. The crisp output is obtained next using strong rules selected using \(T_{r}\), the threshold of fuzzy controller. If the crisp output value is below 50, then the controller assigns the task to the current VM and continues to the next task. If the output is more than 50, then the task cannot be assigned to the current VM. At this point, if it is found that there are no more VMs in \(V\), the controller adds one more VM to it and checks the feasibility of the task on the next VM. When the outer loop has finished iterating, the VM assignment mapping contains information about the number of VMs that will be needed and the tasks that will be assigned to each VM. ```
0:\(T_{l}\), \(T_{p}\) Output: VmAssignmentMapping
1:\(V=(v_{1})\) // VM set, initially singleton
2:\(VmAssignmentMapping=(\phi)\) // VM to Task mapping, initially empty
3:for every task \(t_{i}\) in task set do
4:for every \(v_{j}\) in V do
5: Calculate \(\mu(t_{i})\) // fuzzy value for task length input
6: Calculate \(\mu(LoadOfv_{j})\) // fuzzy value for load of current VM input
7: Calculate \(\mu(NoOfHighPriorityTasksOnv_{j})\) // fuzzy value for no of high priority tasks on VM input
8: Get applicable rules using \(\mu(t_{i_{i}})\), \(\mu(LoadOfv_{j})\), \(\mu(NoOfHighPriorityTasksOnv_{j})\), and \(t_{i_{p}}\)
9: Get strong rules using \(T_{r}\)
10: Defuzzify output to get crisp output value
11:if Output < 50 then
12: assign \(t_{i}\) to \(v_{j}\) in VmAssignmentMapping
13: continue to next task
14:else
15:if\(v_{j}\) last VM in V then
16: add one VM to V
17:endif
18:endif
19:endfor
20:endfor
21:return VmAssignmentMapping
```  
**Algorithm 2** Fuzzy Controller  
In Mamdani fuzzy reasoning, the fuzzy membership values for crisp inputs are used in the inference rules. The fuzzy input membership functions (MFs) used by the fuzzy controller in the proposed approach are detailed next. The crisp domains of the fuzzy setsused by the proposed fuzzy controller are defined for the target input datasets. In Figure 3a, the fuzzy MF for the task length is given. This MF has four linguistic variables: Small (SM), Medium (ME), Large (LA), and Very Large (VL). The second fuzzy input is for the total load assigned to a VM, and it is defined by the membership function given in Figure 3b. Here, the linguistic variables are Low Load (LO), Medium Load (ME), Heavy Load (HE), and Very Heavy Load (VH). The third fuzzy input is given in Figure 3c and represents the number of high-priority tasks on a VM. It has three variables: Low (LO), Medium (ME), and High (HI) numbers of high priority tasks. The output membership function has two variables: Current VM (CV) and Next VM (NV). The two variables correspond to the decision to map or not map a task to the current VM under consideration.