Sustainability 17 00648

Download as pdf or txt
Download as pdf or txt
You are on page 1of 30

Article

Optimization of Microgrid Dispatching by Integrating


Photovoltaic Power Generation Forecast
Tianrui Zhang , Weibo Zhao , Quanfeng He * and Jianan Xu

School of Mechanical Engineering, Shenyang University, Shenyang 110044, China; [email protected] (T.Z.);
[email protected] (W.Z.); [email protected] (J.X.)
* Correspondence: [email protected]

Abstract: In order to address the impact of the uncertainty and intermittency of a photo-
voltaic power generation system on the smooth operation of the power system, a microgrid
scheduling model incorporating photovoltaic power generation forecast is proposed in this
paper. Firstly, the factors affecting the accuracy of photovoltaic power generation prediction
are analyzed by classifying the photovoltaic power generation data using cluster analysis,
analyzing its important features using Pearson correlation coefficients, and downscaling
the high-dimensional data using PCA. And based on the theories of the sparrow search
algorithm, convolutional neural network, and bidirectional long- and short-term memory
network, a combined SSA-CNN-BiLSTM prediction model is established, and the atten-
tion mechanism is used to improve the prediction accuracy. Secondly, a multi-temporal
dispatch optimization model of the microgrid power system, which aims at the economic
optimization of the system operation cost and the minimization of the environmental cost,
is constructed based on the prediction results. Further, differential evolution is introduced
into the QPSO algorithm and the model is solved using this improved quantum particle
swarm optimization algorithm. Finally, the feasibility of the photovoltaic power generation
forecasting model and the microgrid power system dispatch optimization model, as well
as the validity of the solution algorithms, are verified through real case simulation experi-
ments. The results show that the model in this paper has high prediction accuracy. In terms
of scheduling strategy, the generation method with the lowest cost is selected to obtain
an effective way to interact with the main grid and realize the stable and economically
Academic Editor: Gaetano Zizzo optimized scheduling of the microgrid system.
Received: 7 November 2024
Revised: 24 December 2024 Keywords: photovoltaic power generation forecast; SSA-CNN-BiLSTM-ATT prediction model;
Accepted: 10 January 2025 cluster analysis; microgrid power scheduling; quantum particle swarm
Published: 15 January 2025

Citation: Zhang, T.; Zhao, W.; He, Q.;


Xu, J. Optimization of Microgrid
Dispatching by Integrating 1. Introduction
Photovoltaic Power Generation
As climate change continues to intensify, the global demand for clean energy is in-
Forecast. Sustainability 2025, 17, 648.
https://doi.org/10.3390/
creasing year by year. Photovoltaic (PV) power generation, an important part of clean
su17020648 energy, has received extensive attention worldwide. By the end of 2023, the global installed
capacity of photovoltaic power generation had exceeded 1300 GW, accounting for about
Copyright: © 2025 by the authors.
Licensee MDPI, Basel, Switzerland.
18% of the global total power generation capacity. China’s installed PV capacity has ranked
This article is an open access article first in the world for many consecutive years, reaching about 500 GW, accounting for 38% of
distributed under the terms and the world’s total installed PV power generation capacity. At the same time, according
conditions of the Creative Commons to the International Renewable Energy Agency (IRENA), the cost of photovoltaic power
Attribution (CC BY) license
generation has fallen by about 85% over the last decade, making it one of the most eco-
(https://creativecommons.org/
nomically competitive forms of energy in many countries. Photovoltaic power generation
licenses/by/4.0/).

Sustainability 2025, 17, 648 https://doi.org/10.3390/su17020648


Sustainability 2025, 17, 648 2 of 30

can convert solar energy into electricity without the need for fuel and does not produce
harmful gases such as carbon dioxide, so photovoltaic power generation has become an
effective way to solve energy shortages and improve the quality of life. Microgrids are a
kind of power system that can achieve self-sufficiency. They consist of distributed power
sources, loads, and energy storage systems, and can realize the efficient use and transfer of
energy. Guaranteeing the stable operation and reliability of photovoltaic power generation
access to a microgrid energy system is an important direction for the future development
of photovoltaic power generation and microgrids [1,2]. Therefore, this paper focuses on
the economic and environmental issues of different types of energy scheduling in micro-
grids, integrates the results of PV power generation prediction, and performs scheduling
optimization of microgrid power system.
As photovoltaic power generation brings significant economic and environmental
benefits, it has received more and more attention, and research on photovoltaic power gen-
eration prediction tends toward machine learning, deep learning, and neural networks [3].
The advantage of the machine learning approach is that it is able to model a wide
range of dynamic processes. In the study of Leva S. (2017) [4], Artificial Neural Network
(ANN) was used for photovoltaic power generation forecasting. The study pointed out
that the accuracy of the historical dataset has a significant impact on the accuracy of the
model. Popular AI models developed by some researchers such as Tan (2020) [5] for RPGP
include Support Vector Machines (SVM). Compared to statistical methods, AI models
have higher prediction accuracy for EPGP. However, these models are based on shallow
architectures, require manual feature engineering, have limited generalization capabilities,
and lead to unstable networks and non-convergence of parameters due to insufficient
EPGP data. Deep learning methods have been widely used in the process of digitization
and intelligent transformation of various industries, and can also be used for photovoltaic
power generation forecasting. Aslam (2021) [6] and others outlined deep learning-based
methods for predicting solar panel and wind turbine power generation. Due to their self-
learning capability, various ANN-based building energy consumption prediction models
have been developed. Kim (2020) [7] found neural network models to be more valuable
and stable than linear regression methods in predicting electricity loads. Optimization
methods have also been introduced in some studies to improve computational efficiency.
For example, Kalliola (2021) [8] et al. developed neural network models to predict real
estate prices, providing solutions for fine-tuning hyperparameters using stochastic search.
Zhou (2021) [9] developed an adaptive hyperparameter tuning model for predicting fuel
consumption of ships. Bayesian optimization was used to select the optimal neural network
structure, support vector machine, minimum absolute contraction, random forest, and
selection operator. However, in practice, photovoltaic power generation is affected by many
environmental stochastic factors, resulting in the collected data possibly containing noise,
missing information, or errors, which leads to an increase in the difficulty of model training
and affects the prediction results. Different deep learning models have different advantages,
so the prediction results of an algorithm are further optimized and improved by establishing
a combined prediction model. Netsanet S (2022) [10] proposed a hybrid method, VMD-
ACO-2N, wherein the raw data are decomposed using variational modal decomposition
(VMD), and the optimization setup is performed through a method involving orthogonal
indices (OIs) and correlation measures. The method was shown to outperform other
algorithms when feature contributions all played a role. Liang L (2023) [11] proposed a
short- and medium-term PV power prediction model based on FC, DT, LSSVR and IWBOA,
with predictions able to be made for time scales of one day ahead and one month ahead.
The computational speed and prediction accuracy of the LSSVR model were improved by
Sustainability 2025, 17, 648 3 of 30

optimizing each independent sub-model through IWBOA. The model is important for the
availability and grid integration benefits of PV power generation.
In summary, traditional machine learning models and statistical approach models still
have limitations in photovoltaic power generation forecasting. There are still problems
such as difficulty in fully capturing data features and low accuracy. However, deep learning
is very effective in feature extraction of data, especially in photovoltaic power generation
forecasting, where deep learning has achieved better results. In the photovoltaic power
generation forecast of distributed multiple stations, a single model has disadvantages, such
as low generalization ability and poor learning ability. In order to improve the efficiency as
well as accuracy of photovoltaic power generation forecasts, this paper constructs a hybrid
neural network photovoltaic power generation forecast model and designs an improved
CNN-BiLSTM model.
The research on microgrid power scheduling is more in the direction of microgrid
systems, distributed energy scheduling, etc. Dhiman G (2020) [12] proposed a novel
hybrid multi-objective algorithm, MOSHEPO, for solving convex and non-convex economic
scheduling and microgrid power scheduling problems. MOSHEPO takes into account many
of the nonlinear characteristics of generators, such as transmission losses, multiple fuels,
valve point loads, and prohibited operation areas, as well as their operating limitations,
to inform the model and improve its suitability for real-world operation. Prasad T N
(2022) [13] proposed a hybrid AC/DC microgrid power management strategy using Droop
control. The scheme uses ANFIS and PID controllers to control microgrids with energy
sources such as PV, wind, and batteries, and achieves operational cost reduction through
an elephant swarm optimization algorithm, which in turn calculates Droop coefficients
to implement an adaptive Droop control strategy. Luo S (2023) [14] proposed a multi-
objective microgrid power scheduling method for optimal output power of distributed
generators. A two-step solution method based on chaotic sinusoidal mapping multi-
objective optimization bat algorithm and fuzzy theoretical set is used to solve the problem.
In summary, renewable energy, represented by wind and solar energy, has been rapidly
developed in the process of the rapid improvement of energy structure. In this paper, we
take advantage of the combination of distributed energy sources in microgrids in order to
improve the ability of microgrids to accept and dispatch renewable energy sources, and
to achieve the complementary integration of multiple types of power sources in order to
maximize the overall benefits.
In this paper, for the uncertainty and intermittency of the photovoltaic (PV) power gen-
eration system, a microgrid scheduling model including PV power generation prediction is
proposed, classifying PV power generation data through cluster analysis, combining Pear-
son’s correlation coefficient and PCA downscaling to analyze the key features, constructing
a combined prediction model based on SSA-CNN-BiLSTM, and introducing an attention
mechanism to improve the prediction accuracy; subsequently, a multi-temporal dispatch
optimization model is established based on the prediction results, and a differential evolu-
tion improvement quantum particle swarm optimization algorithm is introduced to solve
the problem with the objective of optimizing the economic and environmental costs, and
the effectiveness and feasibility of the model and the algorithm are verified through the
simulation of real cases.
The following are the research features and innovations of this paper:
(1) This paper presents an in-depth study on the application of new energy photovoltaic
power generation, and proposes an effective forecasting and scheduling method,
which better solves the imbalance in the distribution of microgrid power resources
due to the volatility of renewable energy production.
Sustainability 2025, 17, 648 4 of 30

(2) In terms of photovoltaic power generation forecast, this paper proposes a neural
network model based on CNN-BiLSTM, which can consider multiple influencing
factors in the process of photovoltaic power generation at the same time to make the
forecasting results more accurate.
(3) This paper introduces the group intelligence algorithm in the prediction model to
optimize the original structure. Sparrow search algorithm is used to optimize the
weights as well as the thresholds of the CNN-BiLSTM neural network to improve the
robustness of the model and to increase the attentional mechanism to improve the
predictive accuracy of the model while reducing the computational cost more, and to
improve the generalization ability of the model.
(4) A microgrid distributed power scheduling model is established by this paper, which
focuses on how to reasonably allocate the weights of economic objectives as well as
environmental objectives in the multi-objective scheduling problem, and introduces
the quantum particle swarm algorithm based on differential evolutionary algorithm
to solve the problem, and constructs an optimization model aimed at minimization of
the system operation cost.

2. Photovoltaic Power Generation Prediction Model Based on Cluster


