## 4 Network Implementation and Learning Algorithm
### Hybrid DELM Model
1.3 Initialize the target network parameters (power consumption, packet delay, packet loss). 2. Data Preprocessing and Feature Extraction
2.1 Drop unwanted columns from the dataset. 2.2 Data filtering based on specific conditions (deleting rows with zero values in key parameters). 2.3 Filling missing values in related columns. 2.4 Divide the dataset into two sets: training and testing. 2.5 Extract relevant features (SF, TP, BW, CR, etc.). 2.6 Define target variables for optimization (power consumption, packet delay, packet loss). 3. Model Architecture
3.1 Explain input layer features. 3.2 Set two models for the hybrid approach:

\(\bullet\) Random forest model for the baseline point of prediction. \(\bullet\) DELM model for achieving enhanced prediction. 3.3 Set up the random forest model with optimal hyperparameters (100 trees). 3.4 Initialize the DELM model with two hidden layers:

\(\bullet\) Add the first hidden layer: 16 neurons;

\(\bullet\) Add the second hidden layer: 8 neurons (main enhancement layer);

\(\bullet\) Add an output layer with 1 neuron (predicted enhancement). 4. Hybrid DELM Model Training
4.1 Train the random forest model on the training data. 4.2 Apply bootstrapping on the training data. 4.2.2 Build decision trees based on the split features. 4.2.3 Aggregate predictions depending on individual trees (bagging). 4.3 Generate baseline predictions for power consumption, packet delay, and packet loss. 4.4 Assess the baseline performance using cross-validation. 4.5 Initialize weights and biases randomly in the DELM model. 4.6 For each cross-validation fold:

4.6.1 Train the DELM model on the training dataset. 4.6.2 Apply forward propagation on the input data to calculate predictions. 4.6.3 Validate the model with the testing set for each fold. 4.7 Combine the predictions from the random forest and DELM using an ensemble approach. 4.8 Average the outputs of both models by applying weighted averaging based on the validation results. 4.8 Select the combination of parameters (SF, TP, BW, CR) with the lowest MSE as the optimized parameters for the best prediction. 5. Model Validation

5.1 Evaluate model performance using the mean squared error. 5.2 Compare the predicted and target values to calculate the enhancement ratio. 6. OMNeT++ simulation integration

6.1 Connect the OMNeT++ simulation with the hybrid DELM model. 6.2 For each data packet in real time:

6.2.1 Extract features. 6.2.2 The hybrid model predicts the output depending on the optimized parameters. 6.2.3 Update the network with the optimized parameters (SF, TP, BW, CR). 7. Output

7.1 Display the enhanced network parameters. 7.2 Save results for analysis. ## 5 Results and Discussion

In this section, we will discuss the output performance results of the wireless LoRa network for the oil pipeline leak detection and localization system in different scenarios. Although the proposed RTTM-based LoRaWAN monitoring system achieved the desired objective with the default configuration of the LoRa network in terms of detecting the leak quantity and location, in addition to providing real-time monitoring of oil pipeline status, such as the pressure, flow rate, and temperature in an accurate manner, we were motivated to maintain the system's efficiency over time so that it could work with the same efficiency by enhancing the node energy consumption and prolonging the battery life by utilizing the artificial intelligence techniques. The implementation of machine learning techniques presents a great solution that utilizes the strength of prediction, hyperparameter tuning, and optimization to enhance the output of the LoRa network with the best combination of network parameters, such as the spreading factors, transmission power, bandwidth, and coding rate. Firstly, the default LoRa network was run, according to our proposed design, with 100 LoRa nodes within the OMNeT++ simulation. The results were tested and analyzed to calculate the total network output performance with network parameters of SF = 12, TP = 14, BW = 125 kHz, and CR = 4.