Introduction

Energy consumption is a critical indicator of the development of any country. Economic growth needs support from electrical energy sources. The conventional sources are the most used sources to meet residential and commercial loads. The increased use of conventional energy sources increases greenhouse emissions, such as carbon dioxide [1]. Buildings are consuming around 51% of global energy generation, which leads to greenhouse gas emissions [2]. The negative impacts of conventional sources, such as global warming, attract governments, investors, engineers, and researchers to implement and integrate renewable energy sources, such as solar energy.

Photovoltaic (PV) systems are among the most used renewable energy technologies worldwide, increasing cities’ energy consumption. Nowadays, the PV systems are widely used as the rooftop solar PV systems, which are called building-integrated photovoltaics (BIPV) systems. The BIPV systems are promoted by most governments worldwide [3]. Therefore, PV systems are considered a secure, clean, and environmentally friendly source. Sizing PV systems’ components can play a significant role in the system’s optimal size, which means the supply’s high availability at minimum cost. PV modules are the main component of any PV system. Therefore, the PV module must be modeled to include the uncertainties coming from the fluctuations of the weather conditions. Such as solar radiation and ambient temperature [4]. The accurate prediction of the PV modules’ performance is very significant in power system applications, especially for energy management applications, to realize the uncertainties from the distributed energy resources and effects on electricity consumers’ behavior. Besides, the PV performance prediction accuracy leads to managing the electricity markets’ prices and avoiding any cost unbalance [5]. Several applications need an accurate model to predict the performance of PV modules. These applications contain the optimal power flow [6], energy storage chagrining, and discharging behaviors [7], demand-side [8], management, and microgrid [9].

Accordingly, the critical role of the applications mentioned above can be represented by characterizing the PV output power or current. The PV module’s performance is mainly a function of solar radiation and ambient temperature. Thus, any modeling or prediction technique for the PV model’s performance is usually developed based on these variables [10]. Several models are used to characterize the performance of PV modules. These models can be classified as linear models [11], regression models [12], and machine learning models [13]. The accuracy of some of these methods, such as linear, regression, and regressive, is questionable as they are suffering to handle the high uncertainty from solar radiation.

Therefore, several machine learning techniques are widely used to avoid the limitations of the above methods. These techniques include artificial neural network (ANN), support vector machine (SVM), and random forests (RFs). The ANN model shows promising results to model PV modules’ performance as it can handle the uncertainty. Here, several research works have successfully implemented ANN. In [14], the authors used the ANN model to forecast the PV output power. The feed-forward ANN topology has been utilized. Solar radiation, temperature, and wind velocity are considered as the inputs of the ANN model were. The accuracy of this model was measured based on the absolute error. The error of the predicted values compared with the actual values was between 7.7% and 17.6%. In [15], a hybrid multi-layer feed-forward ANN model has been developed and used to predict the PV output power in a grid-connected PV system. The inputs of this model were the solar radiation and the module’s temperature. In [16], several of ANN’s topologies are optimized based on an adaptive approach to predict the PV output power in a grid-connected PV system. Based on the previous research works, it is clear that the ANN can predict PV modules’ performance with a lower error. The prediction error of predicting PV modules’ performance ranges from 5 to 11% [4]. Besides, solar radiation and temperature are the most used inputs to predict the performance of the PV modules. However, the classical ANN models have several hyperparameters, such as the number of hidden neurons. Till now, there is no direct mathematical formula to select the optimal number of neurons. Most of the researchers are using the trial and error approach to set the number of neurons. Therefore, if the number of neurons is undersized, the results will be underfitting, causing high training and high generalization error. While if the number of neurons is oversized, then the results will be overfitting, and a high variance may occur [17].

Accordingly, optimizing the number of hidden neurons may increase the accuracy of the forecasted results. Several artificial intelligence (AI) methods are used to optimize the number of neurons. The ANN-based AI models’ results show good improvement in the predicted values’ accuracy compared with the classical ANN models. Many AI techniques are proposed in the literature, such as particle swarm optimization (PSO) [18], genetic algorithm (GA) [19], and so on. PSO has several disadvantages, such as stuck in the local optima and requires more iterations to find the solution.

