# Using an Artificial _Physarum polycephalum_ Colony for Threshold Image Segmentation
## 4 Algorithm Steps of APPCA
### Step 2: Expansion  
The expansion is an important step of an artificial _Physarum polycephalum_ colony algorithm to search for feasible solutions before an optimal segmented image is output. In expansion, the most important thing is that the population size increases. The expanded population size includes three parts, i.e., the self-learning hyphae, the social-learning hyphae, and the free-learning hyphae. First, the original hyphae vary between the first iteration (\(Ite=1\)) and subsequent iterations (\(Ite>1\)). In the first iteration (\(Ite=1\)), the original population is the randomly generated hyphae with a population size \(S\) in the initialization stage, that is \(Ite=1\), a random segmented image \(\left[x_{i}^{k}\right]_{S}\), where \(x^{k}=\left\{x_{i}^{k}\right|i=1,2,3,\ldots,HV\right\}\). Since they are randomly distributed in the whole solution space, their fitness may vary greatly and the optimal solution cannot be determined. However, in the subsequent iterations (\(Ite>1\)), the original population is the hyphae with a population size \(S\) generated through contraction operations in the previous iteration calculation (\(Ite-1\)). Different from the random hyphae population generated in the first iteration, the hyphae in the subsequent iterations are the optimal solution with the highest fitness in the previous iteration, that is, the optimal segmented images \(x^{*}(Ite-1)\) of APPC. \[\left\{ \begin{aligned} x_{self}^{k}(Ite)=x^{k}(1)=random(k),if\;Ite=1 \\ x_{self}^{k}(Ite)=x^{*}(Ite-1),if\;Ite>1\end{aligned} \right. \tag{15}\]  
In expansion, multiple _Physarum polycephalum_ will collaboratively search for the optimal solutions to identify a set of neighbor pixels. When multiple _Physarum polycephalum_ hyphae move through several pixels, each _Physarum polycephalum_ hyphae will first identify the rest pixels, which are closer to it. In each iterative computing, the segmented image will change with time-varying. There are two expansions in this stage: the one with those solutions with high fitness in Equation (5) will cross for social learning and produce a new generation of solutions; the other is that the _Physarum polycephalum_ will randomly search for the feasible solutions in the whole solution space. Second, the social-learning hyphae allow different hyphae to learn environmental knowledge from each other and generate a new generation of hyphae with a population size \(S\). This simulates the social-learning behavior of natural _Physarum polycephalum_ colony and helps to search in the solution space near the optimal solution in each iteration, improving search efficiency and convergence speed. The social learning of an artificial _Physarum polycephalum_ colony employs the strategy of division and cooperation and provides the algorithm with good swarm learning and searching capabilities. For a pair of parent-segmented images \(x^{k}(Ite-1)\) and \(x^{l}(Ite-1)\), a pair of children-segmented images \(x_{social}^{k}(Ite)\) and \(x_{social}^{l}(Ite)\) can be obtained. \[\left\{ \begin{aligned} x_{social}^{k}(Ite)&=x^{k}(Ite -1)\times p_{s}+x^{l}(Ite-1)\times(1-p_{s})\\ x_{social}^{l}(Ite)&=x^{k}(Ite-1)\times(1-p_{s})+x^{ l}(Ite-1)\times p_{s}\end{aligned} \right. \tag{16}\]  
Due to the completely random nature of social learning, each hyphae has at least one opportunity to learn from any other hyphae, resulting in a new hyphae that is different from themselves. A new generation of hyphae includes two parts, where the one is the same part of the parent by a social-learning probability \(p_{s}\), while the other part different from the parent comes from other hyphae with a probability of \(1-p_{s}\). The larger the \(p_{s}\), the more experience is retained for self-learning, the stronger the local search ability, and the faster the convergence speed; on the contrary, the smaller the \(p_{s}\), the more social-learning experience it has, and the stronger its global search ability, but the slower its convergence speed. In Equation (16), only one child is randomly selected for the next iteration.