# A Novel Hybrid Approach Based on BAT Algorithm with Artificial Neural Network to Forecast Iran’s Oil Consumption

Authors: Mojtaba Bahmani; Mehdi Nejati; Amin GhasemiNejad; Fateme Nazari Robati; Mehrdad Lashkary; Naeeme Amani Zarin
Journal: Mathematical Problems in Engineering
 (2021)

---

## Abstract

In this paper, we develop a function of population, GDP, import, and export by applying a hybrid bat algorithm (BAT) and artificial neural network (ANN). We apply these methods to forecast oil consumption in Iran. For this purpose, an improved artificial neural network (ANN) structure, which is optimized by the BAT is proposed. The variables between 1980 and 2017 were used, partly for installing and testing the method. This method would be helpful in forecasting oil consumption and would provide a level playing field for checking the energy policy authority impacts on the structure of the energy sector in an economy such as Iran with high economic interventionism by the government. The result of the model shows that the findings are in close agreement with the observed data, and the performance of the method was excellent. We demonstrate that its efficiency could be a helpful and reliable tool for monitoring oil consumption.


---

## Body

## 1. Introduction

The efficient application of energy is a factor which can considerably affect the sustainable development of countries. Energy is a foundation element of the modern industrial economy. Over the past few decades, energy has become a very critical element in industries and also a fundamental product and factor in the growth of the economy in different world regions. The ever-increasing dependence of human life on energy has made this factor play a critically crucial role either potentially or actively in the functions of various economic sectors of countries [1]. Given the vital applications of energy in different economic sectors and also the rise of the population over past years, energy has turned the center of attention as one of the most significant factors of production [2]. Oil, natural gas, electric power, solar, wood, animal, and plant waste could be recognized as Iran’s basic energy resource [3]. The oil industry is a fundamental factor in the economy of Iran and the government’s annual budget. It affects foreign trade, the national capital, and developments in nonpetroleum exports [4]. Therefore, recognizing the factors that affect the needed energy in a country is required in managing the energy supplement. Based on the reality that the energy demand procedure and factors that affect it go through vague and complicated patterns, determining efficient instruments for appropriate energy use is necessary. Due to the increasing demand for energy, the assessment of it is necessary. Different optimization techniques, e.g., birds, bats, and fireflies, are appropriate to forecast these models [1]. Different models are presented to determine the possible approach ever in modeling energy issues as a function of various indicators. Given the high dependency of the Iranian economy on oil incomes, acquiring data by employing precious and qualified methods in this field will result in more efficient planning. Hence, the studies in this field have a considerable degree of importance. We examine the relationship between oil consumption in Iran and diverse independent variables, based on socioeconomic factors, using the BANN (hybrid bat algorithm and artificial neural network) technique. Results arising from the present study provide important reference information for the utility companies in pursuing patterns of oil consumption and selecting a more accurate approach to estimate future oil demand.A few studies that propose several models for energy demand policy management with different techniques are introduced. Pourdaryaei et al. [5, 6] in two studies worked on short-run electricity price forecasting using hybrid algorithms. Using a hybrid method for electricity price forecasting via artificial neural network and artificial cooperative search algorithm and using the hybrid backtracking algorithm and the adaptive neuro-fuzzy inference system (ANFIS) approach have improved the accuracy and effectiveness. Kaboli and Alqallaf [7] conducted a study on solving the problem of sending nonconvex economic load via an artificial algorithm for cooperative research. Thus, they used a method that is to interfere and work with feasible solutions throughout the optimization. Hlal et al. [8] conducted an optimization study based on NSGA-II and MOPSO for sizing a hybrid PV/wind/battery energy storage system. Kıran et al. [9] applied artificial bee colony (ABC) and particle swarm optimization (PSO) techniques to forecast electricity energy demand in Turkey in two forms (linear and quadratic) by using selected socioeconomic and demographic variables that included gross domestic product (GDP), population, import, and export. Behrang et al. [4] presented GSA (gravitational search algorithm) oil demand estimation models to be used in the Iran context. In another study, Behrang et al. [10] predicted the total energy demand in Iran from 2006 to 2030, using the bees algorithm technique. Ceylan et al. [11] developed the harmony search (HS) technique to forecast Turkish transport energy demand in tree forms (linear, exponential, and quadratic) based on three factors including population, GDP, and vehicle kilometers. The energy consumption in Turkey is also determined by using the ant colony (ACO) by Toksari [12] with independent variables such as population, GDP, import, and export.According to what has been presented, using nonclassic methods for the identification and prediction of complex systems-related problems has been expanded [13]. Hence, in this study, a novel approach for oil consumption forecasting is presented. Heuristic methods are used for the better optimal solutions and to overcome the complexity of the nonlinearities [14]. The authors’ main goal, therefore, is to employ artificial methods, because of their accuracy, and present new methods, such as the proposed hybrid, in the field of oil and gas, to acquire more precise information and data.This paper is organized as follows. First, a brief introduction is presented. In the next section, we explain the specification of the BANN (hybrid bat algorithm and artificial neural network). Section3 presents optimization and method validation. In Section 4, the model estimations are done, and finally, in the last section, the conclusion is given.


