Algorithms to Model and Optimize a Stand-Alone Photovoltaic-Diesel-Battery System: An Application in Rural Libya

This paper introduces a new optimum calculation technique for a stand-alone hybrid photovoltaic-diesel-battery system (PDBS), which meets the energy requirements of a small village in southern Libya. The bat algorithm design strategy is applied to reduce the annual cost of the system, taking into consideration the controlled electricity restriction and the optimal numbers of PV panels, diesel generators, and batteries. Comparative tests are performed using MATLAB for the bat algorithm with the grey wolf search algorithm and particle swarm optimization, demonstrating that the bat algorithm determines the optimum size of the PDBS effectively at a lower expense. Results then indicate that, taking into account the reliability characteristics, this has a significant effect on optimum capacity, load supply, and cost.


INTRODUCTION
There is a need for sustainable power sources in remote rural areas, which rely on the national power grid for their power needs. So far, solar photovoltaic (PV) energy has been beneficial because it is sustainable, it does not require complicated maintenance, and, above all, it does not release greenhouse gases. Thus, experts in several countries have recommended PV systems because they complement the national grid; however, PV systems have a fundamental problem, which is their discontinuous power flow because solar energy varies with seasonal and weather changes in the sunlight. To make the power flow reliable, hybrid systems are generally equipped with PV arrays and different types of generators [1][2][3].
Hybrid photovoltaic-diesel-battery devices have been suggested for this reason in rural Libya in previous research since they seem appropriate for satisfying the regular energy requirements. Such a hybrid system uses a battery bank for storing excessive power that PV arrays generate to meet the night-time needs. In this system, a diesel generator is added to overcome the unevenness of the generated power [4,5]. Thus, a PV-diesel system offers more excellent power generation reliability as compared to PV-only or diesel-only systems. In a nutshell, hybrid systems offer more flexibility, efficiency, and cost-savings.
Moreover, when a battery and a backup diesel generator are combined with a PV system, it substantially reduces the operational costs and pollutants [6,7]. When a PV-diesel-battery system is first implemented, it results in higher equipment costs; however, if we avoid this initial investment/cost, we will have to adopt a sub-optimal design, which has a negative economic impact in the long run [8]. Thus, the complications of the optimal design of a hybrid renewable energy system should be embraced because classical designs can be either active or efficient, but not both at the same time [9]. In the last 20 years, metaheuristic optimization methods have become widespread. Some, including ant colony optimization [10], genetic algorithms [11], grey wolf optimization (GWO) [12], and particle swarm optimization (PSO) [13], are still popular among experts in different fields. They are commonly applied and easy-to-implement techniques because they are straightforward, flexible, and derivation-free. The mentioned methods each have their own benefits, which sometimes make them good choices to solve optimization issues, and they are based on natural phenomena, which make them useful and straightforward. This implies that the meta-heuristic process might yield useful outcomes in some cases; however, they are likely to show poor performance in more demanding situations. Therefore, researchers have made efforts to propose and test a new algorithm to assure hybrid sustainable power supplies [13,14].
The bat algorithm is a concept based on the echo location of bats (or microbats). Yang developed it in 2010, and it gradually became a frequently used technique because it offers a diversity of solutions. It also uses automatic zooming for balancing exploitation and exploration that mimics different pulse emissions of bats when they search for their prey. Consequently, it is beneficial and it starts quickly [15]. Since it is metaheuristic in nature, a bat algorithm has "microbats" that use echoes with changing frequency, loudness, and pulse rates during the "random walk" process. In this case, it is possible to reach the best solution when optimization ends. This process can be applied to solve real-world problems by optimizing objective functions. In this form of optimization, the number and types of PV panels and batteries are limited. As soon as the iteration begins, it generates a random value for the battery modules with PV panel type in kilowatts, which is computed and saved as a fitness value. As the iteration loops continue, new bats are selected from the existing bats, which means that new modules and types of power generation are chosen. When the parent and offspring bats' fitness values are compared, we choose the best bat for decreasing the cost; therefore, this approach is used in various industrial and engineering applications to optimize real-world issues [16].
The use of the unstable bat algorithm to solve economic dispatch problems containing a variety of equity and discrimination restrictions, like the forbidden operational areas of the power balance and the ramp rate cap, has been demonstrated in the literature. Most research has also verified that the bat algorithm is simple to execute and delivers good performance. In this respect, this algorithm is proposed and applied in this study to determine the perfect size for a stand-alone hybrid photovoltaic-diesel-battery network. The key objectives of this research are to meet the energy requirements of a remote region by using photovoltaic, battery, and diesel generator tools and design a technical model for a standalone hybrid photovoltaic-diesel-battery network. In addition, a comparative analysis of the bat algorithm, GWO, and PSO is performed for the stand-alone hybrid photovoltaic-diesel-battery method.
As a consequence, there are significant new developments in this paper, such as the application of the bat algorithm to the size optimization of a stand-alone photovoltaic-diesel-battery hybrid system, the evaluation of the hybrid system through the production of reliability indices, and the study of the performance of this algorithm through comparisons with GWO and PSO using MATLAB Simulink.
This research has been organized into five further sections. Section 2 presents a description of the site. Section 3 introduces the parts of the power network. Section 4 explains the bat, GWO, and PSO algorithms. Section 5 describes the economic model based on the annual cost of the system (ACS). The applications and results are addressed in Section 6, and then the paper is concluded.

