Introduction

The accurate and sustainable usage of water resources depends on modeling techniques applied in hydrological processes. Also, observation of natural phenomena is needed primarily in modeling the hydrological events (Kisi et al. 2017). In order to estimate hydrological phenomena, some physical characteristics of watershed are necessary (Firat 2008). So, using classical methods, prediction of hydrological phenomena cannot be categorized as a simple process. For instance, channel roughness, uneven bed slope, and multiple branches make the flow routing process more complicated (Pramanik and Panda 2009). In other way, because of the shortage of accessible fresh water resources, accurate prediction of river flow and its fluctuations is considered as a basic rule in planning water resources. Therefore, researchers always try to modify available methods in order to reach more accurate estimations. During last decades, many equations as well as models have been utilized to predict river flow, but most of them did not lead to an accurate results. Recently, artificial intelligence methods (AI) have been accepted as suitable tools for modeling complicated nonlinear phenomena such as hydrological ones (Taormina et al. 2015). The AI’s acceptable performance lays probably in nothing but lack of understanding of the phenomenon nature. In fact, it does not matter for AI which phenomena and with what inputs are estimated. In this context, artificial neural network (ANN) is known as one of the most popular models.

Also, in the last decades, combination of ANN and fuzzy logic had led to the invention of neuro-fuzzy system (adaptive neuro-fuzzy inference system, ANFIS) which has advantages of both fuzzy logic and ANN in a single framework, and was widely used in order to model the hydrological phenomena (Firat and Gungor 2007; Gopakumar et al. 2007; Sanikhani and Kisi 2012; Gholami et al. 2017; Fotovatikhah et al. 2018).

Chang and Chen (2001) estimated real-time stream flow by a counter propagation fuzzy neural network method. Chang and Chang (2006) compared measured and predicted water level in reservoirs using neuro-fuzzy techniques. Drecourt (1999) and Savic et al. (1999) used genetic programming (GP) for modeling rainfall-runoff process. Aytek and Kisi (2008) concluded that GP is a superior method to predict suspended sediment and is more accurate than sediment rating curve and linear regression. Shiri and Kisi (2011) used GP, ANN, and ANFIS to predict groundwater level variations. They found GP as better model in this regard. They also compared AI methods with autoregressive moving average (ARMA), which exhibited the superiority of GP, ANFIS, and ANN over ARMA.

Wu and Chau (2011) used ANN to model rainfall-runoff process. They tried to eliminate the lag effect from two aspects: modular artificial neural network (MANN) and data preprocessing by singular spectrum analysis (SSA). The results showed that although MANN had no significant advantages over ANN, and SSA improved highly the modeling performance. Gholami et al. (2015) used dendrochronology (tree-rings) and ANN to model groundwater fluctuations. Results showed tree-rings had appropriate performance. Karimi et al. (2018) examined application of gene expression programming (GEP) and support vector machine (SVM) for river flow prediction. Results indicated that both GEP and SVM were able to predict the stream flow accurately.

In neural or neuro-fuzzy systems, determining the suitable structure of the network and selection of related parameters are considerably important (Cheng et al. 2005). Also, success of these networks almost depends on the accuracy and efficiency of their training algorithms and optimization methods. There are different methods to train the neural networks and gradient-based algorithms, especially back-propagation, are considered as the most popular ones. These methods are useful in many cases, but they require lots of burdens to optimize the system parameters when structure and parameters become large (Shihabudheen and Pillai 2018). In such cases, the algorithms face to some problems, such as trapping in local optima as well as over-fitting (Peyghami and Khanduzi 2012, 2013; Azad et al. 2018). Also, some algorithms such as Levenberg–Marquardt have high computational complexity and need high memory for calculations. Therefore, new methods are required to overcome the shortcomings of such methods. One of the most suitable methods are evolutionary algorithms. In this case, neuro-fuzzy system combined with evolutionary algorithms (EA) tries to find the parameters without facing to limitation of mentioned learning techniques. In the recent years, hybrid approaches and evolutionary algorithms are taken into consideration. But EA methods have various differences such as variety in convergence speed, computing volume, easy to implement, ability to solve problem with various natures, continuous and discrete, etc. So, the method should be selected with respect to the mentioned issues.

