1 Introduction

Drilling operations leads to significant costs during the development of oil and gas fields. Therefore, drilling optimization can decrease the costs of a project and, hence, increase the profit earned from the oil and gas production. In most of the studies, rate of penetration (ROP) has been considered as the objective function of the optimization process. ROP depends on many factors including well depth, formation characteristics, mud properties, rotational speed of the drill string, etc. Several studies have been conducted to gain a profound insight into the effective parameters on ROP [1, 2]. Maurer [3] introduced an equation for ROP, in which it was accounted for rock cratering mechanisms of roller-cone bits. Galle and Woods [4] proposed a mathematical model for estimating ROP, where formation type, weight on bit, rotational speed of bit, and bit tooth wear were taken as input parameters. Mechem and Fullerton [5] proposed a model with input variables of formation drilling ability, well depth, weight on bit, bit rotational speed, mud pressure, and drilling hydraulics. Bourgoyne and Young [6] used multiple regression analysis to develop an analytical model, and also investigated the effects of depth, strength, and compaction of the formation, bit diameter, weight on bit, rotational speed of bit, bit wear, and hydraulic interactions associated with drilling. Bourgoyne and Young [6] introduced a technic for selection of optimum values for weight on bit, rotational speed, bit hydraulics, and calculation of formation pressure through multiple regression analysis of drilling data. Tanseu [7] developed a new method of ROP and bit life optimization based on the interaction of raw data, regression, and an optimization method, using the parameters of bit rotational speed, weight on bit, and hydraulic horsepower. Al-Betairi et al. [8] used multiple regression analysis for optimization of ROP as a function of controllable and uncontrollable variables. They also studied the correlation coefficients and multicollinearity sensitivity of the drilling parameters. Maidla and Ohara [9] introduced a computer software for optimum selection of roller-cone bit type, bit rotational speed, weight on bit, and bit wearing for minimizing drilling costs. Hemphill and Clark [10] studied the effect of mud chemistry on ROP through tests conducted with different types of PDC bits and drilling muds. Fear [11] conducted a series of studies using geological and mud logging data and bit properties to develop a correlation for estimating ROP. Ritto et al. [12] introduced a new approach for optimization of ROP as a function of rotational speed at the top and the initial reaction force at the bit, vibration, stress, and fatigue limit of the dynamical system. Alum and Egbon [13] conducted a series of studies which led to the conclusion that pressure losses in the annulus are the only parameter which affects ROP significantly, and finally, they proposed an analytical model for the estimation of ROP based on the model introduced by Bourgoyne and Young. Ping et al. [14] utilized shuffled frog-leaping algorithm to optimize ROP as a function of bit rotational velocity, weight on bit, and flow rate. Hankins et al. [15] optimized drilling process of already drilled wells with variables of weight on bit, rotational velocity, bit properties, and hydraulics to minimize drilling costs. Shishavan et al. [16] studied a preliminary managed pressure case to minimize the associated risk and decrease the drilling costs. Wang and Salehi [17] used artificial intelligence for the prediction of optimum mud hydraulics during drilling operations, and performed sensitivity analysis using forward regression. A variety of artificial intelligence works have recently been conducted in civil and oil engineering [18,19,20,21].

In the present paper, a new approach was used for prediction and optimization of ROP, based on artificial neural network (ANN). ANN technique is able to approximate almost all problems of science and engineering [22,23,24,25,26,27,28,29,30,31,32,33,34]. According to the authors’ knowledge, ANN application on ROP optimization has not been widely used by the previous studies. The variables used in this study were well depth (D), weight on bit (WOB), bit rotational velocity (N), the ratio of yield point to plastic viscosity (Yp/PV), and the ratio of 10 min gel strength to 10 s gel strength (10MGS/10SGS). Using ANN technic, several models were developed for prediction of ROP, and the best one was selected according to their performances. Then, an artificial bee colony (ABC) algorithm was used for optimization of ROP based on the selected ANN predictive model, and the drilling parameters were evaluated to determine their effects on ROP.

2 Methodology

2.1 General description of artificial neural network

Artificial neural network (ANN) is a branch of artificial intelligence (AI) technics, which was introduced by McCulloch and Pittsin [35]. ANNs have two important advantages. First, they can be used as a substitute for complex simulation software packages, which require a lot of time to run the model. ANNs can learn the behavior of the software and provide the output with less computational effort. Second, ANNs are powerful tools for obtaining a meaningful relationship between a large amount of data, and predict the output for an unexperienced case [36]. In fact, a group of training data and a group of testing data are used for developing an ANN. Training data are used for training the ANN, and modify its parameters, and test data are used for evaluation of the accuracy of predictive model [37, 38].