SITE DESCRIPTION
Wadi-Marsit, which is located about 200 km south of Tripoli (30° 59′ N, 13° 28′ E), is a village in which about 70 families live. They rely on livestock farming as their primary source of income. The extension of the grid to the community involves notable expenses and complexity because it is a distant place with a very small population.
The selected village has an almost desert-like climate. The number of residents is 220, scattered across an area of 2 km 2 . Most residents live in either tents or huts, but some public services and buildings do exist, including a school. The village has pastures in the vicinity, so livestock farming, and relevant services are the primary sources of income of the local people [17,18]. It comprises a diesel generator, a PV array, a battery bank for residential AC load, and a converter. In this system, the diesel generators (DGs) are linked to an AC bus system that directly gives the load demand without conversion units. In the event that the power generated through sustainable power sources is insufficient to meet the load request, an economical solution will be needed to operate the DGs and batteries. Selected sections of the illustrated hybrid system are listed in Tab. 1. It uses a dump load that discards the excessive power when sustainable energy is excessive as compared to the demand while battery banks are fully charged.

Photovoltaic Array
An appropriate model is essential for simulation. The PV panel has a simple model, in which local and global solar radiation in Wadi-Marsit are the main variables, which are illustrated in Fig. 2. The PV panels have the following detailed equation: Here, A p is the area of a single PV panel (m 2 ), η stands for energy conversion efficiency (%), G(t) represents insolation data (W/m 2 ), and N pv is the sum of the number of PV modules [19,20].

Banks of the Battery
The electricity produced from the hybrid generation system (DG and PV) regulates the charge/discharge power in and out of the battery, which is regulated by the load demand for the given time.
We can mathematically express the battery's state of charge (SOC) as follows: Here, P c is the charged power, SOC(0) is the initial SOC of the battery, η c is the charging efficiency, P d represents the discharged power, and η d represents the discharging efficiency. The battery capacity has the following constraints: In the above equation, B min and B max respectively represent the minimum and maximum power limits, while DOD is depth of discharge. Moreover, the battery's discharged power must satisfy the following constraint: P max represents maximum hourly discharge [4,21].

Diesel Generator
The diesel generator's fuel consumption is linked with rated and generated forms of power. We can calculate the fuel cost using the equation below: Here, F(t) represents per hour consumption of fuel ($/hour), which is based on the diesel generators' load characteristics. It can be calculated as follows: In this equation, P DG (t) is the power that the diesel generators generate, P R represents the diesel generators' rated power, and C f stands for per litre fuel cost ($/L) [22].

Load Requirements
Life in small, remote rural areas like Wadi-Marsit is very different compared to big urban centres, so we analysed and calculated the village's unique power requirements and considered the types of appliances that people use in their daily lives. For this purpose, we visited the chosen site many times and discussed the needs of the residents. We determined that the AC load was needed for 40 huts, 30 houses, and a school, which are located in Wadi-Marsit. We calculated the average daily load requirements for January, July, and October, which are given in Fig. 3.
The estimated load for this village was calculated, keeping in mind a national power supply plan directly using solar energy. Tab. 2 shows the results of the essential required loads in the form of loads needed.