Analysis and SSA-CNN-BiLSTM-ATT
2.1. Correlation Analysis of Influencing Factors
Photovoltaic power generation harnesses the energy of solar cells by converting
light into electricity. When photons enter a solar cell, their energy is absorbed by the
semiconductor material, exciting electrons to a higher energy state and creating electron–
hole pairs. Driven by the internal electric field of the cell, electrons flow from the N-region
to the P-region, while holes move in the opposite direction, generating an electric current
and effectively transforming light energy into electrical energy. The main influencing
factors of photovoltaic power generation are classified into the time dimension as well as
non-time dimension, which mainly include climatic condition, module type, location of
the power plant and human factors. For meteorological factors, humidity, temperature,
wind direction, wind speed, and air pressure are selected as meteorological parameters in
this paper. For geographic factors, the regional environment of the PV system, geographic
coordinates, and altitude are selected.
In order to quantify the influence of each feature on the PV power, the Pearson correlation
coefficient metric is introduced in this paper. The Pearson correlation coefficient metric can
quantify the influence of irradiance, temperature, wind speed, and humidity, as shown
in Table 1.

Table 1. Value range of Pearson correlation coefficient.

Relevant Relation Degree of Relevance


| Rmn | = 1 Perfect linear correlation | Rmn | ≤ 0.2 extremely weak correlation
Rmn = 0 no linear correlation 0.2 < | Rmn | ≤ 0.4 weak correlation
0 < Rmn < 1 positive correlation 0.4 < | Rmn | ≤ 0.6 moderately relevant
−1 < Rmn < 0 negative correlation 0.6 < | Rmn | ≤ 0.8 strong correlation
0.8 < | Rmn | ≤ 1.0 Highly relevant

The Pearson correlation coefficient is calculated as:

∑lj=1 (m j − m)(n j − n)
R(m, n) = q q (1)
2 2
∑lj=1 (m j − m) ∑lj=1 (n j − n)
Sustainability 2025, 17, 648 Table 1. Value range of Pearson correlation coefficient. 5 of 30

Relevant Relation Degree of Relevance


= 1which Perfect
Rmn in m is thelinear
powercorrelation
generated by the n ≤ 0 .2
R mphotovoltaicextremely weak correlation
power generation mechanism at
= 0 time, mno
R mn one =linear
[m1 , mcorrelation 0.2 < R m n ≤ meteorological
2 , . . . , ml ]; n is the historical
0.4 weakimpact
correlation
factor of the PV
0 < Rmn <1
generation produced 0.4 < R m norganization,
by the input generating
positive correlation ≤ 0.6 n = [n1 , n2 , relevant
moderately . . . , nl ]; l denotes
−1 < Rmn < 0
the number of samples; m is
negative correlation
j the 0.6 < R m n ≤ 0.8
power of the PV plant on day j and m is
strong correlation the jth average
of the historical power of the photovoltaic
0.8 < power m; nj isrelevant
generationHighly
R m n ≤ 1.0 the meteorological
impact factor for day j of the PV plant; n is the jth average of the historical meteorological
In impact
this paper, n of
factorthe the photovoltaic
actual power of a power generation.
photovoltaic power The first with
plant inertia between
wind the two
direction
variables is greater when R(m, n) is closer to −1 or 1.
and wind speed data on 30 March 2018 is chosen. Figure 1 is plotted using the pandas
In this paper, the actual power of a photovoltaic power plant with wind direction and
library in Python. Figure 1a represents the heatmap of Pearson’s correlation coefficients
wind speed data on 30 March 2018 is chosen. Figure 1 is plotted using the pandas library in
containing the features before fixing, while Figure 1b shows the heatmap of Pearson’s co-
Python. Figure 1a represents the heatmap of Pearson’s correlation coefficients containing
efficients after applying the K-Nearest Neighbor (KNN) algorithm to fix the anomalous
the features before fixing, while Figure 1b shows the heatmap of Pearson’s coefficients after
data.
applying the K-Nearest Neighbor (KNN) algorithm to fix the anomalous data.

(a) Before repair

(b) After repair

Figure 1.Figure
Heat 1. Heat
map of map of correlation
correlation coefficient
coefficient of eachofvariable.
each variable.
efficient between the actual irradiance before restoration and the actual pow
of photovoltaic power generation is 0.76. After removing the outliers, the c
Sustainability 2025, 17, 648 efficient improves to 0.88, indicating that the linear correlation between 6 of 30 the
enhanced. In practical PV power prediction tasks, the model is usually
measured
According irradiance
to Figure 1,and
it canpredicted using
be concluded forecasted
that among irradiance.
the multiple In Figure 1
meteorological
the data
factors used,thethe
affecting coefficient
output between
of photovoltaic powerthegeneration,
predicted theirradiance and the PV
Pearson correlation
coefficient between the actual irradiance before restoration and the actual power generation
the generating organization increased from 0.62 to 0.69, an improvement of
of photovoltaic power generation is 0.76. After removing the outliers, the correlation
coefficient improves to 0.88, indicating that the linear correlation between the two is further
2.2. Data Preprocessing
enhanced. Basedprediction
In practical PV power on Fuzzytasks,C-Means Algorithm
the model is usually trained using
measured irradiance and predicted using forecasted irradiance. In Figure 1b, after fixing
Photovoltaic power generation is affected by the day–night turnover, w
the data used, the coefficient between the predicted irradiance and the PV generation of
an obvious organization
the generating cyclic pattern. In order
increased totoimprove
from 0.62 the prediction
0.69, an improvement of 0.07. accuracy, a fu
algorithm is introduced to preprocess the data. By using fuzzy C-mean c
2.2. Data Preprocessing Based on Fuzzy C-Means Algorithm
weather is classified into sunny, rainy, and complex types of weather, and
Photovoltaic power generation is affected by the day–night turnover, which exhibits an
diction models
obvious cyclic areInestablished
pattern. forthe
order to improve these threeaccuracy,
prediction types of weather,
a fuzzy C-meansrespectively
algo-
rithm is introduced to preprocess the data. By using fuzzy C-mean clustering, the weather
2.2.1. Cluster
is classified Analysis
into sunny, of Photovoltaic
rainy, and complex types of Data
weather, and then the prediction models
are established for these three types of weather, respectively.
Three historical similar day datasets are obtained using the fuzzy C-me
2.2.1.
of Cluster Analysis
clustering and ofthePhotovoltaic
prediction Datamodels are trained using the historical d
Three historical similar day datasets are obtained using the fuzzy C-means algorithm
different weather types, respectively. The clustering results of this paper
of clustering and the prediction models are trained using the historical datasets under
Figure
different2, wheretypes,
weather the left graph represents
respectively. before
The clustering resultsclustering,
of this paper the right graph
are shown in re
clustering,
Figure 2, wherethe
the Y-axis
left graphrepresents the clustering,
represents before PV power, the graph
the right X-axis represents
represents after the d
clustering, the Y-axis represents the PV power, the X-axis represents the data series, the
yellow squares indicate the centroids of the data clustering results, and 0, 1,
yellow squares indicate the centroids of the data clustering results, and 0, 1, 2 in the graph
correspond to rainy,
correspond to rainy, complexcomplex weather
weather and and respectively.
sunny days, sunny days, respectively.

Figure 2. Data clustering result graph.


Figure 2. Data clustering result graph.

The principle of the fuzzy clustering algorithm is described as follow


that there is a dataset X = { x1 , x 2 , x 3 ,  , x n } , the data in dataset X are first
C fuzzy sub-datasets: { A i
i = 1, 2,  , C } , 0 ≤ C ≤ n , where Ci is the clustering ce
Sustainability 2025, 17, 648 7 of 30

The principle of the fuzzy clustering algorithm is described as follows. Assuming


that there is a dataset X = { x1 , x2 , x3 , . . . , xn }, the data in dataset X are first classified into
C fuzzy sub-datasets: { Ai |i = 1, 2, . . . , C }, 0 ≤ C ≤ n, where Ci is the clustering center of
class i and the affiliation degree of class i samples is Uij . The target dependent variable in
the fuzzy C-means algorithm is shown in Equation (2):

C n
∑ ∑ uijm
2
J (U, V ) = x j − ci (2)
i =1 j =1

where U is the fuzzy C classification of the dataset X, and V = {v1 , v2 , . . . vn } is the clustering
center. m is the weighting factor for the degree of affiliation, and fuzzy clustering is hard
C-means clustering when m = 1. m is usually taken as 1.5–2.5, and in this paper, m = 2.
The constraints are:
c
∑ uij = 1, j = 1, 2, . . . , n (3)
i =1
c n
∑ u ji = 1, 0 < ∑ u ji < n (4)
i =1 j =1

The Euclidean distance between the data object and the obtained cluster center vi is:

dij = x j − vi (5)

J(U, V) is a function that is used in the algorithm to calculate the sum of squares of
the errors between the original data objects and the known cluster centers, and its value
reflects the closeness and correlation between the data objects and the cluster centers. When
the value of J(U, V) is smaller, the degree of closeness of the clusters is higher. Set C = 1;
the smaller the value of C, the higher the degree of closeness of the clusters.
The following is the main computational procedure of the fuzzy C-means algorithm:
(1) Initialization of the clustering center, V = {v1 , v2 , . . . vn }.
(2) Calculate the different affiliation matrices:

1
uij = (6)
!2
c xi − c j m

k =1 ∥ xi − c k ∥

(3) Update the clustering center:

∑iN=1 uijm xi
cj = (7)
∑iN=1 Uijm

(4) Repeat (2) and (3) until Equation (2) converges and reaches the maximum number
of iterations.

2.2.2. Photovoltaic Data Preprocessing


In this paper, the PV power plant data used were obtained from a portion of a PV
power plant with a maximum installed capacity of 50.00 MW in a region of China. This
paper uses the data provided by this photovoltaic power generation station to carry out
a prediction study on photovoltaic power generation. The data preprocessing process is
shown in Figure 3 below.
y 2025, 17, x FOR PEER REVIEW

Sustainability 2025, 17, 648 8 of 30

Start

Checking data continuity

Checking abnormal data

Delete missing data

Data normalisation

End
Figure 3. Data preprocessing flow chart.
Figure 3. Data preprocessing flow chart.
The specific flow of the preprocessing step for the data used in this paper is shown below:
(1) Check the continuity of the data and mark missing or duplicate data points. The times-
tamp format can be used to calculate the time difference between two consecutive points.
(2) The specific flow of the preprocessing step for
Remove anomalous data based on the maximum power value.
(3) Remove consecutive missing power data.
below:
(4) Normalize the data to remove unit differences between different factors.
Numerical normalization refers to the uniform mapping of data of different magni-
(1) Check the continuity of the data and mark m
tudes to the same order of magnitude to eliminate the effect of their respective magnitudes.
The minimum–maximum method is calculated as shown in Equation (8):
timestamp format can be used to calculate the
x−x min
x∗ = (8)
tive points. x −x
max min

The normalized value is x ∗ , the maximum value is X


(2) Remove anomalous data based on the maximu
and the minimum value is
max
X . The mean value method is calculated as shown in Equation (9):
min

(3) Remove consecutive x∗ =


x − x missing power data.
mean
(9)
x var
(4) ∗ Normalize the data to remove unit differences
x denotes the normalized value, xmean denotes the mean value of x, and xvar denotes
the variance of x.
Numerical normalization refers to the uniform
tudes to the same order of magnitude to eliminate
tudes. The minimum–maximum method is calculat
Sustainability 2025, 17, 648 9 of 30

2.2.3. Data Dimensionality Reduction Based on Principal Component Analysis