In contrast, GA requires a lower number of iterations to find a solution. GA is successfully used to optimize the parameters of several applications [20]. In addition, the performance analyses of various commercial photovoltaic modules based on local spectral irradiances in Malaysia is carried out using GA [21]. GA is an evolutionary algorithm that can optimize ANN’s weights [22,23,24]. Moreover, GA is used to tune the parameters of ANN towards a comprehensive optimization of engine efficiency and emissions in the work of [21]. GA mimics chromosomes’ generation to produce new DNA strings that merge components from two diverse chromosome strands. GA can be highly adaptable in their application, given that the chromosomes reveal a data array, which can be utilized to express as many characteristics as needed using the base classifier. GA is sensitive to local optima, which may need to be examined iteratively for sounder and dependable results. In [25], GA is utilized to tune SVM’s hyper-parameters for a short-term PV power prediction.

In this paper, an ANN algorithm is developed based on the GA to predict the PV module’s performance, including the voltage, current, and power at the maximum power point. The main idea is to improve the accuracy of the ANN model using GA. Thus, the GA aims to optimize the ANN’s hyperparameters, such as the number of neurons based on minimum root-mean-squared error (RMSE) between the actual data and the predicted one. The main contributions of this paper can be summarized as follows:

  • Improving the cascade-forward neural network (CFNN) model’s accuracy by optimizing the number of hidden neurons using GA.

  • Comparing the accuracy of the CFNN-based GA model with the classical CFNN, classical feed-forward neural network (FFNN), and FFNN-based on GA models to show the superiority of the proposed model.

The remaining paper is organized as follows: Section 2 describes the mathematical modeling of the PV module. In Section 3, the methods used in this paper are briefly discussed. These methods are FFNN, CFNN, and GA. The flowchart and the procedure of the proposed model are described in Section 4. In section 5, the simulation results and discussion are mentioned. Finally, Section 6 summarizes the main findings of this research work.

Mathematical Model of a Photovoltaic Module

The PV module has several PV solar cells. They are connected in parallel and series configurations. The schematic diagram for a PV solar cell is illustrated in Fig. 1. From Fig. 1, it can be noticed that the PV solar cell contains a current source, which represents the solar radiation, connected in parallel with a p-n diode, and a parallel resistance with a series resistance [4].

Fig. 1
figure 1

The schematic diagram for a PV solar cell

The non-linear behavior of the PV cell output current (I) can be mathematically presented as:

$$ I={I}_{ph}-{I}_0\left[\mathit{\exp}\left(\frac{V+I{R}_s}{V_t}\right)-1\right]-\frac{V+I{R}_s}{R_{sh}} $$
(1)

where Iph stands for the photogenerated current, V represents the PV cell output voltage, I0 represents the diode saturation current, Rs represents the series resistance, Rsh is the shunt resistance and Vt is the thermal voltage. Here, Vt can be obtained by,

$$ {V}_t=\frac{a{k}_b{T}_c}{q} $$
(2)

where a stands for the diode ideality factor, kb is Boltzmann constant, q represents the charge of the electron, and Tc is the cell temperature in Kelvin. The value of Tc can be calculated from the ambient temperature as:

$$ {T}_c={T}_A+\left(\frac{NOCT-20{}^{\circ}}{800}\right)G $$
(3)

where TA is the ambient temperature, NOCT represents the nominal operating temperature of the cell, and G stands for the solar radiation.

The maximum power point of the PV cell (Impp) can be obtained as [26]:

$$ {I}_{mpp}={I}_{ph}-{I}_0\left[\mathit{\exp}\left(\frac{V_{mpp}+{I}_{mpp}{R}_s}{V_t}\right)-1\right]-\frac{V_{mpp}+{I}_{mpp}{R}_s}{R_{sh}} $$
(4)

where Vmpp is the PV cell maximum power point voltage.

Accordingly, the PV cell maximum power (Pmpp) can be estimated by,

