# Behavior Composition for Marine Pollution Source Localization Using a Mobile Sensor Network
## 2 Combining Upwind Sprint and GA for CPSL
### Adapting GA for CPSL
#### 2.2.2 Elementary Behaviors  
Aiming at the above-mentioned circumstance of the MSN, elementary behaviors are designed for individual SNs. Different SNs can simultaneously perform different elementary behaviors. 1. D-behavior: The SN moves away from the centroid of the MSN with the perspective of exploring the uncovered space. In the D-behavior, the goal position of the \(i\)-th SN with coordinates \(\{x_{gi},y_{gi}\}\) is \[ \begin{cases}x_{gi}=x_{c}+10^{4}*\cos(\frac{\pi i}{n})\\ y_{gi}=x_{c}+10^{4}*\sin(\frac{\pi i}{n})\end{cases} ,i=1,2,\ldots,n,\] (6) where \(x_{c}\) and \(y_{c}\) are the \(x\)- and \(y\)-coordinates of the MSN centroid, respectively, and \(n\) is the number of SNs in the MSN. The goal positions in Equation (6) can guide the SNs to move along radial directions with equal angle-spans. 2. U-behavior: The SN moves in the opposite direction to that of the detected fluid-flow to search in the upwind area. The upwind movement direction angle can be denoted as \(\theta_{i}=\pi+\beta_{i}\), where \(\beta_{i}\) is the flow direction angle detected by the \(i\)-th SN. 3. C-behavior: The SN moves toward the new candidate chromosome generated by the \(GA\) to evaluate it. Once the C-behavior is performed, a new chromosome is generated by conducting crossover operation on the GA population. As underlined in Algorithm 2, the GA-correlated operations in uGA include initialization, population update, candidate chromosome generation and evaluation, and the termination criterion. 1. Initialization (line 8 in Algorithm 2). When the MSN encounters the first contact with the chemical plume, \(m\) new chromosomes are randomly initialized in the neighborhood of the position of the first contact. The concentration measured at the first contact is substituted into Equation (7) to calculate the objective value of the initial chromosomes. \[y=\frac{1}{z} \tag{7}\]  
in which \(y\) and \(z\) are the objective value and detected concentration, respectively. 2. Population update (line 10 in Algorithm 2). If the SNs detect a new above-threshold concentration in the upwind area of the population centroid, the detection position is encoded to a new chromosome and then inserted into the population. To maintain a fixed population size, which is denoted as \(m\), the oldest chromosome in the population is discarded after the new chromosome is inserted. In other words, the oldest chromosome is replaced by the newest chromosome and the population is updated in a first-in-first-out manner. 3. Candidate chromosome generation (line 15 in Algorithm 2). Once C-behavior is activated, only one candidate chromosome is generated by a crossover between the two selected chromosomes. The predefined parameters \(p_{c}\) of GAis not used in uGA. To select chromosomes for the subsequent crossover operator, fitness-based roulette wheel selection is conducted based on the fitness function in Equation (1). The fitness value is calculated by substituting the result of Equation (7) into Equation (1), which was originally used for function minimization. Thus, the chromosome correlated with high concentration measurements is more likely to be selected in the roulette wheel selection. As illustrated in Figure 3, an additional condition is set up to filter the new chromosome. The additional condition is that newly generated chromosomes must be located in the upwind search area of the MSN centroid. If the condition is not satisfied, the selection and crossover processes should be repeated. The improved crossover is called upwind-customized crossover. For example, since position B lies in the subarea on the downwind side of the MSN centroid, the generated chromosome at B should be discarded. If the newly generated candidate chromosome falls inside the subarea on the upwind side of the sensor node centroid, such as position A, it will be retained as the new candidate chromosome for further evaluation. After the upwind-customized crossover operation, the mutation operation is conducted on the new chromosome.