After going through data preprocessing, there is still a lot of unnecessary information in
the data. Therefore, in this paper, the data are downscaled through feature selection as well
as feature transformation. The main principle of the Principal Component Analysis (PCA)
method is to turn high-dimensional variables into low-dimensional variables, while ensuring
that the original variables retain a good representation. This allows for the data transformation
of the overall sample of the dimensionality reduction process [15].
(1) The core idea of PCA is a matrix compression algorithm that converts the original
matrix of n × m into a lower dimensional matrix of n × k.
(2) Inputs X1 , X2 , · · · , Xm in the model of PCA are the original variables, and the target
variables Y1 , Y2 , · · · , Yk are obtained after PCA and satisfy k < m. The original sample
is the matrix of n × m:

 
x11 x12 ··· x1m
 x21

x22 ··· x2m 

X=
 .. .. .. ..  (10)
 . . . . 

xn1 xn2 ··· xnm

xi = ( xi1 , x2i , · · · , xmi ) T , i = 1, 2, · · · , m (11)

Let W be the transformation matrix, then PCA combines the original variables linearly as:

 Y1 = w11 x1 + w21 x2 + · · · + wm1 x1

Y21 = w12 x2 + w22 x2 + · · · + wm2 x2 (12)

Y = w x + w x + · · · + w x
m 1m m 2m m mm m

 
w11 w12 ··· w1m
 w21

w22 ··· w2m 

W=
 .. .. .. ..  (13)
 . . . . 

wm1 wm2 ··· wmm

Summarize to obtain Y = (Y1 , Y2 , · · · , Ym ) = W T and Yi = w1i x1 + w2i x2 + wmi xi , i =


1, 2, · · · , m.
In this paper, we require that Yi be uncorrelated with Yj = (i ̸= j, i, j = 1, 2, · · · , m) and

the variance decrease successively, then cov Yi , Yj = 0 and the variance D (Yi ) > D (Yi=1 ).
Let C be the covariance matrix of X = ( x1 , x2 , · · · , xm ) with eigenvalues λi (i = 1, 2, · · · , m),
λ1 ≥ λ2 ≥ · · · ≥ λ m ,
D (Yi ) = λi , i = 1, 2, · · · , m (14)

D (Y1 ) ≥ D (Y2 ) ≥ · · · ≥ D (Ym ) (15)


m m
∑ D(Yi ) =λ1 + λ2 + · · · + λm = ∑ D(x) (16)
i =1 i =1
λk
The kth variance contribution is defined as ∑im=1 λi
.

(3) Steps of PCA algorithm: Let the original data X be a matrix of n × m.


xij − X i
Zero-mean the original data X, i.e., xij∗ = σi , where X i is the mean of Xi and σi is
the variance.
(a) Find the eigenvalues, eigenvectors of the covariance matrix.
(b) Ranking the eigenvalues and selecting the appropriate k components, the resulting
principal components are:
Sustainability 2025, 17, 648 10 of 30

Yi = WiT xi , i = 1, 2, · · · , m (17)

The variance contribution of each principal component was derived from the principal
component analysis and the results are shown in Table 2.

Table 2. Variance contribution rate of each component.

Cumulative Variance
Principal Component Variance Contribution (%)
Contribution (%)
1 33.378 33.379
2 15.965 49.347
3 13.076 62.418
4 9.34 71.768
5 7.08 78.858
6 5.131 83.992
7 4.514 88.507
8 3.495 92.006
9 2.778 94.778
10 1.936 96.716
11 1.491 98.204
12 1.456 99.661
13 0.245 99.907
14 0.084 99.991
15 0.006 99.998
16 0.002 100
17 2.778 94.778

As can be seen from the results in Table 2, the data matrix composed of seven principal
components represents the original data sample. The variance contribution ratio obtained
through PCA calculation can determine whether the downscaled data contain important
information of the original data sample. When the cumulative variance contribution ratio
reaches 85% and above, it indicates that the dimensionality reduction matrix has contained
most of the information from the original data sample, and subsequent data analysis and
processing can be carried out.

2.3. Based on SSA-CNN-BiLSTM-ATT Predictive Model Construction


2.3.1. Sparrow Search Algorithm
Sparrow search algorithm (SSA) is mainly inspired by sparrow foraging behavior and
anti-predator behavior [16]. The algorithm is parameterized by the number of iterations
G, number of populations, percentage of discoverers, fitness function, and the dimension
of parameters to be optimized; this indicates how many parameters need to be optimized.
In this case, the CNN-BiLSTM algorithm is optimized for the number of iterations, the
learning rate, the number of outputs from the convolutional layer filter, the number of
hidden nodes in the BiLSTM layer, so the dimension is 4.
In this paper, SSA introduces a neural network combinatorial model; the specific
calculation process is shown in Figure 4.
ility 2025, 17, x FOR PEER REVIEW
Sustainability 2025, 17, 648 11 of 30

Start

Setting SSA Parameters

Optimised parameter
initialisation

Calculate function fitness

Sorting to select the iterative


optimum

No
Better than the
last optimum?

Yes

Update the parameters one by


Updating the optimal value
one according to the algorithm

Meet accuracy No
requirements or
meet iteration
counts?
Yes

End

Figure 4. Flow chart of optimization parameters of SSA algorithm.


Figure 4. Flow chart of optimization parameters of SSA algorithm.
2.3.2. Convolutional Neural Network
CNN has a wide range of applications in image classification, recognition and predic-
2.3.2.
tionConvolutional
[17]. In the applicationNeural
scenario ofNetwork
this paper, one-dimensional time series data need to
be processed. The one-dimensional convolutional computational expression is:
CNN has a wide range of applications in image classification,
N
diction [17]. In the application
xkl = f ( ∑ xscenario
l −1
i
l
∗ ωik + bkl of
) this paper, one-dimensio
(18)
i =1
need to be processed. The one-dimensional convolutional computati
xkl denotes the kth convolution of the ith layer; f is the activator; N denotes the number
N
xk = f ( xi ∗ ωik + bk )
of convolutional mappings of the input data; ∗ lis the convolutionl −step; l
1 ωik lis the weight
l of

i =1
l
x k denotes the kth convolution of the ith layer; f is the activator
Sustainability 2025, 17, 648 12 of 30

the ith operation of the kth convolution kernel of the ith layer; and bkl is the offset of the kth
convolution kernel corresponding to the ith layer.
In this paper, the maximum pooling method is used with the expression x̂kl = max( xkl :
xk+r−1 ), which is the maximum value of the vector xkl to the vector xkl +r−1 . The sequence x
l

is divided into consecutive vectors with window size r. The maximum pooling operation is
performed on each vector to obtain the maximum feature sequence.

2.3.3. BiLSTM Neural Network


The BiLSTM network enables each input data point to pass through the LSTM network
in two directions, positive and negative, respectively, and the past and future hidden states
can be recursively fed back to achieve a bidirectional loop [18]. LSTM (Long Short-Term
Memory Network) successfully solves the gradient vanishing problem of RNN (Recurrent
Neural Network) by employing three selective transfer mechanisms and cell state units.
LSTM is able to retain the model memory of the input patterns, which overcomes the
shortcomings of RNN in dealing with long-term dependency problems. This makes LSTM
perform well in predictive modeling of temporal data with significant advantages for
long-term memory [19,20]. In summary, LSTM has more advantages than RNN in temporal
data prediction modeling, can effectively solve the long-term dependency problem, and
achieve the long-term memory function.


 f t = σ (W f x t + A f h t − 1 + b f )

it = σ(Wi xt + Ai ht−1 + bi )




c′ = tanh(W x + A h

+b )
t c t c t −1 c
′ (19)

 c t = f t ∗ c t −1 + i t ∗ c t

ot = σ (Wo xt + Ao ht−1 + bo )





 ht = ot ∗ tanh(ct )

Wf , Wi , Wc and Wo denote the input weight vectors, while Af ,Ai , Ac and Ao denote the
upper output weight vectors together with bf , bi , bc and bo denoting the bias vectors, σ de-
notes the S-shape function used for gating, while the tanh function is used for generating a

new storage unit cell ct due to its fast convergence.
→ →
 H t = LSTM( xt , H t−1 )

← ←

H t = LSTM( xt , H t−1 ) (20)

 ′
 → ←
Ht = αt H t + β t H t + λt

→ ←
H t−1 and H t−1 are the hidden layer conditions of the LSTM network and inverse
→ ←
conditions at the moment t − 1; H t and H t are the hidden layer conditions of the LSTM
network and inverse conditions at the moment t; α is the forward propagation unit hidden

layer output weights; β is the backward propagation unit hidden layer output weights; Ht
→ ←
is the total state output of BiLSTM network output, which consists of H t and H t hidden
layer states.

2.3.4. Attention Mechanism


The main principle of the attention mechanism is the automatic weighted average
calculation [21,22]; the principle is shown in Figure 5.
Sustainability 2025, 17, x FOR PEER REVIEW
Sustainability 2025, 17, 648 13 of 30

ht −1 ht …… ht +i

Similarity weight calculation

st −1 st …… st +i

Softmax normalisation

at −1 at … at +i

h∗ + + …… +
ht −1 ht … ht +i

Figure 5. Structure diagram of attention mechanism.


Figure 5. Structure diagram of attention mechanism.
hi is the output data of the implicit layer, αi is the weight value of the input data, and
h final
h∗ is the is result obtained
the output from
data ofthe
thecalculation
implicit with the α
layer, following
is theformula:
weight value of the inp
i i

and h is the final result obtained from
k the calculation with the following formu

h = ∑ αi hi k
(21)

The attention mechanism uses a scoring function


i =1
h∗
= toαcalculate
i hi α and h∗ . The larger i
i =1
the value of the scoring function, the higher the correlation. The correlation of the scoring
The attention mechanism uses a scoring function to calculate α i
function is calculated as si , which is the normalization function to obtain the weight value
and h
αi . Let the sum of the weight values of all hi be 1, i.e., ∑ αi = 1. The formula for αi is shown
larger the value of the scoring function, the ihigher the correlation. The correlatio
in (22):
scoring function is calculatedαas s if tmax
i = so (si ) is the normalization function
, which (22) to ob

