## 3 System Model
### K-Medoids with an Adaptive Salifish Optimization (ASFO) Algorithm for CH Selection  
The sensor nodes are organized into clusters using the clustering technique, and a CH is chosen for each cluster in the wireless sensor network. The primary responsibility of the CH is to gather data from specific cluster nodes and send it to the BS. This research suggests a K-medoids algorithm for clustering in WSNs. The K-medoids algorithm splits all sensor nodes into k clusters. Each cluster is associated with a single object in the K-medoids method. The identified object is called a medoid and corresponds to the cluster's most central point. The K-medoids group is the shortest distance between clusters because the K-medoids related to the cluster node find the optimal center. It improves communication between sensor nodes, reduces energy consumption, and detects more accurate cluster centers, resulting in shorter packet delays. The K-medoids algorithm is efficient and has a fixed number of convergence steps [18]. The K-medoids clustering algorithm has the following steps:  
Step 1: Randomly select \(k\) points from the input data (where \(k\) represents the number of clusters to form). Step 2: Each data point is assigned to the cluster that contains the closest center point. Step 3: For each data point in cluster '\(i\)', calculate and add the distance from all other data points. Specify the point of the i cluster that reduces the total calculated distance from other points as the center point of the cluster. Step 4: Repeat steps 1 and 3 until convergence is reached, that is, until the center point stops moving. The clustering method involves grouping sensor nodes and selecting CHs for all groups in the WSN. The CH's primary function is to collect information from a specific node in the cluster and transmit it to the BS. Because of its ability to find exact central clusters, or centroids, cluster formation is accomplished using the K-medoids algorithm, resulting in low power consumption, low packet latency, and better sensor nodes. The process involves estimating the number of clusters and calculating the first CH node using Equation (5):  
\[c=\sqrt{\frac{n}{2}} \tag{5}\]where \(n\) denotes the number of nodes. These algorithms determine the initial mean point and center location (\(L\)) for all the nodes derived. \[L=\frac{\sum_{n=1}^{N}x_{n}}{n} \tag{6}\]  
where \(x_{n}\) represents the coordinate of the sensor. The average separation between the \(SN\) and \(L\) is represented as \(D\) in the following formula:  
\[D=\frac{\sum_{n=1}^{N}\lvert x_{n}-L\rvert}{n} \tag{7}\]  
The separation between the sensor nodes (\(SN\)) and center location (\(L\)) can be used to calculate the centroid, and clustering is obtained using Equation (7) until a proper CH is selected. The procedure for formation of clustering using K-medoids with a Salifish Optimizer is described in Algorithm 1. ```
Network Initialization Step 1: Initialization of the WSN Step 2: Locate BS at coordinates (50, 180) Step 3: Place all the SNs arbitrarily Formation of clusters using K-medoids and selection of CH using ASFO Step 4: Number of nodes \(N\) divided into several clusters Step 5: Every cluster has \(N\) nodes, and each node is related to its nearest CH Step 6: Randomly select the first CH by selecting the first random medoid from \(N\) in the cluster Step 7: Three-dimensional coordinates (x, y, z) are generated by every normal node to CH Step 8: K-means distance calculation is performed by the CH Step 9: ASFO algorithm is used to select the new CH and center the cluster node Step 10: Repeat step 7 to 9 until the node in the absolute center is found End
```  
**Algorithm 1**Algorithm for clustering using K-medoids with a Salifish Optimizer  
The specific coordinate values used in the algorithm, such as (50, 180), have significance beyond being randomly generated coordinates within the range of 0 to 200. As a result, the best solution was obtained by employing the ASFO algorithm process.