## 2. Methods and Material

### 2.1. Bat Algorithm (BA)

The BAT algorithm was introduced by Yang [15]. This algorithm is an evolutionary algorithm inspired by the behavior of natural bats in locating their foods. It is used to solve various problems. BA starts with an initial population of bats. It employs a homologous manner by performing an echolocation method for updating its position [16]. Bats send a signal with the loudness of frequency 20 kHz to 500 kHz. This signal is deflected back after striking the object to bat as an echo signal. The echo signal is used to calculate the bat’s distance to any object which is the destination of the bat [17, 18]. Bats fly towards the object or prey, and they reduce their pulse rate when they reach the closer object. Bats continue to do so till the distance becomes zero [18, 19]. Also, they can distinguish between insects and obstacles to hunt prey based on the echo [20]. The BA is summarized in the following three main principal rules [15–21]:(1)
Each bat utilizes echolocation characteristics to estimate the distance and to distinguish between prey and obstacles.(2)
Each bat flies randomly with positionxi, velocity vi with constant frequency fmin, updated wavelength λ, and loudness L0 to seek for prey. It automatically changes the frequency of its pulse emission and regulates the rate of pulse release r in a range [0, 1] based on the proximity of its target.(3)
Frequency, loudness, and pulse released rate of each bat is varied. The loudness is adjusted from a large value (positive)L0 to a minimum constant valueLmin.In the simulations, each bat is associated with a velocityvit and a location xitwith iteration t, in a d-dimensional search or solution space. Therefore, the above three rules can be translated into the updating equations for xti and velocities vit:(1)fi=fmin+fmax−fminβ,vit=vit−1+xit−x∗fi,xit=xit−1+vit,where βε0,1 is a random vector outcome from a uniform distribution. x∗ is the best current universal position, achieved after comparing the locations of all then bats. The frequency f during a range fmin,fmax corresponds to a range of wavelengths λmin,λmax. Indeed, the frequency just varies while the wavelength f is constant, and it is assumed that f∈0,max in implementation [22].For the local search, a solution is selected among the best current solutions, and a new solution for each bat is produced using a random walk.(2)xnew=xold+εLt,where εε−1,1 is a random number while Lt is the average loudness of all bats. The loudness normally reduces when a bat finds its prey while the rate of the pulse emission increases. The loudness may be chosen as any value of convenience. It can be chosen as any value of convenience between Lmin and Lmax assuming Lmin=0 which means that a bat has just found the prey and provisionally stops emitting sound. It is shown in the following:(3)Lit+1=αLit,∀0≤α≤1,rit+1=ri01−e−γt,∀γ>0,where t is the iteration number during the optimization process. As time moves towards infinity, the loudnessLit tends to be zero; then,rit=ri0.


### 2.2. Artificial Neural Network (ANN)

