# Plum Tree Algorithm and Weighted Aggregated Ensembles for Energy Efficiency Estimation
## 3 Plum Tree Algorithm
The \(p_{gbest}\) is updated if there exists a plum which has a better fitness value (Step 10), the current iteration \(iter\) is incremented by 1 (Step 11), and the algorithm returns the \(p_{gbest}\) value after all \(I\) iterations have been performed (Step 12). The pseudo-code of the PTA is presented below (see Algorithm 1). ```
1:Input \(I\), \(D\), \(N\), \(FT\), \(RT\), \(FR_{min}\), \(FR_{max}\), \(\epsilon\), \(OF\), \(X_{min}\), \(X_{max}\)
2:Output \(p_{gbest}\)
3: initialize \(N\) flowers in the \(D\)-dimensional space with values from \([X_{min},\ X_{max}]\)
4: initialize \(N\) plums to the positions of the \(N\) flowers
5: apply \(OF\) to compute the fitness of the plums and the flowers and update \(p_{gbest}\)
6:for\(iter=1\) to \(I\)do
7: compute the ripe position \(P_{ripe}\)
8: compute the uripe position \(P_{surpire}\)
9:for each flower do
10: update \(r\) to a random number from the range \([0,1]\)
11:if\(r\ \geq\ F\)then
12: update the flower using formula (3)
13:else if\(r\ \geq\ RT\)then
14: update the flower using formula (4)
15:else
16: update the flower using the formulas (5)-(6)
17:endif
18: adjust the flowers to be in the range \([X_{min},\ X_{max}]\)
19:endfor
20:for each plum do
21: update the plum using formula (7)
22:endfor
23: update the \(p_{gbest}\)
24:endfor
25:return\(p_{gbest}\)
```  
**Algorithm 1** PTA  
The input of the PTA is represented by the following parameters: \(I\)--the number of iterations, \(D\)--the number of dimensions, \(N\)--the number of plums, \(FT\)--the fruitiness threshold, \(RT\)--the ripeness threshold, \(FR_{min}\)--the minimum fruitiness rate, \(FR_{max}\)--the maximum fruitiness rate, \(\epsilon\)--a constant for avoiding division by zero, \(OF\)--the objective function, \(X_{min}\)--the minimum possible value of the position, and \(X_{max}\)--the maximum possible value of the position. The output of the PTA is \(p_{gbest}\), the global best plum position. \(N\) flowers are initialized in (line 3) in the \(D\)-dimensional search space with values from the range \([X_{min},X_{max}]\):  
\[flowers= \begin{bmatrix}F_{1,1}^{0}&\dots&F_{1,D}^{0}\\ \dots&\dots&\dots\\ F_{N,1}^{0}&\dots&F_{N,D}^{0}\end{bmatrix} , \tag{1}\]  
and \(N\) plums are initialized in (line 4) with the values of the flowers:  
\[plums= \begin{bmatrix}P_{1,1}^{0}&\dots&P_{1,D}^{0}\\ \dots&\dots&\dots\\ P_{N,1}^{0}&\dots&P_{N,D}^{0}\end{bmatrix} =flowers. \tag{2}\]  
The fitness values of the flowers and plums are computed in (line 5) using the \(OF\), and the value of the global best plum \(p_{gbest}\) is updated to the position of the plum which has the best fitness value. The instructions from the (lines 7-23) are performed \(I\) times, such that \(iter\) describes the value of the current iteration. The ripe position \(P_{ripe}\) is updated to the position of the plum with the best fitness value (line 7), whereas the unripe position \(P_{unripe}\) is updated to the position of the plum with the second-best fitness value (line 8). The positions of the flowers are given as \(F_{i}^{iter}\), where \(i=\overline{1,\ N}\) are updated in (lines 10-18) considering the value of a random number \(r\) within the range of \([0,\ 1]\) (line 10). If the value of \(r\) is greater than or equal to \(FT\) (line 11), then the position of the flower is updated using the following formula:  
\[F_{i}^{iter}=F_{i}^{iter-1}+random(FR_{min},FR_{max})\times\left(P_{i}^{iter- 1}-F_{i}^{iter-1}\right), \tag{3}\]  
such that \(random(FR_{min},FR_{max})\) returns uniformly a number from the range \([FR_{min},FR_{max}]\). If the value of \(r\) is less than \(FT\) and greater than or equal to \(RT\) (line 13), then the position of the flower is updated as follows:  
\[F_{i}^{iter}=F_{i}^{iter-1}+2\times r_{1}\times\left(P_{ripe}-F_{i}^{iter-1} \right)+2\times r_{2}\times\left(P_{unripe}-F_{i}^{iter-1}\right), \tag{4}\]  
where \(r_{1}\) and \(r_{2}\) are random numbers within the range of \([0,\ 1]\), and \(P_{ripe}\) and \(P_{unripe}\) are the ripe position and the unripe position, respectively.