weight value α . Let the sum of the weight values of all h i be 1, i.e.,
The cosine similarity method, vector dot product method and neural network method
α =
were used to evaluatei the function to calculate the correlation using the following formulas: i
i
Vector dot product method:
formula for αi is shown in (22):
si = f ( hi , h ∗ ) = hi · h ∗ (23)
αi = soft max ( si )
Cosine similarity methods:
The cosine similarity method, vector ∗dot product method and neural n
hi · h
method were used to evaluatesi = fthe h∗ ) =
(hi ,function tohcalculate
∗∥
(24) the fo
the correlation using
∥hi ∥∥
formulas:
Neural network approach:
Vector dot product method:
si = f ( hi , h ) = hi ⋅ h∗
si = f (hi , h∗ ) = MLP(hi · h∗∗ ) (25)

Cosine similarity methods:


hi ⋅ h ∗
si = f ( hi , h ∗
)= ∗
sign the similarity weight of the PV data at each moment. The attention mechan
capture more valuable information by assigning corresponding weights to the PV
Sustainability 2025, 17, 648 14 of 30
each moment according to its importance to the prediction results. Therefore, in
enable BiLSTM to make full use of the differences in PV data, this paper combines
withInthe attentionpower
photovoltaic mechanism to forecast
generation photovoltaic
forecasting, the attentionpower generation.
mechanism is able to
assign the similarity weight of the PV data at each moment. The attention mechanism can
capture more valuable information by assigning
2.3.5. SSA-CNN-BiLSTM-ATT-Based corresponding
Photovoltaic weights
Power to the PV data
Generation at
Forecasting
each moment according to its importance to the prediction results. Therefore, in order to
The photovoltaic power generation forecast process proposed in this paper
enable BiLSTM to make full use of the differences in PV data, this paper combines BiLSTM
in Figure
with 6, is mainly
the attention divided
mechanism intophotovoltaic
to forecast the following steps:
power generation.
(1) Pearson’s correlation coefficient is used to analyze the actual operating dat
2.3.5. SSA-CNN-BiLSTM-ATT-Based Photovoltaic Power Generation Forecasting Process
arrays, determining the correlation coefficients between the variables. Heat m
The photovoltaic power generation forecast process proposed in this paper, shown in
Figurethen plotted
6, is mainly based
divided onthethe
into correlation
following steps: coefficients to visualize the relations
tween the
(1) Pearson’s variables.
correlation coefficient is used to analyze the actual operating data of PV
(2) arrays,
Fuzzydetermining
C-means cluster analysis
the correlation classifies
coefficients the historical
between photovoltaic
the variables. Heat maps power
are then plotted based on the correlation coefficients to visualize
tion sequence samples into three categories: sunny weather changes, cloudy the relationships
between the variables.
changes, and rainy weather changes.
(2) Fuzzy C-means cluster analysis classifies the historical photovoltaic power generation
(3) sequence
To identify the optimal component parameter k, the historical PV power gen
samples into three categories: sunny weather changes, cloudy weather
sequence
changes, andundergoes
rainy weather decomposition.
changes. Variational modal decomposition is ap
(3) Toeach weather
identify type, component
the optimal assumingparameter
k modal k, components
the historicalexist for slow
PV power weather con
generation
sequence undergoes decomposition. Variational modal decomposition
(4) Empirical direct observation divides the k modal components derived is applied to from
each weather type, assuming k modal components exist for slow weather conditions.
into high-frequency and low-frequency components.
(4) Empirical direct observation divides the k modal components derived from step (3)
(5) into
A two-layer prediction
high-frequency framework
and low-frequency is designed. A CNN model is used for t
components.
(5) Afrequency part, andframework
two-layer prediction a BiLSTMis model
designed.is used
A CNN formodel
the high-frequency
is used for the low- part. In
improve the model performance, the model parameters are optimized using
frequency part, and a BiLSTM model is used for the high-frequency part. In order
to improvesparrow
proved the modelalgorithm,
performance, the the
and model parameters
attention are optimized
mechanism is using the
introduced so
improved sparrow algorithm, and the attention mechanism is introduced so that the
model can pay more attention to the key features.
model can pay more attention to the key features.
(6) By
(6) Byfeeding
feeding real-time
real-time environmental
environmental data intodata into the
the trained trained
neural neural
network, network, th
the model
predicts
predicts the the high-frequency
high-frequency and low-frequency
and low-frequency components
components separately separately an
and combines
bines the predictions to arrive at the predicted value of PV power generation
the predictions to arrive at the predicted value of PV power generation.

Input

Data normalisation

Pearson related
analysis

Test set Test set

Convolutional layer: Training Models


ReLu activation
function
CNN
Pooling Layer: Global
Maximum Pooling Output
Layer

Hidden layer: Sigmoid


activation function BiLSTM
Attention mechanism

SSA parameter Predictive


optimisation modelling

Figure6. Flow
Figure chart of
6. Flow photovoltaic
chart power generation
of photovoltaic prediction
power model based
generation on SSA-CNN-BiLSTM-ATT.
prediction model based on SS
BiLSTM-ATT.

2.4. Evaluation of Photovoltaic Power Generation Forecasting Models


Sustainability 2025, 17, 648 15 of 30

2.4. Evaluation of Photovoltaic Power Generation Forecasting Models


2.4.1. Mechanism Analysis of Photovoltaic Power Generation Prediction Error Generation
The PV power prediction process is composed of three links: input data, prediction
model, and result processing. Among them, the input data and the prediction model will
generate errors. The errors in the input data are mainly from the forecasting errors in
Numerical Weather Prediction (NWP), mainly due to the following reasons:
(1) The NWP model is a time- as well as space-discretized continuum time-space method,
which is bound to have some errors.
(2) There are anomalies in the observed data, which will further generate errors when
assimilated into the NWP model.
(3) The atmospheric system is very complex, and the use of partial differential equa-
tions to describe its system is highly sensitive to the existence of errors in the initial
conditions, but the errors will gradually accumulate with the passage of time.

2.4.2. Indicators for Evaluating Projected Results


The performance of the photovoltaic power generation forecast model is quantita-
tively analyzed by choosing the error assessment indices with reference to science [23].
The prediction accuracy of the prediction model was tested by using MAPE and RMSE.
MAPE can evaluate the prediction ability of the prediction model, and RMSE can evaluate
the degree of dispersion of the prediction model, and also, the average absolute error
MAE and R-Squared can be used as the prediction model evaluation index in this paper.
The specific formulas are, respectively:

1 N ht − ht
MAPE = ∑ ′ × 100% (26)
N j =1 ht
v
u N
u1 ′ 2
RMSE = t ∑ (ht − ht ) (27)
N j =1

1 N ′

N j∑
MAE = ht − ht (28)
=1
n ′ 2
∑ ( ht − ht )
j =1
R2 = 1 − n (29)
′ 2
∑ ( ht − ht )
j =1

The real and expected generation of solar power at time t is denoted by ht and ht ,
respectively, and N is the number of samples.

3. Distributed Power Scheduling Model for Microgrids


3.1. Improved Quantum Particle Swarm Algorithms
Quantum particle swarm optimization (QPSO) is based on the principle of quantum
mechanics and improves the search efficiency by using the position and velocity information
of particles [24]. However, QPSO often struggles to escape the local optimal solution
during the optimization process, especially in the later stages, resulting in limited overall
performance [25]. To overcome this problem, the idea of differential evolution is introduced
in QPSO. Differential evolution effectively optimizes the solution of the problem through
competition and collaboration among individuals, enabling the algorithm to better explore
the global optimal solution space. The introduction of differential evolution allows each
Sustainability 2025, 17, x FOR PEER REVIEW 16

Sustainability 2025, 17, 648 16 of 30


allows each individual to adjust its position by exchanging information with other
viduals, thus increasing the probability of jumping out of the local optimal solution
individual to adjust its position by exchanging information with other individuals, thus
combining
increasingthe
the idea of differential
probability of jumpingevolution, theoptimal
out of the local improved QPSO
solution. not only the
By combining overcome
limitations of the later
idea of differential stages,the
evolution, but also significantly
improved QPSO not only improves
overcomes thethe
overall optimization
limitations of
ity, making it perform better in solving complex optimization problems. Asit a resul
the later stages, but also significantly improves the overall optimization ability, making
perform better in solving complex optimization problems. As a result, the improved QPSO
improved QPSO performs more efficiently and reliably in realizing the global optima
performs more efficiently and reliably in realizing the global optimal solution, showing
lution, showing
stronger stronger
adaptability adaptability and robustness.
and robustness.
The
Theflow
flowof
of the improved
the improved QPSO
QPSO algorithm
algorithm is shown
is shown in Figurein7. Figure 7.

Setting algorithm
parameters: M,D,T

Input system load and tariff


data, PPV,PWT,P SB

Initialise the population and


randomly assign PMT,P FC

Adjustment in scheduling
strategies and
constraintsPMT,P FC,P C

Calculation of mbest

Whether the conditions for Output plans and optimal


termination are met adaptation values are least costly

Update Particle Position

Evaluating the cost of


microgrids for particles
f[xid(t)]

The best place to update an


individual

Update the global best


position

Figure
Figure Improved QPSO
7. 7.Improved QPSOflowchart.
flowchart.
3.2. Microgrid Scheduling Model
3.2.3.2.1.
Microgrid Scheduling
Scheduling Model Model
A microgrid is
3.2.1. Scheduling a small power system consisting of a variety of decentralized distributed
Model
energy sources, such as wind power, photovoltaics, and fuel cells. In this study, the
A microgrid is a small power system consisting of a variety of decentralized dis
distributed generator is selected as a distributed energy system consisting of wind turbine,
uted energy sources,
photovoltaic, suchfuel
microturbine, as wind power,
cell and battery.photovoltaics, and fuel cells. In this study
distributed generator
(1) Objective functionis selected as a distributed energy system consisting of wind tur
photovoltaic, microturbine, fuel cell and battery.
The objective of microgrid economic and environmental scheduling is to minimize
(1) theObjective function
comprehensive cost. Under the premise of satisfying the normal operation of each
microgrid power source, their outputs are reasonably arranged. For microgrids, in order
The objective of microgrid economic and environmental scheduling is to mini
the comprehensive cost. Under the premise of satisfying the normal operation of each
crogrid power source, their outputs are reasonably arranged. For microgrids, in ord
ensure that the system operates efficiently while minimizing negative impacts on th
vironment, it is necessary to find a balance between costs and benefits.
C sum = C 1 + C 2
Sustainability 2025, 17, 648 17 of 30

to ensure that the system operates efficiently while minimizing negative impacts on the
environment, it is necessary to find a balance between costs and benefits.

Csum = C1 + C2 (30)

C1 is the operating cost, including fuel cost, maintenance cost, depreciation cost; in
addition, there is a need for a comprehensive assessment of the costs incurred by microgrids
in buying power from and selling power to the main grid. C2 is the environmental cost, i.e.,
the cost of dealing with polluted gases.

T N N ADCi
C1 = ∑ ∑ (∆TCiCG ( H ) + ∆TKi Pi ( H ) + ∑ P (H)
H =1 i =1 i =1 Pi,max a f i i
T T
(31)
+ ∑ ∆TPc ( H )Cgrid ( H ) + ∑ ∆TKbat | Pbat ( H )|)
H =1 H =1

T is the microgrid operation period; N is the number of controllable elements; ∆T is time


period; CiCG is the fuel cost of unit i in period H; Ki is the maintenance cost of unit i; Pi ( H ) is
the output of unit i in period H; a is a constant; ADCi is the annual depreciation cost of unit i;
fi is the capacity factor; Pc ( H ) is the purchased and sold power from the main grid and the
microgrid in period H; Pbat ( H ) is the charging and discharging power of the battery in period
H; and Kbat is the charging and discharging cost of the battery in period H.
The components of environmental costs are listed below:

K K K
C2 = ∑ αk λk1 PMT ( H ) + ∑ αk λk2 PFC ( H ) + ∑ αk λk3 CGP( H ) (32)
k =1 k =1 k =1

αk is the external discounted cost of type k emissions; λkn is the emission factor, with
1, 2, and 3 denoting Micro Turbine, Fuel Cell, and the main microgrid, respectively; K
is the type of emission (NOx, SO2, or CO2); PMT(H) and PFC(H) are the output power,
respectively, at H. Table 3 summarizes the external discounted costs and emission factors
based on publicly available data from local governments.

Table 3. External discounted cost and emission factor.

External Discount Emission Factor (kg/MW)


Typology
Cost (CNY/kg) Micro Turbine Fuel Cell Primary Network
NOx 8.00 0.2 0.014 1.6
SO2 6.00 0.0036 0.0027 1.8
CO2 0.023 724 489 889

The relevant parameter settings for each unit in the microgrid system are shown in Table 4.

Table 4. Operating unit parameters.

Wind Micro Storage


Module Type Photovoltaic Fuel Cell
Turbine Turbine Battery
Installation cost (CNY/kW) 23,750.00 66,500.00 18,500.00 52,710.00 —
Maintenance cost
0.02941 0.00962 0.00963 0.02911 0.0452
factor
Depreciation cost
0.71 2.793 0.0111 0.251 —
factor
Upper limit power (kW) 10.00 10.00 65.00 40.00 20.00
Life span (years) 10.00 20.00 15.00 10.00 5.00

(2) Binding conditions


Sustainability 2025, 17, 648 18 of 30

Battery capacity limitation constraints:

−20 ≤ PSB ≤ 20 (33)

Battery charging and discharging limits:

Pbat ( H ) = Pdis ( H ) − Pch ( H ) (34)

0 ≤ Pdis ( H ) ≤ Pdis , max( H ) × Udis ( H ) (35)

0 ≤ Pch ( H ) ≤ Pch , max( H ) × Uch ( H ) (36)

Udis ( H ) + Uch ( H ) = 1 (37)


T
∑ |Uch ( H ) − Uch ( H − 1)| ≤ Nbat (38)
i =1

The energy balance constrains the battery at the beginning and end of the period:

T
∑ Pbat ( H ) = 0 (39)
i =1

PSB is the output of the battery, Pdis ( H ) and Pch ( H ) are the discharging power and
charging power of the battery in H-cycle, respectively; Udis ( H ) and Uch ( H ) denote the
state of the battery in H-cycle, respectively, with 1 being the charging state and 0 being
the discharging state; Pdis , max( H ) are the upper limit of the discharging power and the
upper limit of the charging power of the battery in H-time period; Nbat is the upper limit of
the battery’s charging and discharging times; and Pbat ( H ) is the algebraic sum of battery
charging and discharging power.
Output Limits:
Pi , min( H ) ≤ Pi ( H ) ≤ Pi , max( H ) (40)

Constraints on the rate of climb:

up
− Ridown ∆T ≤ PiCG ( H ) − PiCG ( H − 1) ≤ Ri ∆T (41)

CG and PCG are the


CG is the amount of power generated by the controllable unit; Pi,min i,max
down up
limits of the output of the unit i, respectively; and Ri and Ri are the downward and
upward climb rates of the unit i, respectively.
System constraints:

N M
∑ PiCG ( H ) + ∑ PiRG ( H ) + PC ( H ) = PL ( H ) (42)
i =1 i =1

RG is the renewable unit power generation; PC ( H ) is the microgrid power purchase


and sale; power is sold to the main grid for PC ( H ) > 0 and purchased from the main grid
for PC ( H ) < 0; and PL ( H ) denotes the load of the microgrid system.

3.2.2. Dispatch Strategy


Distributed generators in microgrids usually use renewable energy sources, whereas
distributed generators in conventional grids use energy sources such as fuel generators.
In view of the above characteristics of microgrid energy, this paper proposes the following
strategies. Wind turbine power generation should first satisfy the winter heat load, and
then satisfy the small electrical load if necessary. When microturbine, PV and wind power
generation cannot satisfy the full electrical load, the algorithm proposed in this paper will
Sustainability 2025, 17, 648 19 of 30

allow the
Sustainability 2025, 17, x FOR PEER REVIEW batteries to be discharged progressively under high load conditions to19avoid of 31
system overload and to satisfy the load demand. The algorithm will consider selling the
Sustainability 2025, 17, x FOR PEER REVIEW
power to the main grid. If the electrical load cannot be met within the allowable discharge 19 of 31

range of the
algorithm battery,
will choose thethe
algorithm will
less costly perform
option a cost comparison.
to supply After comparing
power or interact the
with the main
cost of
grid. fuel
The cell power
specific generation, micro-turbine
decision-making power
process is shown generation
in Figure 8. and power trading, the
algorithmwill
algorithm willchoose
choosethe theless
less costly
costly option
option to supply
to supply power
power or interact
or interact withwith the main
the main grid.
grid.specific
The The specific decision-making
decision-making
Heat load demand processprocess is shown
is shown in Figure
in Figure 8. 8.

Heat load demand

Does the microturbine meet Yes


the thermal load
Does the microturbine meet Yes
the thermal
Noload

No
Whether microturbines, photovoltaics Yes
and wind power can meet
the entire electrical load
Whether microturbines, photovoltaics Yes
and wind power can meet
No load
the entire electrical

No
Whether the permissible discharge Yes
range of the battery meets
the electrical load or not
Whether the permissible discharge Yes
range of the battery meets
Noor not
the electrical load
Compare the cost of generating electricity
(microturbines, fuel cells, purchase
No and sale of
electricity) and choose the least costly method of
Comparegenerating
the cost of electricity.
generating electricity
(microturbines, fuel cells, purchase and sale of
electricity) and choose the least costly method of
Interaction scheme with
generating the main grid
electricity.

Figure 8.Interaction
Microgrid scheduling
scheme strategy.
with the main grid

FigureBased
Figure on the basic
8.8. Microgrid
Microgrid data,strategy.
scheduling
scheduling this paper obtains the cost curves of power generation from
strategy.
microturbines and fuel cells through MATLAB R2021a, as shown in Figures 9 and 10. Af-
Based
Basedon onthe
thebasic data,
basic thisthis
paper obtains the cost curves of power generation from micro-
ter comparing the cost ofdata,
fuel power paper obtains
generation, the cost curves
microturbine of power
power generation
generation from
and elec-
turbines and fueland
microturbines cellsfuel
through
cells MATLAB
through R2021a, asR2021a,
MATLAB shown inasFigures
shown 9 in
and 10. After
Figures 9 comparing
and 10. Af-
tric power business, the power generation method is determined. The specific analyses
the cost
ter shown of
comparingfuel power
the costgeneration, microturbine power generation and electric power business,
are in Table 5. of fuel power generation, microturbine power generation and elec-
the power generation method is determined. The specific analyses are shown in Table 5.
tric power business, the power generation method is determined. The specific analyses
are shown in Table 5.

Figure 9.
Figure Microturbine power
9. Microturbine power cost
cost curve.
curve.

Figure 9. Microturbine power cost curve.


Sustainability2025,
Sustainability 2025,17,
17,648
x FOR PEER REVIEW 20 of 31
20 of 30

Figure 10. Fuel


Figure 10. Fuel cell
cell generation
generation cost
cost curve.
curve.

Table5.5.Comparative
Table Comparativecost
costanalysis.
analysis.

Phase Phase
Cost Comparisons Cost Comparisons AnalysisAnalysis
Low periods C FCJ Low
> Cperiods of
BUY , C SALE
CFCJ > CBUY , CSALE
Fuel cells do Fuel cells do not generate electricity
not generate electricity
electricity Microturbines do not generate electricity after
of electricity C > C , C
consumption MT J Microturbines do not generate
BUY SALE electricity
encountering after
thermal encountering
loads
C MTJ > C BUY , C SALE Fuel cellsthermal
do not generate electricity after encountering
consumption Flat periods of CSALE < C FCJ < C BUY loads
an electrical load
electricity Fuel cells do not generate electricity
Microturbines after encountering
do not generate electricity after an
Flat periods C SALE <consumption
C FCJ < C BUY C MT J > CBUY , CSALE
encountering
electrical load thermal loads
of electricity CFCJ < CBUY , CSALE Fuel cell full power generation
Peak periods of Microturbines do not generate electricity after encountering
consumption C MTJ > electricity
C BUY , C SALE C MT J < 48 > CBUY , CSALE
Microturbines do not generate electricity after
consumption
thermal loads
encountering thermal loads
CSALE < C MT J > 48 < CBUY Micro-turbine power generation to meet electrical loads
C FCJ < C BUY , C SALE Fuel cell full power generation
Peak periods
Microturbines do not generate electricity after encountering
of electricity C M TJ < 48 > C BUY , C SALE
In the following operation, it will rely mainly onthermal the batteryloadsfor charging and discharg-
consumption
C SALEing< Cmanagement.
MTJ
> 48 < C BUY If the electrical load demand
Micro-turbine of the
power system and
generation the charging
to meet electrical demand
loads
of the batteries cannot be met, the microgrid will purchase power from the main grid to
compensate for the shortfall.
In the following operation, Conversely, when
it will rely the microgrid
mainly on the batterygenerates more power
for charging andthan
dis-
itcharging
needs, the excess power will be sold to the main grid.
management. If the electrical load demand of the system and the charging de-
mand of
(1) Low periodsthe batteries cannot beconsumption
of electricity met, the microgrid will purchase power from the main
grid to compensate for the shortfall. Conversely, when the microgrid generates more
In microgrid systems, the cost of generating electricity from microturbines and batter-
power than it needs, the excess power will be sold to the main grid.
ies is usually higher than the price of purchasing electricity directly from the grid, within
(1) Low periods of electricity consumption
their allowable output. In such cases, microturbines and batteries are not used for power
In microgrid
generation. systems,
The primary the costofofthe
function generating
batteries electricity
is to meet from microturbines
the electrical load ofand the bat-
mi-
teries is usually higher than the price of purchasing electricity
crogrid and ensure its proper operation. However, when the batteries cannot meet the directly from the grid,
within their
demand, the allowable
microgrid output.
needs toIn such cases,
purchase microturbines
electricity from theand main batteries
grid. Inareordernottoused for
ensure
power generation. The primary function of the batteries is
the economy and sustainability of microgrids, the operational efficiency of microturbinesto meet the electrical load of
the microgrid
and and ensure
storage batteries must itsbe
proper
optimizedoperation. However,
to achieve the when
best costthe of
batteries
powercannotgenerationmeet
the demand, the microgrid needs to purchase electricity from
and energy utilization efficiency. Therefore, optimizing the operational efficiency of thesethe main grid. In order to
ensure the
devices economy
is crucial andlong-term
for the sustainability of microgrids,
viability of microgrids. the operational efficiency of micro-
turbines and storage batteries must be optimized to achieve the best cost of power gener-
(2) Flat periods of electricity consumption
ation and energy utilization efficiency. Therefore, optimizing the operational efficiency of
theseIndevices
a microgrid system,
is crucial for the thelong-term
cost of generating
viability of electricity
microgrids. from batteries is lower than
the price of purchasing electricity, although it is higher than the price of selling electricity in
(2) Flat periods of electricity consumption
the range of its output power. Therefore, the system prioritizes the use of battery discharge
In a microgrid system, the cost of generating electricity from batteries is lower than
to meet the electrical demand. If the electrical load exceeds the discharge capacity of the
the price of purchasing electricity, although it is higher than the price of selling electricity
batteries or the batteries are in a state of charge, the fuel cells will start generating electricity.
in the range of its output power. Therefore, the system prioritizes the use of battery dis-
When the fuel cell is also unable to meet the demand, the microgrid will purchase power
charge to meet the electrical demand. If the electrical load exceeds the discharge capacity
Sustainability 2025, 17, 648 21 of 30

from the main grid. In summary, when the microgrid operates, the system prioritizes
the use of battery discharge to meet the demand, and if it is insufficient, the fuel cell will
be activated, and finally, the power will be purchased from the main grid to ensure the
economy and reliability of the system.
(3) Peak periods of electricity consumption
In microgrid systems, the cost of generating electricity from fuel cells is always lower
than the price of purchasing and selling electricity, making them a cost-effective option in
all cases. In contrast, the generation cost of a micro gas turbine depends on the magnitude
of its output power. When the output power is lower than 48 kW, the cost of electricity
generated by MGTs is higher than the cost of purchasing electricity from the grid, and thus
not economical, while when the output power is higher than 48 kW, the cost of electricity
generated is lower than the cost of purchasing electricity, and thus becomes economical.
The 48 kW threshold becomes a key equilibrium point for MGTs, which determines the
threshold of their economic performance. Based on the characteristics of this balance point,
the micro gas turbine generates electricity only when its output power exceeds 48 kW to
satisfy the electrical load demand and the battery charging demand. At the same time, in
order to maintain the economy and efficiency of the system, the micro gas turbine does not
sell excess power to the main grid in this case, but focuses on meeting internal demand.
Taken together, the microgrid system is able to achieve the best economic efficiency
under different power demands by rationally utilizing fuel cells and micro gas turbines.
Among them, fuel cells show high economy and efficiency under all circumstances due to
their generation costs, which are always lower than the prices of purchased and sold elec-
tricity, while micro gas turbines optimize their operating costs and benefits by generating
electricity when the output power exceeds 48 kW, thus providing a flexible and economical
generation option for micro grids. It can be seen that microgrids are able to realize the
economy and efficiency of energy supply under different load conditions through scientific
and reasonable equipment scheduling and power management.

4. Practical Case Studies


4.1. Example Simulation of Photovoltaic Power Generation Prediction
In this paper, we select the public typical environmental data of a city in China, a photo-
voltaic power generation forecast for the period between January 2020 and December 2020,
and the solar performance data characteristics obtained through the above screening, with
a temporal resolution of 15 min, which is chosen for comparison with other photovoltaic
power generation forecasting methods in this paper.
Because photovoltaic power is not generated by the photovoltaic system at night,
the 0 power in the nighttime data is deleted from it, and the data are stored between
6:00 and 19:00 every day for analysis. In this paper, first, PV data are processed using
principal component analysis and cluster analysis algorithm, and secondly, the Pearson
correlation coefficient is used to analyze the filtered data, and the samples are input into the
CNN-BiLSTM network, and the parameters are determined after several rounds of training.
And in this paper, we will optimize the number of neurons, and using the SSA algorithm,
Figure 11 shows the fitness curve of the SSA algorithm-optimized CNN-BiLSTM model
compared with other algorithms. The number of convolutional kernels is 32 and 64 with a
step size of 2. All data are filtered and spread through a pooling layer.
Input the processed data, then select three typical days: sunny, complex weather and
rainy days, as prediction days and validate the accuracy of the prediction model using
MAPE, RMSE, MAE and R2 as the evaluation metrics of the model.
The following computer configurations were applied in the case study: Python 4.0,
rainy days, as prediction days and validate the accuracy of the prediction model using
TensorFlow 2.7.0 programming, processor Intel (R) Core (TM) i7-7700HQ (Santa Clara,
MAPE, RMSE, MAE and R2 as the evaluation metrics of the model.
CA, USA), and simulation software PyCharm 2022.2.3. The implementation of SSA-CNN-
The following computer configurations were applied in the case study: Python 4.0,
Sustainability 2025, 17, 648 BiLSTM short-term photovoltaic power generation forecast is based on the attention
22 of 30
TensorFlow 2.7.0 programming, processor Intel (R) Core (TM) i7-7700HQ (Santa Clara,
mechanism.
CA, USA), and simulation software PyCharm 2022.2.3. The implementation of SSA-CNN-
BiLSTM short-term photovoltaic power generation forecast is based on the attention
mechanism.

Figure 11. The fitness curve of CNN-BiLSTM-ATT prediction model was optimized by different algorithms.
Figure 11. The fitness curve of CNN-BiLSTM-ATT prediction model was optimized by different
algorithms.
The following computer configurations were applied in the case study: Python 4.0, Tensor-
Flow 2.7.0
Figure programming,
11. The processor
fitness curve Intel (R) Core (TM)
of CNN-BiLSTM-ATT i7-7700HQ
prediction model(Santa Clara, CA,byUSA),
was optimized and
different
In this section, the SSA-CNN-BiLSTM-Attention neural network based on SSA-CNN-
simulation software PyCharm 2022.2.3. The implementation of SSA-CNN-BiLSTM short-term
algorithms.
BiLSTM-Attention neural network will be used to forecast photovoltaic power generation
photovoltaic power generation forecast is based on the attention mechanism.
forecast for the next 500 data points, and to compare the effectiveness of the SSA-CNN-
Inthis
In thissection,
section,thetheSSA-CNN-BiLSTM-Attention
SSA-CNN-BiLSTM-Attentionneural neuralnetwork
networkbased
basedononSSA-CNN-
SSA-CNN-
BiLSTM-ATT model proposed in this paper, the SSA-CNN-BiLSTM Optimization Algo-
BiLSTM-Attention neural
BiLSTM-Attention neural network
network will
willbebeused
usedto toforecast
forecastphotovoltaic
photovoltaicpower
powergeneration
generation
rithm model, the CNN-BiLSTM Combined Neural Network model, and the BiLSTM- ATT
forecast for
forecast for the
the next
next 500
500 data
data points,
points,and
andto tocompare
comparethe theeffectiveness
effectivenessofofthe
theSSA-CNN-
SSA-CNN-
model, to verify the effectiveness of the proposed model in this paper. Figure 12 shows
BiLSTM-ATT model
BiLSTM-ATT model proposed
proposed inin this
this paper,
paper, the
the SSA-CNN-BiLSTM
SSA-CNN-BiLSTMOptimization
OptimizationAlgo-
Algo-
the iterative curve of different algorithms’ function fitness values, from which it can be
rithm model, the CNN-BiLSTM Combined Neural Network model,
rithm model, the CNN-BiLSTM Combined Neural Network model, and the BiLSTM- ATT and the BiLSTM- ATT
seen that the combined algorithm proposed in this paper has higher accuracy and conver-
model, to verify the
model, the effectiveness
effectivenessofofthetheproposed
proposedmodelmodelinin
this paper.
this Figure
paper. 12 shows
Figure the
12 shows
gence speed than other algorithms.
iterative curve of different algorithms’ function fitness values, from which
the iterative curve of different algorithms’ function fitness values, from which it can be it can be seen
that the
seen thatcombined
the combinedalgorithm proposed
algorithm proposedin this
in paper has higher
this paper accuracy
has higher and convergence
accuracy and conver-
speed than other algorithms.
gence speed than other algorithms.

Figure 12. Convergence diagram of different algorithms.

In 12.
thisConvergence
Figure12.
paper, the diagram
model parameters
of different
are investigated, and after many trials and ad-
different algorithms.
algorithms.
Figure Convergence diagram of
justments, this paper comes up with the optimal hyperparameter settings, as shown in
TableIn6. this paper, the model parameters are investigated, and after many trials and adjustments,
In this paper, the model parameters are investigated, and after many trials and ad-
this paper comes up with the optimal hyperparameter settings, as shown in Table 6.
justments, this paper comes up with the optimal hyperparameter settings, as shown in
Table 6.
Table 6. Parameter settings.

Typology Parameters
Activation function ReLU function
Number of iterations 50
Learning rate 0.001
Fine-tuning learning rate 0.1
Regularization parameter 0.5
Sustainability 2025, 17, 648 23 of 30

Table 7 shows the hyperparameter values for each model, including num epochs
(number of iterations), batch size, Lr (learning rate), and Fc (number of nodes in the fully
connected layer). In CNN-BiLSTM, SSA-CNN-BiLSTM-ATT, and SSA-CNN-BiLSTM pre-
diction models, hidden1 and hidden2 represent the hidden nodes in the BiLSTM layers,
respectively; in LSTM models, hidden1 and hidden2 represent the first and second hid-
den nodes in the first and second layers, respectively,; in the BiLSTM-Attention model,
hidden1 and hidden2 represent the hidden nodes in the first and second BiLSTM layers,
respectively; and in the SSA-CNN-BiLSTM-Attention prediction model, there are two more
hyperparameters, i.e., the size of CNN convolutional kernels size is 3. The values of these
hyperparameters are obtained by iterative testing and tuning.

Table 7. The value of each model hyperparameter.

Fully
Number of Population Hidden Node
Modelling Learning Rate Connected
Iterations size 1, 2
Node
CNN-BiLSTM 50 20 0.001 10 10
BiLSTM-ATT 60 10 0.001 10 10
SSA-CNN-
100 20 0.001 10 10
BiLSTM
SSA-CNN-
150 20 0.002 10 20
BiLSTM-ATT

The training set data are imported into the power generation prediction network
to obtain the initial measurement data and error series, and the SSA-CNN-BiLSTM-ATT
network is built to predict the errors, and the final prediction results are obtained by
summing the predicted results. The prediction results of three typical weather days are
selected according to the clustering results and compared with the prediction results of SSA-
CNN-BiLSTM, CNN-BiLSTM and BiLSTM-ATT. Class a is sunny days, class b is complex
days, and class c is rainy days, and the comparison of the errors of different models for
the three different weather types is shown in Table 8, in order to visually represent the
prediction accuracy of this paper’s algorithms.

Table 8. Error result of prediction model.

Error SSA-CNN- SSA-CNN-


Weather Types CNN-BiLSTM BiLSTM-ATT
Parameter BiLSTM-ATT BiLSTM
a 1.0225 2.2689 3.1825 5.7866
MAPE b 1.5562 2.1935 2.8462 2.1464
c 1.3673 2.3472 2.5347 2.6372
a 3.5292 4.2110 4.5231 8.4481
RMSE b 1.8258 2.3490 2.6374 3.0254
c 3.2021 3.6725 3.8354 5.5128
a 2.5150 2.9021 3.1852 8.1065
MAE b 0.9986 1.2703 1.5632 1.8591
c 2.5876 2.7354 2.9756 5.5128
a 0.9839 0.9770 0.9536 0.8586
R2 b 0.9650 0.9420 0.9235 0.9038
c 0.9845 0.9728 0.9568 0.9286

The data in Table 8 show that the BiLSTM-ATT neural network has the worst prediction
effect; its RMSE is as high as 10.4481, and R2 values are all minimum values. SSA-CNN-
BiLSTM-ATT prediction model has the best performance, its RMSE in the three weather
categories are 3.5292, 1.8258, and 3.2021, and its R2 values are 0.9839, 0.9650, and 0.9845, with
the lowest MAPE and MAE. SSA-CNN-BiLSTM-ATT has the smallest MAPE and MAE among
the models compared to SSA-CNN-BiLSTM, CNN-BiLSTM, and BiLSTM-ATT, with the highest
improvement in RMSE of 5.8%, and an increase in R2 of 1.27%, respectively (Figure 13).
weather categories are 3.5292, 1.8258, and 3.2021, and its R2 values are 0.9839, 0.9650, and
0.9845, with the lowest MAPE and MAE. SSA-CNN-BiLSTM-ATT has the smallest MAPE
and MAE among the models compared to SSA-CNN-BiLSTM, CNN-BiLSTM, and
Sustainability 2025, 17, 648 BiLSTM-ATT, with the highest improvement in RMSE of 5.8%, and an increase in24Rof2 of 30
1.27%, respectively (Figure 13).

(a) MAPE diagram (b) RMSE diagram

(c) MAE diagram (d) R2 diagram

Figure 13. Bar chart of error for different


different weather types under
under different
different forecast
forecast models.
models.

From
From the
the above
above analysis,
analysis, it
it can
can be
be seen
seen that
that the
the first
first three
three models
models predict
predict better
better in
in
sunny
sunny weather,
weather,but
butin
incomplex
complexweather
weatherandandrainy
rainyweather
weather conditions,
conditions,thethe
prediction effect
prediction ef-
of
fectthe
ofSSA-CNN-BiLSTM-ATT
the SSA-CNN-BiLSTM-ATT prediction modelmodel
prediction proposed in thisin
proposed paper
this is obviously
paper due to
is obviously
the other prediction models.
due to the other prediction models.

4.2. Simulation of a Microgrid Distributed Energy Dispatch Example


4.2. Simulation of a Microgrid Distributed Energy Dispatch Example
The microgrid modelled in this paper specifically includes microturbine power gen-
The microgrid modelled in this paper specifically includes microturbine power gen-
eration (65 kw), photovoltaic power generation (10 kw), fuel cell (40 kw), wind turbine
eration (65 kw), photovoltaic power generation (10 kw), fuel cell (40 kw), wind turbine
power generation (10 kw), and storage battery (20 kw). The loads in the case of this paper
power generation (10 kw), and storage battery (20 kw). The loads in the case of this paper
include residential loads and industrial loads, and the scheduling time is 1 day and 25
Sustainability 2025, 17, x FOR PEER REVIEW theofunit
31
include residential loads and industrial loads, and the scheduling time is 1 day and the
time interval is 1 h. The microgrid power system of this paper is shown in Figure 14.
unit time interval is 1 h. The microgrid power system of this paper is shown in Figure 14.

Figure 14. Microgrid power system.


Figure 14. Microgrid power system.

The data related to the cases in this paper are shown in Figures 15–17. Table 9 shows
The data related to the cases in this paper are shown in Figures 15–17. Table 9 shows
the data of purchased and sold electricity prices in different periods.
the data of purchased and sold electricity prices in different periods.
Figure14.
Figure 14.Microgrid
Microgridpower
powersystem.
system.

Sustainability 2025, 17, 648 Thedata


datarelated
relatedto
tothe
thecases
casesin
inthis
thispaper
paperare
areshown
shownininFigures
Figures15–17.
15–17.Table
Table99shows
shows
25 of 30
The
thedata
the dataof
ofpurchased
purchasedandandsold
soldelectricity
electricityprices
pricesin
indifferent
differentperiods.
periods.

Figure15.
Figure Dailyheat
15.Daily heatload
loadand
andelectricity
electricityload
loadin
in winter.
winter.
winter.

Sustainability 2025, 17, x FOR PEER REVIEW 26 of 31


Figure16.
Figure Winter daily
16.Winter daily wind
wind speed
windspeed and
speedand temperature.
andtemperature.
temperature.

Figure 17. Winter


Figure 17. Winter light
light intensity.
intensity.

Table9.9.Electricity
Table Electricityprice
pricelevels
levelsat
atdifferent
differentpoints
pointsin
intime.
time.
Mode Period Tariff PriceTariff
(CNY/kWh)
Price
Mode Period
Electricity
Peak period (10:30–14:30, 18:30–20:30) (CNY/kWh)
0.83
Regular period (7:30–9:30, 15:30–17:30, 21:30–22:30) 0.49
purchase Peak period
Bottom (10:30–14:30,
period (23:30–06:30) 18:30–20:30) 0.17 0.83
Electricity
Regular period
Peak period (7:30–9:30, 15:30–17:30, 21:30–22:30)
(10:30–14:30, 18:30–20:30) 0.65 0.49
purchase
Electricity sale Regular period (7:30–9:30, 15:30–17:30, 21:30–22:30) 0.38
Bottom period (23:30–06:30)
Bottom period (23:30–06:30) 0.13
0.17
Peak period (10:30–14:30, 18:30–20:30) 0.65
Electricity sale Regular period (7:30–9:30, 15:30–17:30, 21:30–22:30) 0.38
Bottom period (23:30–06:30) 0.13

Based on the micro-power system operation strategy above, the output of each micro-
power source on a typical winter day as well as the purchased and sold power of the
micro-grid can be known, as shown in Figure 18. Figure 18 shows the power curve of each
purchase
Bottom period (23:30–06:30) 0.17
Peak period (10:30–14:30, 18:30–20:30) 0.65
Sustainability 2025, 17, 648 Electricity sale Regular period (7:30–9:30, 15:30–17:30, 21:30–22:30) 0.38
26 of 30
Bottom period (23:30–06:30) 0.13

Based on
Based on the
the micro-power
micro-power systemsystem operation
operation strategy
strategy above,
above, thethe output
output ofof each
each micro-
micro-
power source
power source onon aa typical
typical winter
winter day
day as as well
well asas the
the purchased
purchased and and sold
sold power
power of of the
the
micro-grid can be known, as shown in Figure 18. Figure 18 shows the power
micro-grid can be known, as shown in Figure 18. Figure 18 shows the power curve of each curve of each
micro power
micro power source
source forfor 24
24 h.
h. Because
Because winter
winter is
is the
the heating
heating period,
period, the
the micro
micro turbine
turbine first
first
generates electricity to meet the heat load, and from Figure 18, it can be seen that
generates electricity to meet the heat load, and from Figure 18, it can be seen that the micro the micro
turbine can
turbine can satisfy
satisfy the
the heat
heat load
load of
of aa typical
typical day
day inin winter
winter within
within thethe range
range ofof the
the output
output
power. Then, wind and photovoltaic power generation are fully utilized,
power. Then, wind and photovoltaic power generation are fully utilized, and when the and when the
power supply
power supplyisisstill
stillinsufficient
insufficienttotomeetmeet the
the electrical
electrical load,
load, battery
battery andandfuelfuel
cellcell genera-
generation,
tion, subsequent generation from the microturbine, or the purchase of
subsequent generation from the microturbine, or the purchase of power from the main grid power from the
main
are grid are considered
considered to meet thetoload.
meet the load.

Figure 18. Curve


Figure 18. Curve of
of microgrid
microgrid generation.
generation.
Sustainability 2025, 17, x FOR PEER REVIEW 27 of 31
Figure
Figure 19
19 shows
showsaascheme
schemeofofhow
howthethemicrogrid
microgridinteracts
interactswith
withthe main
the grid,
main which
grid, is
which
divided into
is divided thethe
into following three
following time
three periods:
time periods:

Figure 19. Microgrid interaction curve.


Figure 19. Microgrid interaction curve.
(1) Low periods of electricity consumption (23:30–06:30)
(1) Low periods of electricity consumption (23:30–06:30)
Between 1:30 and 4:30, microturbine’s output exceeds thermal load requirements,
Between 1:30 and 4:30, microturbine’s output exceeds thermal load requirements,
causing battery discharge and excess power sold to the main grid. From 5:30 to 6:30,
causing battery discharge and excess power sold to the main grid. From 5:30 to 6:30, com-
combined microturbine, battery, wind, and photovoltaic generation surpasses the thermal
bined microturbine, battery, wind, and photovoltaic generation surpasses the thermal
load, but is insufficient to charge batteries, necessitating grid power purchase. Between
load, but is insufficient to charge batteries, necessitating grid power purchase. Between
23:30 and 00:30, the microturbine, wind, and photovoltaic output falls short of electrical
23:30 and 00:30, the microturbine, wind, and photovoltaic output falls short of electrical
load, requiring battery recharge.
load, requiring battery recharge.
(2) Flat periods of electricity consumption (07:30–09:30, 15:30–17:30, 21:30–22:30)
(2) Flat periods of electricity consumption (07:30–09:30, 15:30–17:30, 21:30–22:30)
At 07:30, 08:30, 09:30, and 17:30, the combined output from wind, fuel cell, and mi-
croturbine precisely matches electrical load and battery power requirements, eliminating
the need for grid power sales. Conversely, at 15:30, 16:30, 21:30, and 22:30, sole fuel cell
generation proves insufficient to meet electrical load and battery charging demands, ne-
Sustainability 2025, 17, 648 27 of 30

At 07:30, 08:30, 09:30, and 17:30, the combined output from wind, fuel cell, and
microturbine precisely matches electrical load and battery power requirements, eliminating
the need for grid power sales. Conversely, at 15:30, 16:30, 21:30, and 22:30, sole fuel
cell generation proves insufficient to meet electrical load and battery charging demands,
necessitating grid power purchase.
(3) Peak periods of electricity consumption (10:30–14:30, 18:30–20:30)
In the microgrid system, the generation and power demand at different time periods
are as follows. At 10:30, 11:30, 12:30, and 18:30, the fuel cells fully generate power, the
batteries are discharged, and the microgrid sells excess power to the main grid. At 13:30
and 14:30, although the fuel cells are generating at full capacity, the total generation from
the units is still insufficient, and the microgrid needs to purchase power from the main grid
to make up the shortfall. At 19:30 and 20:30 in the evening, the fuel cells do not generate
enough power and the microturbine meets the heat load demand after generating more
than 48kW. In summary, the microgrid balances the power demand and supply through
the synergistic operation of fuel cells and microturbines, as well as the purchase or sale of
power, depending on the time period and load conditions.
In this study, we compare the performance of three algorithms, namely, improved
QPSO, standard QPSO and PSO, on the economic and environmental scheduling prob-
lem of microgrids. Some of the parameter settings of the three algorithms were kept
consistent to ensure the accuracy of the comparison results. The study was conducted
for 230 iterations and the cost was recorded every five generations to obtain a total of
41 datasets. Subsequently, the differences in the costs of the three algorithms were analyzed
using Friedman’s test with the initial assumption that there is no significant difference
in scheduling costs among the three algorithms. The actual running results are shown
in Table 10. Through iterative and statistical tests, this study analyzes the performance
difference between the improved QPSO and the other two algorithms in terms of microgrid
scheduling cost.

Table 10. Friedman test results.

Name of Algorithm Average Rankings


PSO 2.85
QPSO 2.02
Improved QPSO 1.12

The initial and late performance of these three algorithms is analyzed based on the
above results.
Figure 20 shows that the PSO algorithm has the highest sensitivity to the initial data
and the remaining two algorithms have relatively low sensitivity to the initial data. The
standard deviation is derived by calculating the cost data from generation 1–20 and the
results are as follows. Standard QPSO is 13.4775, PSO is 4.9380, and improved QPSO is
5.8169. This indicates that in the pre-iteration period, the PSO algorithm has the least
volatility and performs the most consistently, improved QPSO is the second most volatile,
and standard QPSO has the most volatility and the highest sensitivity to the initial data. It
is concluded that the PSO algorithm performs the most stably in the pre-iteration period,
the improved QPSO is second and the standard QPSO has the largest volatility.
searching for an optimal solution at this stage. This performance suggests that the im-
proved QPSO algorithm has a greater ability to better disengage from the local optimal
Sustainability 2025, 17, 648 solution and successfully enter the global optimal solution at a later stage. 28 of 30

Figure 20. Performance comparison of algorithms.


Figure 20. Performance comparison of algorithms.
From Table 11 and Figure 21, it can be concluded that the standard Quantum Particle
Swarm Optimization (QPSO) algorithm tends to stabilize at generation 34, while the Particle
Swarm Optimization (PSO) algorithm reaches a steady state at generation 45. However, the
improved QPSO algorithm only stabilizes in generation 52 and is still actively searching
for an optimal solution at this stage. This performance suggests that the improved QPSO
algorithm has a greater ability to better disengage from the local optimal solution and
successfully enter the global optimal solution at a later stage.

Table 11. Algorithm iteration result.

Improved
Number of Iterations QPSO PSO
QPSO
1 1478.53 1496.1404 1499.975
5 1475.13 1492.835 1497.8886
10 1470.49 1477.8428 1494.6328
15 1465.49 1467.2558 1489.274
20 1465.43 1466.5655 1489.0882
25 1465.4 1466.0593 1488.829
30 1465.38 1466.3064 1488.7039
35 1465.37 1466.30439 1488.6686
40 1465.32 1466.3038 1488.6327
Sustainability 2025, 17, x FOR PEER REVIEW 45 1465.24 1466.3037 1488.5629
29 of 31
50 1465.08 1466.3037 1488.5631
55 1464.97 1466.3037 1488.5631
60–230 (stable value) 1464.97 1466.3037 1488.5631

Figure 21. Comparison of algorithms in the later stage.


Figure 21. Comparison of algorithms in the later stage.
Figure 21 shows the convergence points for three sets of data, 1466.0037 (standard
QPSO), 1465.6831iteration
Table 11. Algorithm (PSO), and 1464.9660 (improved QPSO). These data further demonstrate
result.

Improved
Number of Iterations QPSO PSO
QPSO
1 1478.53 1496.1404 1499.975
5 1475.13 1492.835 1497.8886
Sustainability 2025, 17, 648 29 of 30

that the improved QPSO algorithm is capable of obtaining better solutions with better
convergence results than the standard QPSO and PSO algorithms. This performance im-
provement not only proves the significant advantages of the improved QPSO in algorithm
optimization, but also demonstrates its efficiency and reliability in dealing with complex
system problems.
The improved QPSO algorithm performs more rationally and efficiently in the envi-
ronmental and economic operation of microgrid systems. This improvement allows the
QPSO algorithm to better balance the energy production and consumption of the system
during the optimization of microgrids, reducing energy consumption and operating costs
while improving environmental benefits. By adopting the improved QPSO algorithm,
the microgrid system can realize the optimal economic and environmental operation status
and give full play to its role in sustainable development.
Overall, the improved QPSO algorithm performs more effectively than the standard
QPSO and PSO algorithms in solving the microgrid scheduling problem. It not only has a
significant improvement in optimization efficiency and accuracy, but also shows superiority
in economy and environmental protection. The improved QPSO has broad prospects for
future microgrid applications and provides strong support and a new approach for the
optimization of microgrid systems.

5. Conclusions
Accurate PV power forecasting is essential for improving the reliability of microgrid
power systems, ensuring safe and stable operation, and achieving economic dispatch. This
paper proposes an SSA-CNN-BiLSTM-Attention model to enhance prediction accuracy
through step-by-step optimization of data preprocessing, model construction, and training.
The model considers the operating characteristics of distributed power sources, establishes
an economic and environmental protection model for microgrids, and uses an improved
QPSO algorithm to solve the microgrid power generation scheduling problem. Test results
demonstrate that the combined SSA-CNN-BiLSTM-Attention neural network outperforms
other algorithms in prediction accuracy, while the improved QPSO algorithm effectively
addresses the scheduling problem with a focus on economic and environmental goals.
However, there are still areas for improvement. Future research could incorporate spatial
correlation analysis of neighboring power stations to further enhance prediction accuracy,
address the challenges of the SSA-CNN-BiLSTM-Attention model under complex weather
conditions, and expand to the economic and environmental scheduling of multiple micro-
grids, exploring more efficient optimization methods to improve algorithm performance
and accuracy.

Author Contributions: Conceptualization, T.Z.; methodology, T.Z., W.Z., Q.H. and J.X.; software,
W.Z. and Q.H.; validation, T.Z.; formal analysis, T.Z. and W.Z.; investigation, W.Z.; data curation,
T.Z., W.Z. and J.X.; writing—original draft preparation, T.Z., W.Z., Q.H. and J.X.; writing—review
and editing, W.Z.; visualization, W.Z.; funding acquisition, T.Z. All authors have read and agreed to
the published version of the manuscript.

Funding: This study was supported by the Liaoning Provincial Education Science 14th Five-Year
Plan (grant JG22DB480) and the Liaoning Provincial Department of Education Basic Research Projects
for Colleges and Universities (grant LJ212411035026).

Institutional Review Board Statement: Not applicable.

Informed Consent Statement: Not applicable.

Data Availability Statement: Data are contained within the article.

Conflicts of Interest: The authors declare no conflicts of interest.


Sustainability 2025, 17, 648 30 of 30

References
1. Cao, R.; Tian, H.; Li, D.; Feng, M.; Fan, H. Short-Term Photovoltaic Power Generation Prediction Model Based on Improved Data
Decomposition and Time Convolution Network. Energies 2023, 17, 33. [CrossRef]
2. Abdellatif, A.; Mubarak, H.; Ahmad, S.; Ahmed, T.; Shafiullah, G.M.; Hammoudeh, A.; Abdellatef, H.; Rahman, M.M.; Gheni, H.M.
Forecasting Photovoltaic Power Generation with a Stacking Ensemble Model. Sustainability 2022, 14, 11083. [CrossRef]
3. Wei, X.; Wang, M. Research on Data Model and Integration Technology of New Energy Power System. In Proceedings of the
2017 4th International Conference on Information Science and Control Engineering (ICISCE), Changsha, China, 21–23 July 2017;
pp. 1135–1139. [CrossRef]
4. Leva, S.; Dolara, A. Analysis and Vlidation of 24 Hours Ahead Neural Network Forecasting of Photovoltaic Output Power.
Math. Comput. Simul. 2017, 131, 1325–1340. [CrossRef]
5. Tan, Z.; De, G.; Li, M. Combined Electricity Heat-cooling-gas Load Forecasting Model for Integrated Energy System Based on
Multi-task Learning and Least Square Support Vector Machine. Clean. Prod. 2020, 248, 119252–119263. [CrossRef]
6. Aslam, S.; Herodotou, H.; Mohsin, S.M. A Survey on Deep Learning Methods for Power Load and Renewable Energy Forecasting
in Smart Microgrids. Renew. Sustain. Energy Rev. 2021, 144, 524–536. [CrossRef]
7. Kim, M.K.; Kim, Y.-S. Predictions of Electricity Consumption in a Campus Building Using Occupant Rates and Weather Elements
with Sensitivity Analysis: Artificial Neural Network vs. Linear Regression. Sustain. Cities Soc. 2020, 62, 515–530. [CrossRef]
8. Kalliola, J.; Kapočiūtė-Dzikienė, J.; Damaševičius, R. Neural Network Hyperparameter Optimization for Prediction of Real Estate
Prices in Helsinki. PeerJ Comput. Sci. 2021, 7, 434–444. [CrossRef] [PubMed]
9. Zhou, T.; Hu, Q.; Hu, Z. An Adaptive Hyper Parameter Tuning Model for Ship Fuel Consumption Prediction under Complex
Maritime Environments. J. Ocean. Eng. Sci. 2021, 5, 260–265. [CrossRef]
10. Netsanet, S.; Zheng, D.; Zhang, W.; Teshager, G. Short-Term PV Power Forecasting Using Variational Mode Decomposition
Integrated with Ant Colony Optimization and Neural Network. Energy Rep. 2022, 10, 8. [CrossRef]
11. Liang, L.; Su, T.; Gao, Y.; Qin, F.; Pan, M. FCDT-IWBOA-LSSVR: An Innovative Hybrid Machine Learning Approach for Efficient
Prediction of Short-To-Mid-Term Photovoltaic Generation. J. Clean. Prod. 2023, 385, 135716. [CrossRef]
12. Dhiman, G. MOSHEPO: A Hybrid Multi-Objective Approach to Solve Economic Load Dispatch and Micro Grid Problems.
Appl. Intell. 2020, 50, 119–137. [CrossRef]
13. Prasad, T.N.; Devakirubakaran, S.; Muthubalaji, S.; Srinivasan, S.; Kamel, S. Power Management in Hybrid ANFIS PID Based
AC–DC Microgrids with EHO Based Cost Optimized Droop Control Strategy. Energy Rep. 2022, 8, 15081–15094. [CrossRef]
14. Luo, S.; Guo, X. Multi-Objective Optimization of Multi-Microgrid Power Dispatch under Uncertainties Using Interval Optimiza-
tion. J. Ind. Manag. Optim. 2023, 19, 823–851. [CrossRef]
15. Li, S.; Chen, X.; Yin, L.; Zhang, F.; Wu, P.; Zhao, S.T. Evaluation and Research of Photovoltaic Power Generation Model Considering
Climate Change. Acta Energiae Solaris Sin. 2022, 43, 79–84. [CrossRef]
16. Peng, O.; Ren, T.; Wang, Y. Short-term Wind Power Prediction by Optimizing Deep Learning Network Hyper-Parameters Based
on ISSA. Smart Power 2023, 51, 31–38+52.
17. Huang, X.; Li, Q.; Tai, Y.; Chen, Z.; Liu, J.; Shi, J.; Liu, W. Time series forecasting for hourly photovoltaic power using conditional
generative adversarial network and Bi-LSTM. Energy 2022, 246, 123403. [CrossRef]
18. Kim, T.Y.; Cho, S.B. Predicting residential energy consumption using CNN-LSTM neural networks. Energy 2019, 182, 72–81.
[CrossRef]
19. Zhang, X.; Shang, J.; Yu, G. Bearing Fault Diagnosis Based on Attention for Multi-Scale Convolutional Neural Network [J/OL].
J. Jilin Univ. Eng. Technol. Ed. 2023, 1–10. [CrossRef]
20. Yao, Z.; Lu, Z.; Li, C. Improved CEEMDAN-PSO-BiLSTM Model for Short-term Passenger Flow Prediction at Bus Stops.
J. Beijing Jiaotong Univ. 2023, 47, 74–80.
21. Sun, H.; Li, F. Photovoltaic Hot Spot Recognition Based on Attention Mechanism. Acta Electron. Sin. 2023, 44, 453–459. [CrossRef]
22. Zhou, H.; Bai, H.; Cai, Z. Container Quota Optimization Algorithm Based on GRNN and LSTM. Acta Electron. Sin. 2022, 50,
366–373.
23. Qu, W.; Chen, G.; Zhang, T. An adaptive noise reduction approach for remaining useful life prediction of lithium-ion batteries.
Energies 2022, 15, 7422. [CrossRef]
24. Kang, L.; Zhang, X.; Oleg, K. SLSL-QPSO: Quantum-behaved particle swarm optimization with short-lived swarm layers.
SoftwareX 2023, 24, 101536. [CrossRef]
25. Zhu, X.T.; Xu, B. Power short-term load forecasting based on QPSO-SVM. Adv. Mater. Res. 2012, 591, 1311–1314. [CrossRef]

Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual
author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to
people or property resulting from any ideas, methods, instructions or products referred to in the content.

You might also like