Artificial neural network is a famous artificial intelligent method that simulates the work of the human mind mechanism. It is a method that handles information coming from different nodes in this model known as neurons. These nodes are embedded in different layers which will work together to solve a complicated problem [23].Artificial neural network is a mathematical approximation to the human nervous system that have been widely used to solve various nonlinear problems. The structure of ANN contains the elements of the input layer, hidden layer, and output layer. A network can contain multiple different hidden layers enabling the network to have computational and processing abilities. The number of layers is dependent on the problem complexity. In general, a neural network is a set of connected input and output units that each connection has an associated weight [13].An artificial neural network (ANN) contains the elements of the input layer, hidden layer, and output layer. The ANN can contain multiple different hidden layers enabling the network to have computational and processing abilities.Figure1 shows an artificial neural network (ANN) with a hidden layer, which contains some weights connecting between layers. The output values are going to be calculated through the subsequent steps.Figure 1
A three-layer artificial neural network.First, the sum of weights is calculated as follows:(4)Sj=∑i=1nwijIi+βi,where Ii is the input variable, wij is the weight between the input variable Iiand neuron j, and βiis the input variable’s bias term.Second, neurons’ output values in the hidden layers are produced from the received values of weighted summation (equation (4)) by using an activation function. A popular choice of such a function is a sigmoid function as follows:(5)fjI=11+e−Sj,where fjis the sigmoid function for neuron j and Sjis the sum of weights.Finally, the output of neuronj is calculated as follows:(6)Oj=∑i=1kwijfj+βj,where Ojis the output of neuron j, wijis the weight between the output variable Oiand neuron j, fjis the activation function for neuron j, and βiis the output variable’s bias term [24].


### 2.3. Proposed Method

The goal of employing a bat algorithm and artificial neural network simultaneously is to present a higher performance estimation and forecast. When the bat algorithm is embedded into an ANN to optimize its initial weights and biases, it will play a well-suited role in addressing a number of the deficiencies caused by the randomness of the initial weights and biases of ANN. The main goal of using the BAT algorithm to optimize the ANN is to combine them, using the initial connection weights between ANN layers and the initial biases between neural nodes, to optimize the distribution, execute global searches within the solution space, and find the optimal initial weights and biases of the ANN at a rapid convergence rate. Subsequently, the initial weights and biases obtained by the ANN are often used for training and testing the sample set. The ANN with the optimal weights and biases is formed and trained to predict the output. The flowchart of the BANN algorithm is shown in Figure2.Figure 2
Flowchart of the BANN.


## 2.1. Bat Algorithm (BA)

The BAT algorithm was introduced by Yang [15]. This algorithm is an evolutionary algorithm inspired by the behavior of natural bats in locating their foods. It is used to solve various problems. BA starts with an initial population of bats. It employs a homologous manner by performing an echolocation method for updating its position [16]. Bats send a signal with the loudness of frequency 20 kHz to 500 kHz. This signal is deflected back after striking the object to bat as an echo signal. The echo signal is used to calculate the bat’s distance to any object which is the destination of the bat [17, 18]. Bats fly towards the object or prey, and they reduce their pulse rate when they reach the closer object. Bats continue to do so till the distance becomes zero [18, 19]. Also, they can distinguish between insects and obstacles to hunt prey based on the echo [20]. The BA is summarized in the following three main principal rules [15–21]:(1)
Each bat utilizes echolocation characteristics to estimate the distance and to distinguish between prey and obstacles.(2)
Each bat flies randomly with positionxi, velocity vi with constant frequency fmin, updated wavelength λ, and loudness L0 to seek for prey. It automatically changes the frequency of its pulse emission and regulates the rate of pulse release r in a range [0, 1] based on the proximity of its target.(3)
Frequency, loudness, and pulse released rate of each bat is varied. The loudness is adjusted from a large value (positive)L0 to a minimum constant valueLmin.In the simulations, each bat is associated with a velocityvit and a location xitwith iteration t, in a d-dimensional search or solution space. Therefore, the above three rules can be translated into the updating equations for xti and velocities vit:(1)fi=fmin+fmax−fminβ,vit=vit−1+xit−x∗fi,xit=xit−1+vit,where βε0,1 is a random vector outcome from a uniform distribution. x∗ is the best current universal position, achieved after comparing the locations of all then bats. The frequency f during a range fmin,fmax corresponds to a range of wavelengths λmin,λmax. Indeed, the frequency just varies while the wavelength f is constant, and it is assumed that f∈0,max in implementation [22].For the local search, a solution is selected among the best current solutions, and a new solution for each bat is produced using a random walk.(2)xnew=xold+εLt,where εε−1,1 is a random number while Lt is the average loudness of all bats. The loudness normally reduces when a bat finds its prey while the rate of the pulse emission increases. The loudness may be chosen as any value of convenience. It can be chosen as any value of convenience between Lmin and Lmax assuming Lmin=0 which means that a bat has just found the prey and provisionally stops emitting sound. It is shown in the following:(3)Lit+1=αLit,∀0≤α≤1,rit+1=ri01−e−γt,∀γ>0,where t is the iteration number during the optimization process. As time moves towards infinity, the loudnessLit tends to be zero; then,rit=ri0.


