1. Introduction
With the development of society, the global demand for energy is increasing rapidly [
1]. The increasing consumption of primary energy can bring a series of environmental problems, such as air pollution, global warming, and resource depletion [
2]. Some studies have suggested that 40% of global energy consumption and 50% of global greenhouse gas emissions are related to buildings [
3]. Therefore, expanding the use of renewable energy in buildings is of great significance in addressing the environmental crisis, and many governments have adopted ambitious policies [
4,
5,
6]. With solid policy support, the electricity from solar photovoltaic (PV) increased by a record 179 TWh and exceeded 1000 TWh total in 2021 worldwide, demonstrating that solar PV generation has become the largest source of renewable energy after wind [
7]. Many private sectors are investing in distributed solar PV, and the rooftop solar PV percentage of total installed PV capacity is over 32% [
8]. With the continuous progress of technology, the cost of PV has decreased rapidly, which will further promote the application of solar PV in buildings all over the world [
9].
Solar PV is generally integrated with a storage battery to improve the stability of the energy utilization of the solar PV generation system [
10].
Figure 1 shows the electricity demand and solar PV generation of a detached house on one winter day. Because solar radiation is an uncontrollable environmental factor, the real-time electricity generation from solar PV is unstable. The real-time electricity demand of a house also varies with its functions and environmental changes. Hence, a solar PV and battery integrated system can be deployed to mitigate the above fluctuations. The batteries can store the electricity when electricity from solar PV is greater than the electricity demand from the house, and provide electricity when electricity demand cannot be satisfied from solar PV.
To decrease the equipment cost of the PV and battery integrated system and increase its environmental benefits, the proper size of the PV and the capacity of storage batteries should be customized based on the real-time electricity load of buildings. The experience methods directly use the average daily electricity load to estimate the size of storage batteries and solar PV [
11], which can cause a waste of resources. There are many optimization studies for sizing renewable energy systems based on the economic and environmental effects. Kaabeche and Ibtiouen [
12] used an iterative technique to optimize an integrated solar PV, wind turbines, diesel generator, and battery system with a given capacity for the battery and varying numbers of PV panels and wind turbines. Ssheb-Koussa et al. [
13] optimized the size of a hybrid renewable energy system for four various sites in Algeria using MATLAB/Simulink (version 7.14) using a deterministic approach. Based on the weekly power dispatch simulation, Zhang et al. [
14] employed linear programming to optimize integrated PV, diesel generator, and storage battery systems. Ekren, O. and Ekren, B.Y. [
15] used the response surface method to compute the optimal PV area, rotor swept area of a wind turbine, and battery capacity in which the data for one-hour electricity load from 15 random days in each season were used. Akram et al. normalized the daily average electricity load in Dammam and used an iterative search algorithm to optimize the sizes of the PV, wind turbine, and battery materials [
16]. With four estimated hours of electricity consumption, Ahmadj and Abdi minimized the total present cost of a hybrid renewable energy system by using a Hybrid Big Bang–Big Crunch algorithm [
17]. Singh et al. optimized the net present value cost of a hybrid energy system to obtain the best solution for a PV size and power storage device [
18].
Most of the above studies only applied averaged daily or monthly electricity loads and considered one objective when sizing the hybrid renewable system. However, in some areas, the real electricity demand may fluctuate significantly with environmental changes. Additionally, for complex systems with multiple objectives, linear programming, iterative techniques, nonlinear programming, and other classical optimization techniques are not suitable anymore [
19]. Genetic algorithms can find the global optimal in a relatively short computation time because of their inherent capacity to randomly search for the optimal in all directions. Through selection, crossover, and mutation operators, genetic algorithms can enhance the quality of a population in every generation [
20]. Nondominated Sorting Genetic Algorithm-II (NSGA-II) is a variant of a genetic algorithm that can better preserve good solutions during iterations of GA simulations [
21]. Many studies have demonstrated that genetic algorithms and their variants, especially NSGA-II, can solve the complex optimization problems for hybrid renewable energy systems [
19,
22,
23]. Chang et al. applied a one-year hourly electricity demand to a detached house and developed a model of a PV and battery integrated system [
24]. The optimal size specifications of the integrated system were much better than the solutions from the experience method, but the deployed traversal algorithm cost too much computation time. Therefore, this work utilizes a model of a PV and battery integrated system with hourly electricity load data in a year [
24] and uses NSGA-II to overcome the drawbacks of the traversal algorithm.
The rest of this paper is organized as follows. First, the PV and battery integrated system is introduced, and the total electricity cost and usage of grid electricity are defined as the two indicators considering the economic and environmental benefits of the households. Second, NSGA-II is customized to optimize the above two indicators simultaneously. To verify the accuracy of NSGA-II, a single-objective genetic algorithm (GA) is deployed to optimize the above two indicators separately. The convergence process of the deployed genetic algorithms is also analyzed comprehensively, which shows the time-saving effects. The robustness of the deployed NSGA-II to various grid electricity prices is also tested. Finally, NSGA-II is compared with the traditional method to further prove the accuracy and time-saving effects of NSGA-II in sizing a PV and battery integrated system.
3. Results
NSGA-II was used to optimize the total electricity cost and usage of electricity of the PV and battery integrated system simultaneously, and a single-objective GA was used to optimize the above two indicators separately.
Figure 3 and
Figure 4 illustrate the mutually confirmed solution space and optimization results. The convergence processes of these algorithms were also considered from the perspective of computation time.
Figure 5 shows the convergence processes of the genetic algorithms, and
Figure 6 compares their computation time with the traversal algorithm. The robustness of the deployed algorithms to the fluctuation of grid price was also tested. Various grid prices were applied as shown in
Figure 7, and the stable performances of the genetic algorithms were demonstrated.
Figure 4 shows the optimal solutions of the deployed genetic algorithms. In
Figure 4, the blue circles represent the Pareto front solutions of the NSGA-II. The red five-pointed star represents the optimal solution of the single-objective GA for the total electricity cost and the black pentagon represents the optimal solution of the single-objective GA for the usage of grid electricity. The installation angle of the PV in the Pareto front solutions varied from 35 to 47°, which was significantly smaller than the initial installation angle range. The areas of PV in the Pareto front solutions varied from 23 to 62 m
2 and the capacity of the storage battery varied from 3 to 55 kWh. Both of the ranges almost coincided with the initial settled range, which demonstrated the ideal spread distribution of the Pareto front solutions for these two specifications. The optimal installation angle of PV for the two single-objective GAs was near 36°. In contrast, the optimal area of PV and the optimal capacity of the storage battery for the single-objective GAs was the opposite of this and was located at the two ends of the Pareto front solution. The simulation results for the optimal solutions of NSGA-II and the two single-objective GAs are shown in
Figure 4 with abbreviations similar to those in
Figure 3. The simulation results for the optimal solutions of NSGA-II and the two single-objective GAs are shown in
Figure 5 with the legend labels similar to those in
Figure 4. The simulation results for the two single-objective GAs are also located at the two ends of the simulation results of NSGA-II, and the distribution of the total electricity cost and the usage of grid electricity from the Pareto front solutions are continuous and spread. When the total electricity cost is less than CNY 3000, the used grid electricity greatly decreases from 2800 to 246 kWh. Then the grid electricity used slowly decreases to 119.7 kWh, while the total electricity cost rapidly increases to CNY 7612. In all simulation results for NSGA-II, the red circle shown in
Figure 5 is chosen as the optimal solution considering the trade-off between economic and environmental benefits.
Figure 6 demonstrates the convergence process of the three genetic algorithms used. The two single-objective GAs for total electricity cost and the yearly grid electricity used obtain the stable optimal solutions after approximately 2500 and 1300 evaluations, respectively. NSGA-II achieves the Pareto front solutions with a stable hypervolume after 2000 evaluations. The running time for the above three genetic algorithms and the traversal algorithm are shown in
Figure 7, where the total running times of the three genetic algorithms fluctuated for various maximum generation numbers, but all of them were significantly less than the running time of the traversal algorithm.
To test the robustness of the deployed NSGA-II to the fluctuating grid prices, five types of grid prices are utilized in
Figure 8. The colored circles represent the simulation results from the Pareto front solutions of NSGA-II. The five-pointed star and pentagon represent the optimal simulation results from two GAs for various grid prices. When the grid prices vary from CNY 0.40 to 0.56/kWh, the optimal simulation results for the two GAs are still located at the two ends of the optimal simulation results of NSGA-II. The optimal simulation results for the GA for the yearly grid electricity used stay in similar positions, while the optimal simulation results of the GA for the total electricity cost and the optimal simulation results for NSGA-II with the low total electricity costs shift to the right and decrease gradually.
4. Discussion
The optimization results for the two single-objective GAs and the optimization results of NSGA-II are mutually verified. As shown in
Figure 5, the optimal solution for the two single-objective GAs, corresponding to the total electricity cost and the yearly used grid electricity, coincide with the two ends of the Pareto front solutions drawn by NSGA-II. All of the genetic algorithms utilize the random evolution process to iterate the population generation. However, for the same objective, the GA and NSGA-II converge to the same solution, demonstrating their reliability. An inherent contradiction between the two objectives can be found in
Figure 4, in which the optimal area of PV and the optimal battery capacity in two GAs are totally different while the optimal installation angles of all genetic algorithms have similar values. The optimal installation angles of the PV in the Pareto front solutions vary in a small range (35–47°), and the optimal installation angles of the PV in the two GAs are near 36°, which suggests that a uniform optimal installation angle of PV exists, causing a lower total electricity cost and a lower usage of grid electricity. However, for the relatively expensive solar PV and storage battery as well as the cheap grid electricity, the use of more grid electricity and the installation of less solar PV and a smaller battery leads to a lower total electricity cost. Additionally, the lower usage of grid electricity, which is considered to bring more environmental benefits, encourages households to use more solar PV and a larger storage battery. The spread distribution of the Pareto front solutions in the area of PV and battery capacity shows the trade-off of NSGA-II for these two conflicting objectives, which is consistent with the simulation results shown in
Figure 5. The users can choose proper photovoltaic and storage battery system parameters according to their interest in economic and environmental benefits. Additionally, all deployed genetic algorithms converge properly and show strong robustness with the fluctuation of the grid price in
Figure 8, which further verifies the accuracy of the algorithms.
Figure 9 compares the optimal solutions from three genetic algorithms and the experience method. For the area of PV, NSGA-II and the GA for grid electricity choose large values that are similar to that of the experience method, but the GA for total electricity cost uses only a 23.3 m
2 solar PV area, which is near the low bound of the area of PV. NSGA-II and the GA for total electricity cost use a much smaller battery compared to the GA for grid electricity and the experience method. The optimal installation angles of the two GAs are similar and close to 36°, which is slightly lower than that of NSGA-II (43.9°) and higher than that of the experience method (26°). In all, the optimal solution of the experience method is similar to the optimal solution of the GA for lower usage of grid electricity, which shows its trend to use more solar energy.
Compared to the experience method, which utilizes the average daily electricity demand of a detached house and the approximated installation angle and area of PV according to experience, our proposed mathematical model of a PV and battery integrated system with the NSGA-II considers hourly electricity demands and related hourly solar radiation and can offer more efficient solutions. The total electricity cost of the experience method is CNY 7640, and the used grid electricity is 173.5 kWh. For the chosen optimal solution of NSGA-II, the total electricity cost is CNY 2472.1, and the grid electricity used is 443.3 kWh. Compared to the experience method, 67.6% of the total electricity cost is saved, but an additional 269.8 kWh of grid electricity is used. Based on the simulation results of NSGA-II shown in
Figure 5, when the grid electricity used is 170.9 kWh, the total electricity cost is only CNY 4615.2, which means that 39.6% of the total electricity cost is saved; and when the total electricity cost is CNY 7612.8, only 119.7 kWh of grid electricity is used, which means approximately 31% of the grid electricity is saved.
All three deployed genetic algorithms cost much less computational time than the traversal algorithm. As shown in
Figure 6, all of the genetic algorithms obtain stable optimal solutions after around 2000 evaluations.
Figure 7 compares the specific running time of the three genetic algorithms with the traversal algorithm. In this case, even if the solutions provided by the traversal algorithm are only accurate to the integer level, 116,100 evaluations are needed. The gap in the number of evaluations highlights the time-saving characteristics of the genetic algorithms. The sampling interval of the traversal algorithm can be limited by the curse of dimensionality, while the genetic algorithms can offer accurate optimal solutions.
Figure 10 and
Figure 11 clearly illustrate the difference between the genetic algorithms and the traversal algorithms.
Figure 10 shows the traversal results, in which PV_waste represents the wasted electricity for PV-generated electricity over the sum of electricity demand and the rest capacity of the storage battery. Because the optimal solutions for both total electricity cost and yearly usage of grid electricity have almost the same optimal installation angles for PV and the optimal angle does not vary with the area of PV and battery capacity, only the area of PV and the battery capacity are used as variables. As shown in
Figure 10, the total electricity cost increases with the battery capacity and the area of PV. This cost is significantly smaller when the battery capacity is lower, reflecting the greater effect of the battery capacity on the total electricity cost compared to the area of PV. The used grid electricity decreases as the area of PV increases. When the battery capacity is less than 10 kWh, more grid electricity is used for the suppressed ability of the battery to store and reuse electricity. PV_waste can be zero if the areas of PV and battery capacity are chosen properly. The largest area of PV and the smallest battery capacity is the worst situation that results in the largest amount of PV_waste.
Figure 11 shows the simulation results for NSGA-II, and this figure uses the same legend as
Figure 10. It is clearly shown that NSGA-II requires much fewer evaluations than the traversal algorithm. As shown in
Figure 11a,b, the Pareto front simulation results almost coincide with the edges of the solution space in
Figure 10a,b, in which the total electricity cost and the used grid electricity have the lowest values. In
Figure 11c, the largest value for PV_waste is smaller than 1600 kWh, which is much smaller than the maximum amount of PV_waste in
Figure 10c, and all Pareto front solutions avoid the two extreme cases of a large area of PV with a small battery capacity or a large battery capacity with a small area of PV. Additionally, the interval of parameters for the traversal approach in
Figure 10 is one, which only offers integer solutions, while NSGA-II can offer accurate decimal solutions. All of this confirms the accuracy and time-saving of the deployed NSGA-II.
5. Conclusions
The deteriorating environment and fossil fuel depletion necessitate increased renewable energy adoption, and the conflict between economic and environmental interests requires more efficient solutions. This study employs a developed mathematical model for a PV and battery integrated system for detached houses to optimize total electricity cost and yearly used grid electricity, catering to economic and environmental interests. Utilizing the model with the hourly real-time electricity demands of the house, the deployed NSGA-II algorithm can find more efficient optimal solutions than the traditional methods. The key conclusions are as follows.
NSGA-II and the two single-objective GAs applied to the PV and battery integrated system produce consistent optimal solutions, even with fluctuating grid prices, demonstrating the accuracy of NSGA-II.
All of the genetic algorithms converge quickly, achieving stable optimal solutions after approximately 2000 evaluations. NSGA-II completes the optimization in 726.1 s, saving 94% of the computation time compared to the traversal algorithms (12,216.1 s).
The Pareto front solutions of NSGA-II reveal a clear trade-off between economic and environmental benefits. The experience method incurs a total electricity cost of CNY 7640 and uses 173.5 kWh of grid electricity, while the optimal NSGA-II solution costs CNY 2446.7 and uses 496.3 kWh, aligning better with typical household preferences.
The traversal algorithm is inefficient and limited to integer solutions. NSGA-II intelligently bypasses unreasonable parameter ranges, aligning with the traversal algorithm’s solution space edges where total electricity cost and grid electricity usage are minimized.
This study provides a framework for optimizing PV and battery system sizes for detached houses, but there are some limitations. First, because this study addresses detached houses in rural areas, more cost-effective lead–acid batteries are chosen. Other types of batteries available on the market (e.g., lithium batteries) are not investigated, and there is a lack of generalizability of the analyses in this regard. In addition, the analytical data used in the study are derived from simulations, not measured data. Subsequent analysis using measured data would increase the credibility of the study’s conclusions. These limitations will continue to be addressed in future studies. Our future work will integrate more renewable energy sources into the model and test more complex application scenarios to generalize the system for various building types.