$$ {P}_{mpp}={V}_{mpp}\times {I}_{mpp} $$
(5)

Methods

In this section, the artificial neural network (ANN) basics as a prediction technique and the genetic algorithm (GA) as an optimization technique are described.

Artificial Neural Network (ANN)

ANN is considered as a machine learning technique that is inspired by the human nervous system to handle the information. The ANN principle aims to identify the data pattern and learn from the characteristics and the interactions on these patterns. The ANN structure has three main layers; the input layer, the hidden layer containing the hidden neurons, and the output layer. The hidden neurons have activation functions, which aim to link the layers by weight links [16]. The ANN model has two main stages; training and testing stages. In the training stage, the hidden neurons receive the information from the input layer by the incoming links and then combine it with a non-linear function with the training stage’s targeted response. The created relationship is utilized to find the current timestep’s proper weight, which predicts the new data. A part of the dataset for the variables considered as inputs is used to test and validate the trained model’s accuracy in the testing stage. The merit of the ANN is the ability to model complex problems accurately [25].

Several topologies of the ANN are utilized to model the performance of the PV modules in the literature [27], such as a feed-forward neural network (FFNN) [15], general regression neural network (GRNN) [27], and cascade-forward neural network (CFFN) [28]. The FFNN is considered the most direct and straightforward ANN topology, allowing it to pass from the input layer to the output layer through the hidden layer. The FFNN updates the weight links by utilizing the back-propagation(BP) algorithm. In contrast, the GRNN is suitable for applications that the availability of the data is limited or relatively small. Finally, the CFNN has also used the BP algorithm as a learning algorithm. However, the weighted link at each neuron depends on the information in the previous neurons. The CFNN has the ability to handle a wide rand of the dataset. Therefore, in this paper the FFNN and CFNN topologies are utilized to forecaste the PV output power with and without optimizing their number of neurons.

Feed-Forward Neural Network (FFNN)

The FFNN is the simplest ANN topology [15]. The structure of the FFNN is illustrated in Fig. 2. The FFNN contains three main layers, such as the input, hidden, and output layers. The hidden layer contains the hidden neuron. The input layer passes the inputs to the hidden layer. Each hidden neuron has an activation function and several links with all the inputs. Accordingly, the weights are calculated for each sample of the dataset and updated at the next sample. The calculation and update of these weights are carried out based on the correlation and estimated error between the actual training data on the output layer with that predicted at each data sample. The update of these weights is conducted based on minimizing the calculated error to improve the model’s accuracy.

Fig. 2
figure 2

The structure of an FFNN topology

Cascade-Forward Neural Network (CFNN)

The CFNN topology structure is similar to that in FFNN. It is started with defining the number of the input and output neurons according to the number of inputs and outputs from the dataset [28]. The data starts feeding to the hidden neurons. The CFNN model aims to maximize the correlation between actual and predicted data by feeding the new data by adjusting the weights. This process is repeated until the minimum error is reached between the actual and predicted data. The structure of the CFNN topology is shown in Fig. 3.

Fig. 3
figure 3

The structure of a CFNN topology

The values of weights are calculated for each neuron. The calculation of these values in FFNN and CFNN topologies is conducted based on the supervising learning algorithm. The BP learning algorithm is utilized for the learning process in FFNN and CFNN topologies as follows:

$$ {ANN}_u\left(\left(L,N\right),I,O\right)\overset{Traning}{\to }{ANN}_t $$
(6)

where ANNurepresents the untrained ANN model, L stands for the number of hidden layers in the network, N is the number of hidden neurons at each L, I stands for the inputs from the training dataset, O is the output from the training dataset and ANNt stands for the trained ANN model.

According to Fig. 3, the equations are formed from the CFNN model can be written as follows [29]:

$$ y={\sum}_{i=1}^n{f}^i{w}_i^i{x}_i+{f}^o\left({\sum}_{j=1}^k{w}_j^o{f}_j^h\left({\sum}_{i=1}^n{w}_{ji}^h{x}_i\right)\right) $$
(7)