## 2.2. Artificial Neural Network (ANN)

Artificial neural network is a famous artificial intelligent method that simulates the work of the human mind mechanism. It is a method that handles information coming from different nodes in this model known as neurons. These nodes are embedded in different layers which will work together to solve a complicated problem [23].Artificial neural network is a mathematical approximation to the human nervous system that have been widely used to solve various nonlinear problems. The structure of ANN contains the elements of the input layer, hidden layer, and output layer. A network can contain multiple different hidden layers enabling the network to have computational and processing abilities. The number of layers is dependent on the problem complexity. In general, a neural network is a set of connected input and output units that each connection has an associated weight [13].An artificial neural network (ANN) contains the elements of the input layer, hidden layer, and output layer. The ANN can contain multiple different hidden layers enabling the network to have computational and processing abilities.Figure1 shows an artificial neural network (ANN) with a hidden layer, which contains some weights connecting between layers. The output values are going to be calculated through the subsequent steps.Figure 1
A three-layer artificial neural network.First, the sum of weights is calculated as follows:(4)Sj=∑i=1nwijIi+βi,where Ii is the input variable, wij is the weight between the input variable Iiand neuron j, and βiis the input variable’s bias term.Second, neurons’ output values in the hidden layers are produced from the received values of weighted summation (equation (4)) by using an activation function. A popular choice of such a function is a sigmoid function as follows:(5)fjI=11+e−Sj,where fjis the sigmoid function for neuron j and Sjis the sum of weights.Finally, the output of neuronj is calculated as follows:(6)Oj=∑i=1kwijfj+βj,where Ojis the output of neuron j, wijis the weight between the output variable Oiand neuron j, fjis the activation function for neuron j, and βiis the output variable’s bias term [24].


## 2.3. Proposed Method

The goal of employing a bat algorithm and artificial neural network simultaneously is to present a higher performance estimation and forecast. When the bat algorithm is embedded into an ANN to optimize its initial weights and biases, it will play a well-suited role in addressing a number of the deficiencies caused by the randomness of the initial weights and biases of ANN. The main goal of using the BAT algorithm to optimize the ANN is to combine them, using the initial connection weights between ANN layers and the initial biases between neural nodes, to optimize the distribution, execute global searches within the solution space, and find the optimal initial weights and biases of the ANN at a rapid convergence rate. Subsequently, the initial weights and biases obtained by the ANN are often used for training and testing the sample set. The ANN with the optimal weights and biases is formed and trained to predict the output. The flowchart of the BANN algorithm is shown in Figure2.Figure 2
Flowchart of the BANN.


## 3. Optimization and Method Validation

Optimal tuning of PI controllers for load frequency controller design was proposed by Abd-Elazim and Ali [25]. Their results of numerical simulation demonstrated the superiority of BA in comparison with simulated annealing in PI controller optimization. Bat algorithm which is a heuristic method is used for selecting features. It is a metaheuristic algorithm. The process of optimization uses it. Function minimization or maximization is a major problem in optimization. Randomization is used for computing the best solution in the best optimum way [26]. Different measures are applied to examine the estimation accuracy and forecasting ability of different estimators. The most popular ones are mean squared error (MSE) or root mean squared error (RMSE) [13] and correlation coefficient (R).


## 4. Empirical Results