Chau (2007) used a split-step particle swarm optimization (PSO) to train ANN for river stage forecasting. The results showed that this method was able to benefit acceptable global searching ability and convergence. Cheng et al. (2015) combined ANN and quantum-behaved particle swarm optimization (QPSO) to predict daily reservoir runoff of Hongjiadu reservoir in China. They pointed out that the ANN-QPSO had higher accuracy than the ANN. Using two hybrid fuzzy models including ANFIS-GA and ANFIS-PSO, Jalal-Kamali (2015) predicted groundwater quality of Kerman Province located in center of Iran. ANFIS-PSO was also used in another study conducted by Basser et al. (2015) to estimate optimum parameters of a protective spur dike. Furthermore, Rezapour-Tabari (2016) integrated fuzzy inference system and direct search optimization algorithm (DSOA) to predict daily runoff in downstream of Taleghan River, Iran. The results showed that proposed model (ANFIS-DSOA) has suitable capability to predict mentioned parameter. Also, Svensson (2016) concluded that increasing the forecast horizon from 1- to 3-month decreased the correlation between hind casts and river flow observations.

In modeling hydrological processes such as river flow, rainfall, evaporation, etc. due to the nature of these phenomena, the possibility of increasing the forecast horizon is limited. So, owing to the limited ability of the models, the present study is performed to increase model accuracy in forecasting horizon (e.g., t + 1, t + 3, t + 5, and t + 7). Converting the daily values of river flow to monthly and yearly may lead to increase the correlation coefficient of data in a period of time and decrease severe fluctuations of river flow created by moderation, rather severe precipitation. Therefore, small or average rainfall which cause small or average floods are less observed or completely ignored, and as a result, modeling and prediction will be facilitated. According to the related literature, the effects of EA and especially comparative evaluation of some algorithms in improving ANFIS performance to predict river flow forecasting has been studied rarely. Consequently, investigation of EA’s application in prediction of river flow (till next 7 days) seems suitable while severe fluctuations of small and moderate floods are to be considered.

In the current study, two aims have been pursued: (1) In order to recover the problems of classical training algorithm for predicting river flow, three evolutionary algorithms—genetic algorithm (GA), ant colony optimization for continuous domain (ACOR), and PSO—were suggested as alternative to classic ANFIS optimization algorithm. The results of all three suggested methods were compared and, at last, the best one was proposed. (2) The accuracy of new methods was investigated in increasing the ability of ANFIS in river flow prediction for various forecasting horizons from 1 to 7 days.

Materials and methods

Study area

Zayandehrood river basin is located in the central part of Iran, with geographical coordinates of 50° 24′ to 53° 24′ east longitude and 31° 11′ to 33° 42′ north latitude, an area of 41,500 km2 and altitude of 1466 to 3974 m (Fig. 1). Although annual value of precipitation is approximately 140 mm, it changes from 50 mm in the east to 1500 mm in the west. Also, average amount of annual temperature is 14.5 °C, and the lowest and highest temperatures are 12.5 and 42 °C which occur in January and July, respectively. The basin is classified as semi-arid region and the annual potential evapotranspiration is 1900 mm. With average discharge of 900 million cubic meter (MCM), Zayandehrood River is considered as one of the most important rivers in the basin, and even Iran. It originates from eastern slopes of the Zagross Mountain and ends by reaching Gavkhuni swamp (Rezaei et al. 2013).

Fig. 1
figure 1

The location of study area (Safavi and Ahmadi 2015)

Adaptive neuro-fuzzy inference system

Jang and Sun (1993) proposed adaptive network based on fuzzy inference system which is named ANFIS. To describe the structure of ANFIS, the system comprises two inputs (x1 and x2). Also, two fuzzy Takagi and Sugeno’s type if-then rules and one output (y) are generally considered as follows (Shiri and Kisi 2010):