An ANN is composed of neurons distributed in different positions called layers. The layers between the first and last layer are called hidden layers [23, 39, 40]. By entering the data, each neuron imposes some mathematical calculations on the data and delivers it to the next neuron. There are different types of interaction between neurons in an ANN, and the most common type is feed-forward-back-propagation (FF-BP) method, which is reported to be efficient by the previous authors [26, 41, 42]. This method involves two stages. First, the input data are passed through the layers, and an output is obtained. During this stage, synaptic weights of the network are determined. Second, according to the difference between the real (measured) output and predicted value by the ANN, the weights are adjusted through back propagation of error signal. This process iterates until an acceptable value of accuracy is met. There are different indices for the evaluation of network performance [37]:

$${R^2}=1 - \frac{{\sum\nolimits_{{i=1}}^{N} {{{(y - y^{\prime})}^2}} }}{{\sum\nolimits_{{i=1}}^{N} {{{(y - \tilde {y})}^2}} }},$$
(1)
$${\text{RMSE}}=\sqrt {\frac{1}{N}\sum\nolimits_{{i=1}}^{N} {{{(y - y^{\prime})}^2}} } .$$
(2)

2.2 General description of artificial bee colony

This algorithm was developed by Karaboga [43] and mimics the behavior of bees when they search for nectar of flowers. In a hive of bees, there are three different types of bees: scouts, employed bees, and onlookers. The scout bees start a random search of the surrounding environment to find flowers which secrete nectar. After finding the flowers, they keep the location in their memory. Then, they return to the hive and share their information about their findings through a process called waggle dance. Next, the other group, called employed bees, starts finding the flowers based on the information obtained from the scouts to exploit the nectar of the flowers. The number of employed bees is equal to number of food sources. The third group of bees are called onlookers, which remain in the hive waiting for the return of the employed bees to exchange information and select the best source based on the dances (fitness of the candidates). In addition, the employed bees of an abandoned food site serve as a scout bee.

Considering an objective function, \(f(x)\), the probability of a food source to be chosen by ab onlooker can be expressed as follows [44]:

$${P_i}=\frac{{F({x_i})}}{{\sum\nolimits_{{j=1}}^{S} {F({x_i})} }},$$
(3)

where \(S\) indicates the number of food sources and \(F(x)\) represents the amount of nectar at location \(x\). The intake efficiency is defined as \(F/\tau\), in which \(\tau\) represents the time consumed at the food source. If, in a predefined number of iterations, a food source is tried with no improvement, then the employed bees dedicated to this location become scout and hence start searching the new food sources in a random manner.

ABC algorithm has been used in different engineering problems including well-placement optimization of petroleum reservoirs [45], optimization of water discharge in dams [46], data classification [47], and machine scheduling [48]. More description on the ABC algorithm can be found in the other references [18, 43, 49, 50]. A typical flowchart of ABC algorithm is shown in Fig. 1.

Fig. 1
figure 1

Typical flowchart of ABC algorithm

3 Data collection

In the present study, a data set obtained from a drilling process in a gas field located in the south of Iran was used. The depth of the well was 4235, which was drilled with one run of roller-cone bit and three runs of PDC bit. The IADC code of the roller-cone bit was 435M, and PDC bits had codes of M332, M433, and M322. Roller-cone bit was used for about 20% and PDC bits for 80% of the drilled depth. In detail, roller-cone bit was used for the depth interval of 1016 to 1647 m, PDC (M332) was used for depth interval of 1647 to 2330 m, PDC (M433) was used for depth interval of 2330 to 3665 m, and finally, the depth between 3665 and 4235 m was drilled by PDC (M322).

The data sets consist of 3180 samples, which were taken every 1 m of penetration from 1016 to 4235 m. The recorded variables included well depth (D), rotation speed of bit (N), weight on bit (WOB), shut-in pipe pressure (SPP), fluid rate (Q), mud weight (MW), the ratio of yield point to plastic viscosity (Yp/PV), and the ratio of 10 min gel strength to 10 s gel strength (10MGS/10SGS). The statistical summary of the data points is gathered in Table 1.

Table 1 Statistical summary of input data

4 Result and discussion

4.1 Prediction

In the present research, an ANN model was developed to predict the ROP as a function of effective parameters. To train the network, three training functions were used including Levenberg–Markvart (LM), scaled conjugate gradient (SCG), and one-step secant (OSS). The number of hidden layers in the network was one, since, according to Hornik et al. [51], one hidden layer is capable of solving any type of non-linear function. The number of neurons in the hidden layer was another parameter to be set. Several equations have been proposed by different authors to determine the optimum number of neurons in a hidden layer, which are represented in Table 2. Ni and No indicate the number of input and output variables, respectively.

Table 2 The equations for determining the optimum number of neurons in a hidden layer

Using the values obtained by the equations of Table 2, several ANN models were developed with neurons of 2–16. Then, the models were compared in terms of R2 and RMSE, and the best model was selected [59,60,61]. The comparison was done through the method proposed by Zorlu et al. [62]. In this method, the R2 and RMSE of each enveloped model are calculated. Next, the networks are assigned an integer number according to their R2 and RMSE values, in the way than the better result acquires higher number. For example, if the number of models is equal to 8, the model having the best (highest) R2 value acquires 8, and the model having the worst model acquires the value of 1. This procedure also is repeated based on RMSE comparison. Then, the two numbers of assigned to each model are summed up, and a total score is obtained for each model. Finally, the model acquiring the highest total value is determined as the best model for the problem of study.