To obtain oil consumption data, it is necessary to normalize in the first step. Equation (7) was used in this regard.(7)XN=XR−XminXmax−Xmin,XN: normalized value, XR: the value to be normalized, Xmin: the minimum value in all the values for the related variable, and Xmax: the maximum value in all the values for the related variable. Xmin and Xmax values for each variable are selected between 1980 and 2012 and are shown in Table 1.Table 1
Minimum and maximum values of research variables for normalization.
VariableMaximumMinimumPer capita GDP (constant 2010 US$)6952.4443640.315Population, total (million persons)8139Import (a thousand barrels a day)2136.9Export (a thousand barrels a day)2867911Oil consumption (mboe)99.88928.434The input parameters of the BANN included population, gross domestic product, import, and export, and the oil consumption was considered as the BANN output parameter [1]. The data on these parameters were divided into training, testing, and data validation. 70% of these data were used for training, 15% of data were used for validation, and the rest were used for testing.Figures3–5 show the best validation performance graph and regression plot between actual and predicted data in the BANN method. Tables 2 and 3 and Figure 6 show the performance evaluation of BANN outputs.Figure 3
Validation performance graph.Figure 4
Regression plot.Figure 5
Optimized neural network output and model performance criteria for data.Table 2
Neural network operation.
Neural network processData usage (%)MSERTraining700.00019730.999356Validation150.02058050.966715Testing150.02924050.936587Total1000.00800100.953600Table 3
Performance evaluation of neural network outputs.
MSERMSEStd error0.0080010.0894510.080401235Figure 6
Error histogram for BANN outputs.Figure7 and Table 4 for the modeling and the testing data show the performance of the BANN method.Figure 7
Comparison of actual oil consumption values and their predicted values with BANN.Table 4
BANN operation.
YearsActual dataBANN−outputpredictedRelative error %201399.88999.154010.007358201493.94793.937719.89E-05201585.57985.372740.00241201681.79581.122050.008227201784.49684.560490.000763Average––0.003771546Table5 shows the comparison of different models introduced in the introduction and present study.Table 5
Comparison of various models introduced in the introduction and present studya.
SourceMethodTarget (country)Average relative errors (%)Toksarı [12]Ant colony algorithmTotal energy (Turkey)1.07Ceylan et al. [11]Harmony searchTotal energy (Turkey)21.74Harmony searchTotal energy (Turkey)13.41Harmony searchTotal energy (Turkey)39.32Assareh et al. [3]Genetic algorithmOil (Iran)2.83Genetic algorithmOil (Iran)1.72Particle swarm optimizationOil (Iran)1.4Particle swarm optimizationOil (Iran)1.36Behrang et al. [4]Gravitational search algorithmOil (Iran)1.14Gravitational search algorithmOil (Iran)1.52Gravitational search algorithmOil (Iran)1.43Gravitational search algorithmOil (Iran)3.32Gravitational search algorithmOil (Iran)1.33Kıran et al. [9]Particle swarm optimizationElectricity (Turkey)3.99Particle swarm optimizationElectricity (Turkey)4.406Artificial bee colonyElectricity (Turkey)3.20Artificial bee colonyElectricity (Turkey)4.47Present studyHybrid bat algorithm with artificial neural network (BANN)Oil (Iran)0.0037The average relative errors are separately based on the testing period of each model.


## 5. Conclusion

Demonstration of the significance of employing hybrid estimation strategies in the energy sector is the point of the present study. The relationship between economic development and energy consumption in developing countries is something essential, and it needs proper calculation for a wide variety of economic, social, and technological features. Therefore, in this study, the BANN (hybrid bat algorithm and artificial neural network) has been successfully used to estimate Iran’s oil consumption based on the structure of Iran’s socioeconomic conditions. Oil consumption is estimated based on population, GDP, import, and export. The proposed method anticipated oil consumption in terms of relative errors and RMSE.Given the high dependency of the Iranian economy on oil incomes, acquiring data by employing precious and qualified methods in this field will result in more efficient planning. According to Table5, the empirical results of Iran’s data exhibit that the accuracy of the BANN method was more precise than that of the other methods. Regarding the results, oil consumption is influenced by population, GDP, import, and export. Hence, the findings proved that the recommended model was an appropriate tool for effective oil consumption prediction in Iran. It will provide a level playing field for checking the energy policy authority impacts on the structure of Iran’s energy with high economic interventionism by the government.The BANN success in such a study suggests that it could be applied as a practical instrument for energy-economic analysis in various areas, such as designing energy systems with more theoretical specifications complexity. Forecasting oil consumption can also be studied by other metaheuristics including harmony search and simulated annealing. The results of different methods could be put into analogy with the BANN method.



---

*Source: 6189329-2021-02-24.xml*