# Solving the Manufacturing Cell Design Problem through an Autonomous Water Cycle Algorithm
## 4 The Water Cycle Inspired Solving-Method
The way in which a stream modify its trajectory is depicted in Figure 3, where \(X\) is the new position of the stream as a random displacement in the interval \([0,\alpha\cdot d]\), \(d\) is the distance between the river and the stream (usually in terms of fitness value), and \(\alpha\in(1,2)\). Figure 1: Hydrological water cycle. According to the attraction capacity of water flows, the algorithm applies three phases to transform a solution during one iteration of the optimization process. First, it moves streams forward to the rivers as given by  
\[X_{stream}(t+1)=X_{stream}(t)+rand\cdot\alpha\cdot(X_{view}(t)-X_{stream}(t)). \tag{11}\]  
where rand is a random number in the interval \([0,1]\). Second, streams are directed to the sea as given by  
\[X_{stream}(t+1)=X_{stream}(t)+rand\cdot\alpha\cdot(X_{sea}(t)-X_{stream}(t)). \tag{12}\]  
Third, rivers flow towards the sea as given by  
\[X_{river}(t+1)=X_{river}(t)+rand\cdot\alpha\cdot(X_{sea}(t)-X_{river}(t)). \tag{13}\]  
Next, the algorithm evaluates if the newly generated solution is better than its connection, i.e., if the stream provides a better fitness value than the river. In such a case, roles are exchanges as depicted in Figure 4.  
\[N_{sr}=N_{rivers}+1, \tag{8}\]0 Exchange of roles between a stream and its river. \[N_{sr}=N_{rivers}+1, \tag{8}\]1 Flow from a stream to its connecting river. \[N_{sr}=N_{rivers}+1, \tag{8}\]2 Transformation process. The algorithm also includes a mechanism to avoid premature convergence based on the evaluation of the evaporation condition. This process evaluates how close are rivers and streams to the sea so that evaporation is produced. Thus, the evaporation condition for rivers is evaluated as  
\[N_{sr}=N_{rivers}+1, \tag{8}\]3  
and for streams is evaluated as  
\[N_{sr}=N_{rivers}+1, \tag{8}\]4  
where \(d_{max}\) is updated over iterations as given by  
\[N_{sr}=N_{rivers}+1, \tag{8}\]5  
Note that the \(d_{max}\) is reduced over iterations, meaning that the evaporation condition is more complicated to meet so as execution progresses. If the evaporation condition is met, a rain process occurs, meaning that the water cycle starts again and then, a new population is generated replacing the previous one. That is,  
\[N_{sr}=N_{rivers}+1, \tag{8}\]6  
where \(LB\) and \(UB\) represent the lower and upper bound values, respectively. Based on the above description, the main steps in the algorithm are described in Algorithm 1. ```
1\(\{M,P,C,M_{max}\}\leftarrow\) loadProblemData();
2 Choice of parameters \(N_{pop}\), \(N_{rivers}\), \(d_{max}\). ;
3 Generate initial population. ;
4 Calculate \(N_{sr}\) y \(N_{stream}\). Equations (8) and (9). ;
5 Calculate the fitness value for each raindrop. Equation (4). ;
6 Determine flow intensity for the sea and rivers. Equation (10). ; // Produce \(T\)-generations. 7 while\(t<T\)do
8 Streams flow to rivers. Equation (11). ;
9 Streams flow to sea. Equation (12). ;
10 Rivers flow to sea. Equation (13). ;
11 ifThe stream is better than its connection to the riverthen
12 Exchange of position between stream and river. ;
13 ifThe stream is better than its connection to the seathen
14 Exchange of position between stream and sea. ;
15 ifThe river is better than its connection to the seathen
16 Exchange of position between river and sea. ;
17 ifEvaporation process. Equations (14) and (15)then
18 Rain process. ;
19 New Raindrops. Equation (17). ;
20 Reduce \(d_{max}\) according to Equation (16). ;
```  
**Algorithm 1**Water cycle inspired algorithm.