# Solving the Manufacturing Cell Design Problem through an Autonomous Water Cycle Algorithm
## 5 The Proposed Autonomous Water Cycle Algorithm  
The integration of autonomous search into the water cycle algorithm will be responsible for varying the population size (\(N_{pop}\)), while maintaining the same proportion of rivers/sea (\(N_{sr}\)and streams (\(N_{streams}\)). This proportion was experimentally defined as 30% for \(N_{sr}\) and 70% for \(N_{streams}\). The calculation of \(N_{pop}\) is inspired by one of the most important expressions in the water cycle algorithm, Equation (10), defining the trade-off between exploitation and exploration in the metaheuristic. Thus, the population size is calculated according to the relationship between the worst and best solution in the current population. That is:  
\[N_{pop}=round\Bigg{\{}\Bigg{|}\frac{c_{best}^{N_{pop}}-c_{wrong}^{N_{pop}}}{ \sum_{i=1}^{N_{pop}}cost_{i}}\Bigg{|}\times 100\Bigg{\}}, \tag{18}\]  
where \(c_{best}^{N_{pop}}\) and \(c_{worst}^{N_{pop}}\) are the best and worst fitness value in the current population. In this expression, population size will be larger as the difference between the best and the worst fitness value is increased. Otherwise, population size will be smaller.  
The criterion for updating the population size is defined according to the differences observed, in percentage, between the best and worst solution in \(N_{sr}\) in two different time intervals. Thus, let \(diff_{N_{sr}}^{\mathrm{f1}}\) and \(diff_{N_{sr}}^{\mathrm{f2}}\) the differences observed between the best and worst solution in \(N_{sr}\) in time \(t1\) and \(t2\), \(t1<t2\), respectively. Then, if \(diff_{N_{sr}}^{\mathrm{f2}}-diff_{N_{sr}}^{\mathrm{f1}}<0\), it means that the algorithm could be trapped in a local minimum and then, the population size should be increased in a number of elements as given by Equation (18). Otherwise, if \(diff_{N_{sr}}^{\mathrm{f2}}-diff_{N_{sr}}^{\mathrm{f1}}>diff_{th}\), it means that the differences observed could be very large and then, the algorithm should focus the search on the most promising areas, so reducing the population size in terms of Equation (18). Note that \(diff_{th}\) was experimentally defined as 3.00%. The previously discussed hybridization of autonomous search and the water cycle algorithm can be find in Algorithm 2.  
```
1 Calculate initial population size. Equation (18).;
2 Define t1 and t2.;
3 while\(t<T\)do
4 Execute one iteration of the water cycle algorithm (lines 8-24 in Algorithm 1).;
5 if\(t=t2\)then
6 if\(diff_{N_{sr}}^{\mathrm{f2}}-diff_{N_{sr}}^{\mathrm{f1}}<0\)then
7 Increase population in terms of Equation (18).;
8 else
9 if\(diff_{N_{sr}}^{\mathrm{f2}}-diff_{N_{sr}}^{\mathrm{f1}}>diff_{th}\)then
10 Decrease population in terms of Equation (18).;
11
12 Define t1 and t2.;
13
```  
**Algorithm 2**Hybridization of autonomous search and the water cycle algorithm.  
When proposing a hybrid approach is also important to analyze the time complexity of the proposal in comparison to the default approach. If we focus on the default water cycle algorithm, the time complexity has a linear relationship between the maximum number of iterations (\(T\)) and the population size. Hence, the time complexity of the algorithm is bounded by \(O(k\cdot n)\), where \(k\) is related to the number of iterations and \(n\) with the population size. Analyzing the hybrid approach, we also reach that time complexity is also bounded by a linear relationship between the number of iterations, which remains constant in both approaches, and the population size, which varies over the execution of the algorithm. Hence, theoretical complexity is not increased. As expected, execution time could differ for both approaches because of the size of the population, as occurs for two runs of the default algorithm with two different values for the population parameter. If we focus on the memory footprint, we reach that it depends on the size of the population. Hence, the usage of the main memory will be similar for both approaches, while considering the same population size.