where y represents the output from CFNN, fi is the activation function from the input layer to the output layer, \( {w}_i^i \) is weight from the input layer to the output layer, xi stands for the input vector, fo is the activation function on the output layer, \( {w}_j^o \) stands for the weight of the output layer, \( {f}_j^h \)is an activation function on the hidden layer, \( {w}_{ji}^h \) represents the weight of the hidden layer.

If a bias is added to the input layer and the activation function of each neuron in the hidden layer, then the output from CFNN in (7) can be rewritten as:

$$ y={\sum}_{i=1}^n{f}^i{w}_i^i{x}_i+{f}^o\left({w}^{\mathrm{b}}+{\sum}_{j=1}^k{w}_j^o{f}_j^h\left({w}_j^b+{\sum}_{i=1}^n{w}_{ji}^h{x}_i\right)\right) $$
(8)

where wb stands for the weight from bias to output and \( {w}_j^b \) is the weight from bias to hidden layer.

The number of hidden neurons is considered one of the essential hyper-parameters in the ANN, which significantly affects the ANN models’ accuracy. According to the literature, no mathematical formula can be used to find the optimal number of hidden neurons directly [30]. The number of hidden neurons is dependent on the data characterization and the number of inputs, outputs, and hidden layers. The number of hidden neurons is mostly calculated based on a trial and error method. Here, if the number is high, then over-fitting and high variance may happen. While if it is low, high training and generalization errors may happen. Therefore, the number of hidden neurons should be selected optimally. In this research, the genetic algorithm (GA) is proposed to optimize the FFNN and CFNN models’ neurons. The objective function aims to minimize the value of root mean square error (RMSE).

Genetic Algorithm (GA)

The genetic algorithm (GA) was introduced in the 1960s and 1970s by John Holland and his collaborators [31, 32]. GA mimics an abstraction of biological evolution based on Charles Darwin’s theory of natural evolution by modifying a population of individual solutions [25]. Therefore, GA is considered as a class of heuristic optimization methods. GA has several advantages over traditional optimization algorithms, such as the ability of dealing with complex problems and parallelism. Accordingly, GA can handle several objective functions, including (i) linear or nonlinear; (ii) stationary or non-stationary;(iii) continuous or discontinuous; or (iv) with random noise [33]. As GA has multiple offsprings in a population; therefore, the population can explore the search space in many directions simultaneously. This fact supports the parallization of the GA [34]. A GA flowchart is shown in Fig. 4. Therefore, the main characteristics of a GA are as follows:

  1. 1.

    GA works with a coding of the parameter set, not the parameters themselves.

  2. 2.

    GA initiates its search from a population of points, not a single point.

  3. 3.

    GA uses payoff information, not derivatives.

  4. 4.

    GA uses probabilistic transition rules, not deterministic ones.

Fig. 4
figure 4

GA working principle flowchart

GAs are being used to solve a wide variety of problems in energy applications, such as MPPT controllers introduced in [35] and overviewed in [36, 37], and PV performance analysis in [21].

The Proposed Model

The proposed model is a combination between the CFNN and the GA. The GA is utilized to tune the number of hidden neurons in the CFNN. The main procedure for optimizing the number of hidden neurons using GA is lustrated in Fig. 5. Here, the main steps of the proposed model structure can be summarized as follows:

  1. 1.

    In the first stage, the variables and inputs are imported to be used in the proposed model. In this paper, the proposed model’s inputs are solar radiation, ambient temperature, day number of the year, and hours. At the same time, the output of the proposed model is the output PV power.

  2. 2.

    The maximum number of iterations, size of the population, which equals to the dimension of the optimization problem multiply by 10, and the dimension of the optimization problem, which is one in this work as the GA aims to optimally tune one hyper-parameter of the CFNN model based on minimum RMSE are set. Finally, set the upper and lower limits of the dimension of the optimization problem.

  3. 3.

    The objective function is defined in this stage. In this paper, the RMSE is considered to be the objective function. RMSE is calculated as a relation between the predicted and the actual values.

  4. 4.

    The GA is utilized to optimize the number of hidden neurons in the CFNN model based on minimum RMSE. This stage is started by randomizing the hidden neuron’s number as an initial value for the first iteration.

  5. 5.

    According to the hidden neurons’ initial value, the CFNN model is trained to predict the response. The predicted response is used as an input to the objective function. Here, the RMSE is calculated.

  6. 6.

    If the calculated RMSE is lower than the calculated using the random number of neurons, then the new number is updated. Otherwise, the previous number of neurons is still dominating, and it is used for the next iteration.

  7. 7.

    The above steps will be returned until the maximum number of iterations reached the maximum number of iterations.

  8. 8.

    The number of the hidden neurons at a minimum RMSE value is considered the optimal number of the hidden neurons.

  9. 9.

    The optimal number of the hidden neurons is used to train the CFNN using 70% of the dataset. Besides, the remaining dataset (30%) is used to test the CFNN model. The predicted response is used to evaluate the performance of the CFNN-based GA model.

