# Prediction of Grain Porosity Based on WOA-BPNN and Grain Compression Experiment
## 4 Modeling Prediction of Grain Porosity
### Whale Optimization Algorithm  
The whale optimization algorithm (WOA) is a novel meta-heuristic algorithm introduced by [PERSON] and [PERSON] in 2016. It draws inspiration from the hunting behavior of humpback whales [40]. Humpback whales feed by spitting bubbles underneath the fish to create a bubble net, trapping the target fish inside before feeding on them. The predation process of humpback whales is divided into three main stages: encircling the prey, bubble attack, and feeding on the prey. (1) Encircling Prey  
Humpback whales can recognize the location of their prey and surround them. The humpback whale group does not know the exact position of the fish in advance, and their communication enables them to share information about the fish's location. The WOA initially assumes that the humpback whale closest to the prey is the best candidate (i.e., the  
Figure 4: Topology diagram of the BPNN. current optimal solution). The other humpback whales then calculate the distance between their current position and the current optimal solution, and move toward the optimal solution position. This behavior is represented by the following mathematical model [40]:  
\[D=|C\cdot X^{*}(t)-X(t)| \tag{8}\]  
\[X(t+1)=X^{*}(t)-A\cdot D \tag{9}\]  
where \(t\) is the number of iterations; \(A\) and \(C\) are coefficient vectors; \(D\) is the distance between the humpback whale and its prey; \(X^{*}\) is the position vector of the optimal solution in the current humpback whale population; and \(X\) is the position vectors of humpback whales other than the optimal solution. The formulas for \(A\) and \(C\) in Equations (8) and (9) are as follows:  
\[A=2a\cdot r-a,\ a=2-\frac{2t}{T_{\max}} \tag{10}\]  
\[C=2\cdot r \tag{11}\]  
where \(a\) is the convergence factor, which decreases linearly from 2 to 0 during the iteration; \(r\) is a random vector in the range of \([0,1]\); and \(T_{\max}\) is the maximum number of iterations. Attacking by Bubble Net  
After encircling the prey, humpback whales spit bubbles toward the school, creating a bubble net to trap the fish. Humpback whales use a narrowing encirclement or spiral updating of their position to trap food inside a bubble net, optimizing their foraging strategy in the solution space. There are two approaches to the mathematical modeling of humpback whale bubble net attacks:  
Method 1: Shrinking encircling mechanism. This behavior is achieved by decreasing the value of \(a\) in Equation (10). When \(\mid A\mid<1\), individual humpback whales are approaching the humpback whale in the current best position. Under the condition \(\mid A\mid<1\), humpback whales use larger spanning intervals to swim and search for fish when \(\mid A\mid\) is larger, enabling the WOA to achieve global optimization. Conversely, when \(\mid A\mid\) is smaller, humpback whales use smaller spacing to swim, enhancing the WOA's capacity for local optimization. Method 2: Spiral updating position. First, calculate the distance between the humpback whale and its prey, and then create a spiral equation that represents the relationship between the whale and its prey. This approach can significantly enhance the local optimization capability of the WOA, albeit at the expense of reduced optimization efficiency. The mathematical model that simulates the humpback whale's spiral update position method is:  
\[X(t+1)=D^{\prime}\cdot e^{ht}\cdot\cos(2\pi l)+X^{*}(t) \tag{12}\]  
where \(D^{\prime}=\mid X^{*}(t)-X(t)\mid\) is the distance from the whale to the prey, \(b\) is a constant that defines the shape of the logarithmic spiral, and \(l\) is a random number within the range of \(-1\) to \(1\). Humpback whales swim in a shrinking, encircling circle around their prey while following a spiral path. To simulate this simultaneous behavior, it is assumed that the whale's position is updated during the optimization process by selecting the shrinking encircling mechanism with a 50% probability and swimming along the spiral path with a 50% probability. The mathematical model is as follows. \[X(t+1)=