TYPES OF ALGORITHMS 4.1 Grey Wolf Search Algorithm
Grey wolves are hunters; they are at the peak of the food chain. They like to live as families, and they adopt a rigid social structure, as seen in Fig. 4. The hunting phenomenon (optimization) in the GWO algorithm depends on α, β, and δ, while ω wolves follow the α, β, and δ wolves. Now it is time to encircle the prey because, in reality, grey wolves encircle their prey before killing it. The mathematical model for this encirclement is given by the two equations below: Here, t shows a current iteration, while Xp is the position vector of the prey and both C and A stand for coefficient vectors. X gives the place vector of the grey wolf and the vectors A and C are supplied by: In this case, components of A have been reduced from 2 to 0 in a linear way over several iterations while r 1 and r 2 represent random vectors (0, 1).
For the mathematical simulation of grey wolves hunting, alpha (best possible candidate solution), beta (next to best), and delta wolves know better where the prey is, so we save the top solutions that have been found so far and we use other search agents (omegas) to adjust their positions according to the top search agents' locations. In this context, we propose the following formulas [23,24]:

Particle Swarm Optimization (PSO)
PSO is distinguished as a balanced experimental mechanism that is flexible so that it can update and improve the local and global exploration possibilities. It is based on a stochastic search process that has a lower memory requirement, so it shows substantial computational effectiveness and it is also easy to implement in comparison with other swarm intelligence approaches and meta-heuristic developmental computations. Eberhart and Kennedy created PSO in 1995 as a population-based stochastic optimization process based on birds' social behaviours [25]. PSO is a populationbased heuristic process that has evolved based on birds' motions in a flock when they are in search of food. The solutions are in the form of scattered random particles in a given problem space. These particles are termed as swarms, which mutually exchange information based on their specific positions. Using their own and their neighbours' experiences, the particles update their positions. The particles' updating process actually takes place through their velocity. The vectors for position X and velocity V of the i th particle located in a d-dimensional space are mathematically represented as follows: In this case, r 1 and r 2 illustrate the uniform random numbers between 0 and 1, w(k) shows the weighting factor that manipulates the impact of past velocities on current velocity, Gbest(k) shows the best global position at iteration k, Pbest j (k) is the best location of particle j during iteration k, and c 1 and c 2 are social scaling parameters such that c 1 = c 2 = 2 [26,27].

Bat Algorithm
Xin-She Yang proposed this new population-based meta-heuristic algorithm in 2010, which exploits the echo locations of bats. Bats have a unique capability to use sonar echoes to locate and catch their prey and avoid obstacles in the dark. Bats emit sound waves and then they receive the echoes of the sounds coming back to them, which helps them create a 3D picture of their surroundings in their minds that allows them to understand the sizes, shapes, and types of prey. In a nutshell, the bat algorithm combines the functions of a genetic algorithm and PSO, which leads to better results. It optimizes the system's objective function, so depending on that, we can add different kinds of PV and battery modules. After adding the PV and battery modules, we can calculate the amount of power that can be generated and stored, which is possible by finding the fitness value, when the iteration begins. After that, as the iteration loops continue, it results in choosing new modules' values. The fitness values are then compared for parent and offspring bats to select the best bat, which helps in reducing the cost [28,29].
The bat algorithm begins with n total bats, which are randomly placed in a search space. Every bat has three parameters: location X i and velocity V i at iteration t. Then we can find the best solution, X*. A bat's velocity and position are updated using the equations below: Here, fi stands for the frequency of every bat that is uniformly drawn through (f min , f max ), and   0 1 ,   , which is a random vector, is drawn using a regular distribution. For local search, a random walk method is used with direct exploitation to modify the current preferable solution with the following equation: Here,    is a random number while A t shows normal loudness. As the iterations take place, we get pulse emission rate r i and assorted loudness A i , which provides a useful mechanism for controlling both exploration and exploitation, and it is possible to switch to the exploitation stage whenever necessary. Generally, loudness is reduced when a bat finds its prey, but the pulse emission rate is enhanced. Thus, loudness can acquire any convenient value between A min and A max . Whenever A min = 0, it implies that a bat has found its prey, so it will temporarily stop emitting sounds. Here, t+1 i A has been expressed as given below: and In the equations above, r i stands for the pulse emission rate, while both α and γ are constants. For simplicity, we used α = γ = 0.9 -0.98 for simulations [30,31].