Fig. 5
figure 5

The flowchart of the proposed CFNN-based GA model

To evaluate the performance of the proposed model, five statistical error terms are utilized. These terms are RMSE, nRMSE, MBE, nMBE, and MAPE, which they can be mathematically formulated as:

$$ RMSE=\sqrt{\frac{1}{N}{\sum}_{i=1}^N{\left({I}_{p_i}-{I}_{a_i}\right)}^2} $$
(9)
$$ nRMSE=\frac{\sqrt{\frac{1}{N}{\sum}_{i=1}^N{\left({I}_{p_i}-{I}_{a_i}\right)}^2}}{mean\left({I}_a\right)} $$
(10)
$$ MBE=\frac{1}{N}{\sum}_{i=1}^N{\left({I}_{p_i}-{I}_{a_i}\right)}^2 $$
(11)
$$ nMBE=\frac{\frac{1}{N}{\sum}_{i=1}^N{\left({I}_{p_i}-{I}_{a_i}\right)}^2}{mean\left({I}_a\right)} $$
(12)
$$ MAPE=\frac{100}{N}{\sum}_{i=1}^N\left|\frac{I_{p_i}-{I}_{a_i}}{I_a}\right| $$
(13)

where Ip represents the predicted PV power value, Ia represents the real PV power value, and N represents the length of the dataset.

Results and Discussion

The Four models, FFNN, CFNN, and FFNN-GA and the proposed model (CFNN-GA) are developed using MATLAB 2020a operated by a standard PC under Windows 10. Actual hourly data for a PV module and meteorological data are utilized to show the proposed model’s effectiveness. Here, the PV data are measured at 30° tilt angle and 0° azimuth using four wire connection to a bipolar power supply. Accordingly, the global tilt irradiance is measured using a ventilated pyranometer mounted in 30° plane, while the module temperature is measured using three wire connections to Pt100 resistance temperature detectors. The electrical specifications of the used PV module can be summarized as listed in Table 1.

Table 1 Electrical specifications for a PV module

A sample of each of the utilized meteorological data is shown in the following figures. Here, a sample for 500 h of the solar radiation and ambient temperature is shown in Figs. 6 and 7, respectively. Figure 8 shows a sample of the training PV power output. Here, 70% of the dataset is utilized for training the proposed model and the other models. At the same time, the remaining dataset is utilized to test and validate the models.

Fig. 6
figure 6

A sample of the training solar radiation data

Fig. 7
figure 7

A sample of the training ambient temperature data

Fig. 8
figure 8

A sample of the training output power data

The GA is utilized to optimally tune the number of hidden neurons for the CFNN and FFNN models. The maximum number of iterations in GA is set to be 500 iterations. Also, the dimension of the optimization problem is set to be 1. Therefore, the population is set to be 10. Finally, the search space limits for the hidden neurons are set as [1, 100] neurons. Accordingly, the convergence curves for the GA for optimizing the number of hidden neurons in CFNN and FFNN are shown in Figs. 9 and 10, respectively.

Fig. 9
figure 9

Convergence curve for the FFNN-based on GA model