$$ Rule\ 1: if\left({x}_1\; is\;{A}_1\right) and\left({x}_2 is\ {B}_1\right) then\ {f}_1={p}_1{x}_1+{q}_1{x}_2+{r}_1 $$
(1)
$$ Rule\;2: if\left({x}_1\; is\ {A}_2\right) and\left({x}_2 is\ {B}_2\right) then\ {f}_2={p}_2{x}_1+{q}_2{x}_2+{r}_2 $$
(2)

Where A and B are the fuzzy sets, p, q, and r are consequent parameters of the model obtained in the training stage, respectively. The structure of ANFIS is composed by five layers. Layer 1 is input variables, fuzzy sets. Every node in this layer adapts to a function parameter. Gaussian function is commonly utilized as the activation function. Layer 2 multiplies any two memberships which got by the fuzzy sets, so the output represents fuzzy rules or applicable degree of intensity. In layer 3, every node is fixed, or non-adaptive. In layer 4, every node adapts to an output. The parameters in this layer are returned to as consequent parameters. In the last, there is only a single node which is a fixed or non-adaptive node. As the summation of all incoming signals from the previous node, this last node computes the overall output (Jang 1993).

It is notable that there has been used three methods, grid partition (GP), subtractive clustering (SC), and fuzzy c-means clustering (FCM), in order to generate a basic FIS. The primary modeling showed that the FCM had better performance than the SC and GP (Mirrashid 2014). Therefore, the FCM was used to train classic ANFIS in this research. Also, training algorithms of the ANFIS were selected as back-propagation and hybrid. It is notable that back-propagation had better performance in most of the predictions. On the other hand, optimum number of epoch for all models was 500, and increasing the number of epochs had not considerable effect on the models performance. The best value of initial step-size, step-size-decrease, and initial-increase were 0.01, 0.9, and 1.1, respectively. One thousand one hundred available data were divided into training (60%), validation (20%), and test stages (20%). To analyze the data, Matlab r (2014) software was used. It is notable that classic ANFIS was accepted as basic model because of its capability for modeling hydrological phenomena.

Application of particle swarm optimization for optimizing ANFIS parameters

PSO is a heuristic algorithm based on the stochastic optimization technique which was first introduced by Eberhart and Kennedy (1995). Owing to some reasons, such as low computational volume, easy implementation, independency on problem situations, high convergence speed, using global search method, ability to solve complex issues, and escaping from stocking in local optima points, has led PSO to use for solving many of the optimization problems. On the other hand, the classic ANFIS algorithms (gradient descent-based algorithms) are not able to train mentioned model properly to predict some phenomena with high natural complexity, such as rainfall and river flow. Poor performance is due to the high computational volume, the probability of being trapped in local optima, and some other problems (Salimi et al. 2018). In order to overcome such issues, PSO is an appropriate alternative to optimize and train ANFIS.

PSO algorithm considers each solution as a particle in a search space. Each particle has a fitness value that is being validated by a fitness function that is to be optimized. Particle i has a position in the d-dimensional space of the problem that is to be solved and its tth iteration is shown as Eq. (3). The same particle has a velocity which directs its movement and its tth iteration is shown as vector V (Eq. 4). Each particle uses a memory represented by vector P (Eq. 5) to remember the best position in each iteration.