ACS-BASED ECONOMIC MODEL
The economic calculations in this context are based on the annual cost of the system (ACS), which is used to reach the benchmark cost. ACS comprises annual operational cost (AOC), annual capital cost (ACC), annual maintenance cost (AMC), annual fuel cost (AFC) of diesel generators, and annual replacement cost (ARC). The system comprises PV modules, batteries, DGs, and an inverter. We can calculate the ACS as follows: ACS = ACC + ARC + AFC + AOM (22) Some units work for the whole lifetime, so they do not need a replacement; consequently, they do not have a replacement cost. These units include PV panels, DGs, and the inverter. Their price can be determined as follows: In the equation above, C cap is each component's capital cost in $ that has a life beyond the project lifetime. In this formula, CRFis the capital recovery factor that shows the present worth of the collection of equivalent annual cash flows. It can be calculated as follows: In Eq. (24), I shows the per annum real interest rate, which comprises annual inflation rate f and nominal interest i. It can be determined as follows: In this case, i′ is the interest on the loan (%). We can calculate the system's annual operation and maintenance cost (AOM) through independent variables such as the reliability of components (λ), capital cost, and the components' lifetimes using the following equation: The cost of replacing units is represented by the annual replacement cost (ARC) in the lifetime of a project. Our work includes some units that require replacement, such as battery banks. Thus, ARC is determined as follows: Here, C rep is the battery banks' annual replacement cost in $, while y rep is the duration of life of the batteries (fraction of a year). In Eq. (27), SFF represents the sinking fund factor, which is a proportion for calculating the annual cash flows' future value. It can be determined as given below [32,33]:

APPLICATION AND RESULTS
The main purpose of this study is to implement the bat algorithm, PSO, and GWO using MATLAB to create a hybrid PV-diesel generator-battery system for electricity generation in a small village in southern Libya. To evaluate the performance of the proposed bat algorithm, PSO, and GWO and make recommendations for better system selfplanning, we check the configurations of various systems to find the best and most efficient hybrid system for 25 years. The effectiveness of the proposed algorithm is independently monitored by comparison to PSO and GWO.
A comparison of the performance of the three optimization methods (PSO, GWO, and bat) individually on the environmentally friendly system to minimize gross project costs for each part (PV panels, diesel generators, and batteries) in the system for a period of 25 years is shown in Fig. 5. This figure reveals that the bat algorithm is much faster and has fewer iterations than the other methods. Figure 5 The variations of the numbers of PV panels, batteries, and diesel generators obtained by PSO, GWO, and BAT algorithm for cost.
As shown in Fig. 6, the algorithm converges within 100 iterations when the objective function value is compared among the bat algorithm, GWO, and PSO. It is also obvious in Fig. 6 that the outcomes were obtained in terms of optimal configuration for power generation. If we summarize the results, $ 200 640 was the best value for cost, which was obtained with the bat algorithm, while the expenses were respectively $ 205 036 and $ 212 116 when using the GWO and PSO methods. The optimal number of components for the bat method involves 134 battery banks, 778 solar panels, and 2 diesel generators, as shown in Tab. 3. The simulation results for GWO and PSO respectively showed the need for 144 and 168 battery banks, 832 and 896 solar panels, and 2 diesel generators in each case.
Thus, this table also shows that the bat algorithm offers a better, more optimized solution as compared to the GWO and PSO methods.  Figure 6 The performance of the bat algorithm as compared to GWO and PSO for finding the optimal configuration The energy contribution from each part (i.e. PV panels, diesel generator, and battery) for the best solution system using the bat algorithm is given in Fig. 7. The contribution of energy supplied by PV panels is 48%, which is higher compared to other parts. The diesel generators and batteries supplied 20% and 32% of the energy.  The costs of different components are given in Fig. 8, as optimized using the bat algorithm. This figure shows that ACC is the most expensive cost factor while the amount of production of the PV panels is the governing cost.

CONCLUSION
This paper has explored a modern approach to simulation efficiency for designing an off-grid hybrid power generation system for meeting loads of several houses and huts in Wadi-Marsit. A hybrid PV-DG-battery design with the bat algorithm was suggested. Minimizing the total cost of the yearly system is the primary target of the studied optimization issue, so we had to determine the optimal numbers of diesel generators, PV modules, and battery banks. Results revealed that the bat method could reach the global optimum with simpler computations. Our proposed system includes 778 PV panels, which supply approximately 48% of the load demand. According to the bat algorithm, the total number of required batteries is 134, which have a total storage capacity of 873.6 kWh. Moreover, the ACS can be reduced to $ 200 640. Results indicate that the bat algorithm increased the efficiency of optimization and enhanced the calculations of other approaches to reduce device costs.
The bat algorithm was evaluated here for optimum performance of a stand-alone photovoltaic system-diesel generator-battery system in terms of efficiency, and it was concluded that the proposed algorithm has the potential to avoid the local minimum and can perform better than other optimization approaches.