Fig. 10
figure 10

Convergence curve for the proposed model

Based on Fig. 9, it can be noticed that the optimal number of the hidden neurons in the CFNN model is nine neurons with an RMSE value of 0.06 W. The optimal solution is reached after 200 iterations. In comparison, the optimal number of the hidden neurons for the FFNN model is seven neurons with an RMSE value of 0.0025 W, as shown in Fig. 10, which is obtained after 100 iterations. To show the proposed model’s effectiveness, 30% of the data set is used to test it and validate it by utilizing the hidden neurons’ optimized number. Accordingly, Fig. 11 shows the forecasted output power utilizing the proposed model and the PV module’s actual values.

Fig. 11
figure 11

A sample of 100 h of the predicted PV output power using the proposed model

Based on Fig. 11, it is clear that the forecasted values are very close to the actual values visually. Statistically, the RMSE, nRMSE, MBE, nMBE, and MAPE values compared to the predicted and actual values are 0.0025 W, 0.0131%, and 0.0011 W 0.0067% and 0.8121%, respectively.

To show the CFNN-based GA model’s superiority, its performance is compared with that obtained by the classical CFNN, classical FFNN, FFNN-based on GA models. Here, the predicted output power of the PV module using the model mentioned above with the actual data are shown in Fig. 12.

Fig. 12
figure 12

A sample of the predicted output PV power using several models

Based on Fig. 12, it can be noticed that the predicted output power of the PV module using the proposed model is more accurate as it is closer to the actual data curve. To prove that, the statistical error terms are used as listed in Table 2.

Table 2 A comparison of the proposed model with the other used models in terms of statistical error terms and the training and testing time

According to Table 2, it can be noticed that the values of RMSE, nRMSE, MABE, nMBE and MAPE for the proposed model is less than that for the other models. Besides, the training and testing time for the proposed model is faster. Thus, the proposed model can be recommended to model the PV modules’ performance accurately and faster than other models. This will lead to more accurate sizing results or/and control response for PV systems.

To validate the effectiveness of the proposed model, its performance in terms of MAPE compared with some of the research works in the same area. Here, the proposed model compared with perturb and observe (P&O) method with incremental conductance method (ICM) [38], random forests (RFs) model [4], generalized regression artificial neural network (GRNN) [30] and CFNN [30] as listed in Table 3.

Table 3 A comparison of the proposed model with the other research works in terms of MAPE

Based on Table 3, it can be noticed that the proposed model outperforms the above-mentioned models in terms of MAPE. In which, the MAPE of the proposed model is lower by 61.89%, 90.68%, 83.68% and 88.53% than P&O method with ICM, RFs model, GRNN model and CFNN model, respectively. Therefore, the proposed model can perform better than the above-mentioned models in predicting the PV output current in terms of MAPE. Accordingly, the proposed model can recommend for future research works that required the modeling the current of the PV modules. Here, the optimal parameters of GA that used in this paper are listed in Table 4.

Table 4 Optimal parameters of GA

Conclusions

This paper proposed a new prediction model to predict the output power of a PV module. This model was a combination of machine learning and artificial intelligence technique. The CFNN model represents the machine learning technique, and the GA stands for the artificial intelligence algorithm. This combination aimed to improve the accuracy and performance of the CFNN model by optimizing the number of its hidden neurons by the genetic algorithm. The main idea was to secure a minimum RMSE between the predicted and actual data. The proposed model’s performance was evaluated and compared with that obtained by a classical CFNN, classical FFNN, and FFN-based on GA models. This compression was carried out in terms of RMSE, nRMSE, MBE, nMBE, and MAPE and the training and testing time. The results show the proposed model’s superiority as the values of RMSE, nRMSE, MBE, nMBE, and MAPE were 0.0025 W, 0.0131%, 0.0011 W, and 0.0067% and 0.8121%, respectively. Also, its training and testing time was 0.0098 s. and 0.0032 s., which were less than the other models. Accordingly, the proposed model can be recommended to characterize the PV modules’ performance faster and more accurately than the other mentioned models.