$$ {X}_i^t=\left(\ {x}_{i1}^t,{x}_{i2}^t,\dots, {x}_{id}^t\right) $$
(3)
$$ {V}_i^t=\Big(\ {v}_{i1}^t,{v}_{i2}^t,\dots, {v}_{id}^t $$
(4)
$$ {P}_i^t=\left(\ {p}_{i1}^t,{p}_{i2}^t,\dots, {p}_{id}^t\ \right) $$
(5)

Each particle is updated after each iteration with two best values. The first and second best values are the best solution (pbest) and global best (gbest), the best position achieved within the population, respectively. PSO pursues these values. After determining the pbest and gbest, velocity of each particle is updated by using Eqs. 6 and 7.

$$ {V}_i\left(t+1\right)=W{V}_i(t)+{C}_1{r}_{1,i}(t)\left({p}_i(t)-{X}_i(t)\right)+{C}_2{r}_{2,i}(t)\left({p}_g(t)-{X}_i(t)\right) $$
(6)
$$ {X}_i\left(t+1\right)={X}_i(t)+{V}_i\left(t+1\right) $$
(7)

In Eqs. 6 and 7, t is the number of iterations, and two variables, C1 and C2, are learning factors. These two factors control displacement of a particle (particle displacement) after each iteration. Normally, C1 = C2 = 2. Two random numbers, r1 and r2, have a range [0, 1]. Inertia weight shown by W gets an initial value ranging within [0, 1].

In PSO, the population is initialized by random solutions. The fitness of the population is recalculated iteratively up to the point of reaching the termination condition with pbest, gbest, position, and velocity updated in every iteration. The system, finally, yields gbest and its fitness value. The termination condition may be defined, for example, as achieving the maximum number of iterations or arriving at a certain fitness value for gbest.

In the present study, PSO was used to optimize and train ANFIS in order to predict the river flow at 1, 3, 5, and 7 days ahead. The modeling of river flow by ANFIS-PSO had five stages (Fig. 2):

  1. 1.

    Determining the input and output data for the system (upstream and downstream river flow): At this stage, ratio of training, validation, and test phases are determined. Further, the initial parameters of the algorithm, such as the initial population size, the number of iteration, the learning rate, lower and upper bound of velocity, the intended error, the global and personal best learning coefficient, and other relevant parameters, are determined.

  2. 2.

    Calculating value of parameters by ANFIS in each cluster.

  3. 3.

    Generating a basic fuzzy system (FIS) and training it by the PSO: At this stage, first, a FIS is generated using one of the common methods, SC, GP, and FCM. Then, FIS is trained and optimized by PSO according to the following steps:

    1. a.

      First, according to the conditions and purpose of the problem, an initial population was generated, and average and variance amount of river flow data were set.

    2. b.

      In the following, the best experience of each particle (pbest) and the best experience of all the particles (gbest) were updated. The update of velocity for each particle is calculated by the Eq. (6).

    3. c.

      The new position of each particle was updated using Eq. (7).

    4. d.

      E was calculated by Eq. (8), if this value was met the acceptable error, went to step “4”; otherwise, the system went to the step e.

Fig. 2
figure 2

Steps of ANFIS-PSO model procedure

$$ E={Q}_{Target}-{Q}_{Model} $$
(8)

Where QTarget is observed river flow, QModel represents the predicted values by the model, and E indicates difference between the observed and the predicted values.

  1. e.

    Setting the counter (counter + 1): If the counter was greater than the maximum number of Maxiter (max-iteration), the optimization was completed and the system went to step 4. Otherwise, the system returned to step 1 and calculated the new variance and average amount of output river flow using some data with more potential.

  1. 4.

    Choosing the last values of the average and variance as the most optimal estimation of the output parameters.

  2. 5.

    Using the optimal values to calculate river flow in 1, 3, 5, and 7 days ahead.

  3. 6.

    Modeling the validation and test stages and evaluating the system performance using some error indices such as R2 and RMSE (m3/s).

To determine the algorithms’ setting parameters, after trying various values, max-iteration, population size, inertia weight, and inertia weight reduction factor, personal and global best learning coefficients were fixed to 800, 78, 1, 0.98, 2, and 2, respectively.

Application of ant colony algorithm for continuous domains for optimizing ANFIS parameters

Ant colony is an optimization method based on how food is searched by ants. Ant colony optimization (ACO) was first introduced by Dorigo (1992) and has acceptable ability to solve optimization problems with high computational complexity and voluminous computations. However, the ability of this algorithm to solve continuous problems is weaker than the discrete ones. Owing to this reason, Socha and Dorigo (2008) presented ACOR to improve the ability of the ACO to optimize continuous problems.

Using a continuous function instead of discontinuous functions as the probability density function (PDF) is the main idea of the ACOR. In fact, in this method, the ants’ population is distributed with a continuous function in the response domain. As a result, the ability of the algorithm to solve continuous problems is increased. It should be noted that in the first step of the present study, although several continuous functions were used, the Gaussian function had the most suitable performance. For this reason, the Gaussian function was used as a PDF in the prediction of river flow for all of the time periods.

Despite low convergence speed, ACOR has the features, such as lack of trapping in local optima, use of global search methods, ability to optimize some problems with high computational complexity, and grantee to reach convergence. These features make this algorithm as a suitable option for training a simulation system such as ANFIS.

The ANFIS-ACOR steps in accordance with Fig. 3 begin by identifying the inputs and outputs as well as the parameters related to the algorithm, such as the initial population, the number of iteration, and the alpha and beta coefficients. Then, using one of the existing methods (i.e., GP, SC, and FCM), a fuzzy system is generated. In the following, by providing the optimal values of the variance and the mean of the data, the ACOR tries to minimize the value of E (Eq. 8). Finally, the results are presented in three sections which are training, validation, and test, and performance of the model is measured by some statistical factors like R2, RMSE, and so on. It should be noted that, as with some other studies (Mirrashid 2014), the early modeling indicated that the FCM had a better performance than the GP and SC. For this reason, the results of the fuzzy systems generated by FCM have been reported in this study.

Fig. 3
figure 3

Steps of ANFIS-GA model procedure

It is noteworthy that after trying various values, the best amount of max-iteration, population size, conversion ratio fitness to pheromones (Q), power factor of pheromones (Alpha) and heuristic (Beta), and evaporation of pheromones (Roh) were 350, 45, 10, 2, 1, and 0.03, respectively.

Application of genetic algorithm for optimizing ANFIS parameters

GA is a meta-heuristic algorithm inspired by process of natural selection and was first introduced by Holland (1975). Owing to some reasons as the use of global search method, the lack of trapping in local optima, non-dependence on the problem conditions, and the suitable performance in solving complex problems with voluminous computations, GA is considered as an appropriate option for training ANFIS, although this algorithm has a relatively low convergence speed.

Duty of this algorithm is similar to PSO and ACOR and tries to provide the most optimal variance and average amount of the data. The difference of ANFIS-GA and other models (e.g., ANFIS-PSO, ANFIS-ACOR) is how to optimize these parameters (variance and average amount of the data for river flow); however, they are similar in the remaining steps. Figure 4 shows the steps of the ANFIS-GA model. After trying various values, the best max-iteration, initial population, percent of crossover, and mutation in GA algorithm were selected as 550, 80, 0.7, and 0.3, respectively.

Fig. 4
figure 4

Steps of ANFIS-ACOR model procedure

Modeling performance criteria

In the current study, five statistical criteria were used to select the optimal model. The statistical criteria consisting of coefficient of determination, R2, which indicates the degree of association between the predicted and observed values; root mean square error, RMSE (m3/s), which is commonly used in many iterative prediction and optimization schemes; mean absolute relative error (MARE); mean absolute error, MAE (m3/s); and Nash-Sutcliffe model efficiency (NSE) were used to evaluate the performance of suggested hybrid models. Equations are given as follows:

$$ {R}^2={\left[\sum \limits_{i=1}^n\left({x}_i-\overline{x}\right)\left({y}_i-\overline{y}\right)/\sqrt{\sum \limits_{i=1}^n{\left({x}_i-\overline{x}\right)}^2\sum \limits_{i=1}^n{\left({y}_i-\overline{y}\right)}^2}\right]}^2 $$
(9)
$$ RMSE=\sqrt{\frac{1}{n}\sum \limits_{i=1}^n{\left({x}_i-{y}_i\right)}^2} $$
(10)
$$ MARE=\frac{\sum_{i=1}^n\left|\left(\frac{y_i-{x}_i}{y_i}\right)\right|}{n}\times 100 $$
(11)
$$ MAE=\frac{\sum_{i=1}^n\mid \left( xi- yi\right)\mid }{n} $$
(12)
$$ NSE=\left[1-\left(\ \frac{\sum_{i=1}^n{\left({x}_i-{y}_i\right)}^2}{\sum_{i=1}^n{\left({x}_i-\overline{x_i}\right)}^2}\right)\right] $$
(13)

Where n is the number of data, xi and yi are the observed and predicted values, and \( \overline{x} \) and \( \overline{y} \) are average of observed and predicted values, respectively.

Data collection and analysis

The study area was divided into the upstream stations including Eskandari (U1) and Ghaleh-Shahrokh (U2) and the downstream ones including Sad-Tanzimi (D1), Pole-Zamankhan (D2), and Cham-Aseman (D3), according to the location of Zayandehrood dam (Fig. 1). Also, for comparison of river flows in the determined time periods (i.e., 1-, 3-, 5-, and 7-day), the values of river flow in different stations were used as input variables and the values of river flow in Pole-kaleh station (O) was used as output variable (Fig. 1). Dataset composed of daily river flow in 3 years was selected (totally 1100 data). These data were monitored regularly each day at six different sites (6 × 1100). For prediction of the river flow based on the existing measured values of different variables (U1–U2 and D1–D3) and their correlation analysis, total river flow values (m3/s) of five stations were identified. Statistical measures like standard deviation (SD) and coefficient of variation (CV) were used to determine dispersion of the data (Table 1).

Table 1 Basic statistics of measured river flow in different stations

To determine the relationship of each input variable (station) with output (O), a correlation analysis was applied (Table 2). According to correlation matrix, five data groups—I1 (Sad-Tanzimi), I2 (I1 + Cham-Aseman), I3 (I2 + Pol-Zamankhan), I4 (I3 + Ghaleh-Shahrokh), I5 (I4 + Eskandari)—were selected as model inputs candidates. River flow of Pol-Kaleh station was then predicted for 1, 3, 5, and 7 days ahead by ANFIS. Finally, the best input group was selected for modeling river flow by hybrid models.

Table 2 Correlation matrix of measured river flow among different stations

Results and discussion

According to Table 3, results suggested that I3 with most correlation coefficient had the best performance in prediction of river flow in 1, 3, 5, and 7 days ahead, so this data group has been selected as hybrid models’ input. To increase the certainty about models performance in later periods, the models were also used in 8- and 10-day ahead prediction but results did not provide required criteria and so they were not reported.

Table 3 The effects of various input groups for predicting the river flow of Pol-kaleh station in 1, 3, 5, and 7 days ahead

Models for 1-day ahead river flow prediction

The performance measures of hybrid ANFIS models for prediction of river flow at 1-day ahead are evaluated in Table 4. Almost all the models had acceptable performance in this forecast horizon. In this section, R2 and NSE of hybrid models in training, validation, and test stage were higher than 0.80. It is noteworthy that because the lag in this step was only 1-day, classic ANFIS performance could be comparatively satisfying. It is necessary to say that the average performance index returns to the function of validation and test stages, which have higher importance in models evaluation. The performance improvement of ANFIS-PSO was the highest and it was recognized as the most suitable model for river flow forecasting in 1-day ahead. This improvement was considerable such that the values of R2, RMSE (m3/s), MAE (m3/s), MARE, and NSE of ANFIS were improved from 0.82, 1.49, 55.5, 3.12, and 0.84 to 0.91, 1.39, 43.3, 2.94, and 0.92 by the best hybrid model (ANFIS-PSO), respectively.

Table 4 Performance indices of models for 1-day ahead river flow forecasting

The difference in performance of the suggested and classic models, ANFIS-PSO and ANFIS, can be related to the better capability of hybrid model training algorithm in escaping from trapping in local optima points as well as over-fitting. Also, appropriate ability of PSO compared to classic method in optimizing continues problems seems likely to be another reason for the obtained results. It is noteworthy that, as it mentioned before, classic algorithms require lots of burdens to optimize the system parameters when structure and parameters become large (Azad et al. 2018; Shihabudheen and Pillai 2018). Therefore, because of chaotic origin of river flow, structure and parameters become large, and as a result, the quality of classic ANFIS performance decreases.

PSO had better results than the GA because of its appropriate capability in solving continuous problems like river flow (Kachitvichyanukul 2012). The presented results of this study are compatible with other reports (Rezapour-Tabari 2016). Jalal-Kamali (2015) declared that PSO had better performance than GA on performance improvement of ANFIS in modeling of water quality parameters. Moreover, scatter diagram of ANFIS-PSO for validation and test stages is shown in Fig. 5. Note that, data pairs closer to the 45° line represent better prediction cases. The observed and ANFIS-PSO model predictions at 1-day ahead in validation and test stages are shown in Fig. 6. It is noteworthy that data from 0 to 164 days belong to validation and from 165 to the last day belongs to test stage.

Fig. 5
figure 5

Scatter plots of observed and predicted 1-day ahead river flows using ANFIS-PSO model

Fig. 6
figure 6

Observed and computed river flow values for 1-day lead time using ANFIS-PSO model in validation and test stage

Models for 3-day ahead river flow prediction

The performance of ANFIS fell significantly down with increasing the forecast horizon from 1- to 3-day such that the average RMSE (m3/s), MAE (m3/s), and MARE increased from 0.82 to 0.63, 1.49 to 2.16, and 3.80 to 6.85 and NSE decreased from 0.84 to 0.70 in the validation and test stages, respectively. It is because of raising the turbulence in river flow data when the lag was increased from 1- to 3-day. In fact, when the turbulence level enhances, the classic algorithm is less capable to train the system properly, and as a result, model fails to predict extremum points (highest or lowest river flow values). The advantage of the hybrid models was increased compared to classic ANFIS with increasing the forecast horizon. ANFIS-PSO as the best model succeeded to improve error measures (R2, RMSE (m3/s), MAE (m3/s), MARE, and NSE) respectively by 0.18, 0.22, 1.44, 19.72, and 0.11%. This model placed in the first rank respectively with 0.81, 1.94, and 5.4 values of R2, RMSE (m3/s), and MAE (m3/s) (Table 5). After that, ANFIS-ACOR also had better performance than the classic ANFIS. It seems that better performance of GA in optimization of discrete data caused to poor accuracy (Kachitvichyanukul 2012). It is necessary to say that time needed for training ANFIS by the PSO was significantly less than the ACOR and GA. It is an important advantage for PSO and is due to its simple structure. Low convergence speed of ACO and GA is one of the most important weaknesses of these algorithms. It is notable that the high value of determination coefficient and NSE in results of hybrid models shows that over-fitting phenomenon had not happened during modeling process. The results are supported by other reports. In an investigation done by Elbeltagi et al. (2005), five evolutionary-based search methods were compared and they generally found that PSO performed better than GA, memetic algorithm, ACO, and shuffled frog leaping algorithm in terms of success rate and solution quality. Figure 7 shows the scatter graphs of predicted and measured values in validation and test stages of ANFIS-PSO model. The observed and computed values of ANFIS-PSO model for 3-day ahead hydrograph are exhibited in Fig. 8.

Table 5 Performance indices of models for 3-day ahead river flow forecasting
Fig. 7
figure 7

Scatter plots of observed and predicted 3-day ahead river flow using ANFIS-PSO model

Fig. 8
figure 8

Observed and computed river flow values for 3-day lead time using ANFIS-PSO model in validation and test stage

Models for 5- and 7-day ahead river flow prediction

Increasing the forecast horizon causes some difficulties for intelligent models (Salimi et al. 2018). The results obtained by ANFIS-PSO and other models for prediction of river flow in next 5 and 7 days ahead were given in Tables 6 and 7, respectively. Similar to previous sections, ANFIS-PSO showed the best performance and least error while the results obtained by other models were in close agreement with ANFIS. Therefore, it was difficult to select alternative models, hierarchically. In this condition, ANFIS-PSO improved ANFIS performance, considerably. The mentioned model could optimize the values of R2, RMSE (m3/s), MAE (m3/s), and MARE as 0.16, 0.45, 2.11, and 95.35 in 5-day time period, respectively (Table 6). Function improvement of ANFIS in 5-day ahead can be introduced as the most important performance of ANFIS-PSO, because performance evaluation criteria were evolved from an unacceptable value to a satisfactory value in this period (Table 6). It is noteworthy that because of chaotic nature of many hydrological phenomena, R2 higher than 70% is acceptable in hydrological modeling studies. Figure 9 shows the scatter graphs of predicted and measured values in validation and test stages of ANFIS-PSO model. The observed and computed values of ANFIS-PSO model for 5-day ahead hydrograph are exhibited in Fig. 10.

Table 6 Performance indices of models for 5-day ahead river flow forecasting
Table 7 Performance indices of models for 7-day ahead river flow forecasting
Fig. 9
figure 9

Scatter plots of observed and predicted 5-day ahead river flow using ANFIS-PSO model

Fig. 10
figure 10

Observed and computed river flow values for 5-day lead time using ANFIS-PSO model in validation and test stage

The investigations in last time period (7-day ahead) showed some evidences of models performance decrement. As it mentioned before, it lays in nothing but racketing up the complexity of making a useful equation between input and output because of long gaps (7-day lags). The performance of ANFIS-PSO in this period was much better than the other models, similar to other periods. In this period, the ANFIS-PSO showed the highest performance improvement such that the average of R2 (validation and test stages of the classic ANFIS) was increased from 0.22 to 0.53; the average of MAE (m3/s) was decreased from 12.85 to 8.65, NSE was enhanced from 0.44 to 0.62, and MARE fell from 231 to 183 (Table 8). However, the obtained results are far from acceptable standards of hydrological modeling. Therefore, it can be concluded that 5-day ahead was the last acceptable forecast horizon of river flow that could be predicted by presented evolutionary algorithms.

Table 8 Performance indices of the best models in different time periods

Sensitivity analysis

In this study, sensitivity analysis has been done based on cosine amplitude method (CA). CA is an equation based on input and output series data (Hasanipanah et al. 2016). CA equation is given below.

$$ {CA}_{ij}=\frac{\sum_{k=1}^n\left({X}_{ik}+{X}_{jk}\right)}{\sqrt{\ {\sum}_{k=1}^n{X}_{ik}^2{\sum}_{k=1}^n{X}_{jk}^2}} $$
(14)

In Eq. 13, Xi and Xj are input and output parameters, respectively, and data range changes from 0 to 1. Investigations showed that results obtained by sensitivity analysis have high overlap with correlation matrix results. Both analyses indicated that constructed dam in the bed river causes to impair in upstream and downstream river flows. It is necessary to say that CA equation is a trustworthy method for analysis of two time series of parameters and can be used in analysis and validation of results obtained by correlation matrix and nonlinear sensitivity analysis while it has this capability to be used in many hydrological watershed. The results obtained by CA are given in Table 9.

Table 9 Sensitivity analysis of the governing stations in different time period

Conclusion

Predicting river flow fluctuations is important for planning and constructing river structures and other industrial operations as well as integrated water resources management. In the present study, the accuracy of classic ANFIS method was improved to predict river flow at 1, 3, 5, and 7 days ahead. Hybrid ANFIS models were obtained by integrating ANFIS with GA, ACOR, and PSO algorithms. The results showed that the mentioned algorithms were capable to improve the ANFIS performance to predict the river flow in all periods. PSO was introduced as the most suitable algorithm to reduce the probability of being trapped in local optima, over-fitting, and increasing convergence speed. Sensitivity analysis (cosine amplitude method) showed that the selected inputs with respect to correlation analysis were the best inputs for modeling river flow in this study. Overall, it can be concluded that the evolutionary algorithms (especially PSO) can be successfully used to train the ANFIS in forecasting 1-, 3-, and 5-day ahead river flows.

The scope of the present study is able to be modified to improve the prediction skill in several ways, such as follows: (I) benefiting other related hydrological information commonly used in modeling river flow, (II) trying other appropriate EA methods to examine their performance as well as compare with the methods presented in this study, (III) using the suggested methods to predict other hydrological phenomena, (IV) comparing the performance of suggested hybrid method with other kinds of popular methods, e.g., ANNs, SVR, GEP, etc.