# A Discrete Prey-Predator Algorithm for Cloud Task Scheduling
## 3 The Proposed Discrete Prey-Predator Algorithm for Cloud Task Scheduling
### Pseudo-Code for the Proposed Discrete Prey-Predator Algorithm for Cloud Task Scheduling  
The following is the pseudo-code of the proposed Discrete Prey-Predator Algorithm 1 for cloud task scheduling:```
1:Initialize:
2:\(X_{0}=[x_{1},x_{2},x_{3},\ldots,x_{m}]\)
3:\(r=iterations\_max\)
4:Set the initial value of \(r=1\)
5:For each resource, do:
6: Define the speed for each cloud resource in \(M=[s_{1},s_{2},s_{3},\ldots,s_{m}]\)
7:End for
8:For each cloud task, do:
9: Define the length of each task in \(N=[t_{1},t_{2},t_{3},\ldots,t_{m}]\)
10:End for
11:While (\(t<=iterations\_max\)):
12: Determine the survival value for each schedule \(SV(x_{i})\)
13:For each \(SV(s_{i})\)do:
14: Determine the direction \(y_{i}\) using the equation:
15:\(y_{i}=\sum_{j=1}^{P}e^{(SV(x_{i}))^{r}-r_{i}(x_{j}-x_{i})}\)
16:End for
17:For each Task schedule surviving value \(i\)do:
18: Determine the movement of the prey schedule using the equation [21]:
19:\(xschedule_{i}=xschedule_{i+1}+Lmax(\in 2\left(\frac{y_{i}}{||y_{i}||}\right)+ \in 3\left(\frac{y_{i}}{||y_{i}||}\right))\)
20:End for
21:For each Task schedule surviving value \(i\)do:
22: Determine the distance between the positions of prey & predator schedules using the equation:
23:\(d_{1}=||Scheule_{predator}-(x_{i}+y_{r})||\)
24:\(d_{2}=||Scheule_{predator}-(x_{i}-y_{r})||\)
25:End for
26:For each Task schedule surviving value \(i\)do:
27: Determine the best prey schedule using the equation:
28:\(x_{best\_prey}=x_{i}+\lambda_{min(e_{i})(\frac{y_{i}}{||y_{i}||})}\)
29:End for
30:\(t=t+1\)
31:End while
```

**Algorithm 1** Discrete Prey-Predator Algorithm for Cloud Task Scheduling

### The Proposed Discrete Prey-Predator Method for Cloud Task Scheduling in Detail

This section describes the steps, mapping, and equations for the proposed Discrete Prey-Predator method for cloud task scheduling. Suppose that

\[N=[t_{1},t_{2},t_{3},\ldots,t_{m}] \tag{1}\]

is a set of \(n\) cloud tasks and

\[M=[s_{1},s_{2},s_{3},\ldots,s_{m}] \tag{2}\]

is a set of \(m\) cloud resource providers. Suppose that we have \(12\) tasks \([t_{1},t_{2},t_{3},\ldots,t_{12}]\) with task lengths as stated respectively in Equation (3):

\[Tasks\_Lengths=[12,6,4,2,10,2,2,24,8,14,16,4] \tag{3}\]

Suppose that we have \(6\) resources \([s_{1},s_{2},s_{3},s_{4},s_{5},s_{6}]\) with resource speeds as stated respectively in Equation (4):

\[Resource\_Speeds=[9,5,8,4,6,7] \tag{4}\]

The proposed Discrete Prey-Predator algorithm for cloud task scheduling starts the optimization process by initializing of the first random population, \(X_{0}=[x_{1},x_{2},x_{3},\ldots,x_{m}]\)where each \(\mathrm{x}_{1}\) represents a surviving solution. A solution in the population is a cloud task schedule that maps clients' tasks to cloud resource providers. In the mapping process, the dimension index represents the client task index (\(\mathrm{t}_{\mathrm{i}}\)) and the resource \(\mathrm{id}\) (\(\mathrm{s}_{\mathrm{i}}\)). We start with an intimal population with six random surviving solutions as stated in Equation (5):

\[\left( \begin{array}{c}\mathrm{x}_{1}\\ \mathrm{x}_{2}\\ \mathrm{x}_{3}\\ \mathrm{x}_{4}\\ \mathrm{x}_{5}\\ \mathrm{x}_{6}\end{array} \right)=\left(