In the present article, three types of learning functions were used for training the network, the results of which are presented in Tables 3, 4, and 5. According to the tables, LM, SCG, and OSS functions acquired the best results, respectively. To design an accurate model, the best model of each function was compared. The results of comparison are shown in Figs. 2 and 3. As can be seen, the best model of LM function yielded a better performance. Thus, this function was selected for designing an ANN for the prediction and optimization of ROP.

Table 3 The results of the developed ANN models based on LM function
Table 4 The results of the developed ANN models based on SCG function
Table 5 The results of the developed ANN models based on OSS function
Fig. 2
figure 2

The results of R2 for LM, SCG, and OSS functions

Fig. 3
figure 3

The results of RMSE for LM, SCG, and OSS functions

4.2 Optimization purpose

In the previous section, an ANN was developed for the prediction of ROP using the input data. As mentioned, selecting the most accurate predictive model can significantly affect the performance of optimization. In this section, the performance of the optimization algorithm is evaluated. Then, the ANN model obtained in the previous section is incorporated in the optimization algorithm to optimize the effective parameters for maximizing the penetration rate.

4.3 Evaluation of optimization algorithm

In this section, the best ANN model obtained in the previous section was selected for the optimization of ROP using ABC algorithm. To evaluate the performance of ABC, two functions were used for minimization by ABC:

$$\begin{aligned} {{\varvec{F}}_1}\left( {\varvec{x}} \right) & =\left[ {1+{{\left( {{{\varvec{x}}_1}+{{\varvec{x}}_2}+1} \right)}^2}\left( {19 - 14{{\varvec{x}}_1}+3{\varvec{x}}_{1}^{2} - 14{{\varvec{x}}_2}+6{{\varvec{x}}_1}{{\varvec{x}}_2}+3{\varvec{x}}_{2}^{2}} \right)} \right] \\ & \quad \times \left[ {30+{{\left( {2{{\varvec{x}}_1} - 3{{\varvec{x}}_2}} \right)}^2}\left( {18 - 32{{\varvec{x}}_1}+12{\varvec{x}}_{1}^{2}+48{{\varvec{x}}_2} - 36{{\varvec{x}}_1}{{\varvec{x}}_2}+27{\varvec{x}}_{2}^{2}} \right)} \right]. \\ \end{aligned}$$
(4)

The range of variations of x1 and x2 are (− 2, 2). In addition, the optimal value of this function at the point (1−, 0) is 3.

This function is plotted in Fig. 4. The ABC algorithm was used for finding minimum point of the above-mentioned function, and the values of − 0.33559 and − 0.52311 were obtained for Eq. 4. The performance of ABC in finding the minimum point is illustrated in Fig. 5.

Fig. 4
figure 4

Function of Eq. 4 plotted in Cartesian coordinates

Fig. 5
figure 5

Evaluation of ABC algorithm for Eq. 4

4.4 Optimization of ROP in petroleum wells

In this section, the ANN predictive model was used for the optimization of parameters effective on ROP. Since the well depth increases during drilling, it was not considered as a decision variable. Hence, the parameters of ROP were optimized in some specific depths. It makes sense in the way that the parameters cannot be optimized in each meter of penetration.

The ABC algorithm was used for the optimization of ROP effective parameters. After a series of sensitivity analysis, it was concluded that the efficient number of population and iterations are 40 and 500, respectively. Three depths on which optimization applied were 2000, 2500, and 3000. The results of optimization in the selected depths are provided in Tables 6, 7, and 8.

Table 6 Comparison of real and optimized values for depth of 2000 m
Table 7 Comparison of real and optimized values for depth of 2500 m
Table 8 Comparison of real and optimized values for depth of 3000 m

As can be seen, in each selected depth, value of ROP was increased by about 20–30%. Therefore, by combining artificial intelligence and optimization, it can create suitable patterns for ROP in an oil well to increase penetration and reduce costs.

5 Conclusions

In the present work, artificial intelligence method was used for prediction of rate of penetration in a gas well. The data were collected from a gas field located in south of Iran. Seven input parameters were selected as input data to develop a predictive ANN model. For this purpose, three learning functions were compared, and LM function was selected as the best function for designing the predictive model (R2 = 0.912 and R2 = 0.893 for training and testing section, respectively). Next, an ABC algorithm was employed to optimize the effective parameters of ROP for maximizing the penetration rate. Three scenarios were selected for considering the well depth in optimization process. Then, the best models for the depths 2000 m, 2500 m, and 3000 m were obtained, and the results showed 20–30% of improvement in penetration rate. Therefore, it was concluded that the proposed model can be used for prediction and optimization of penetration rate in drilling operations. The outputs of this study can be provided as a practical application to use by engineers and researchers. In addition, the developed intelligent methods can be considered as a good alternative for empirical or theoretical methods.