# Differential Evolution and Fuzzy-Logic-Based Predictive Algorithm for V2G Charging Stations
## 3 Results
As in Figure 5c, it can be seen in Figure 6c that at the moment of higher costs, it became attractive for the batteries to supply current to the grid; nevertheless, they quickly recovered the equilibrium of charge after the tariff reduction. From the initial analyses, it was possible to carry out a study in order to adapt the values of \"K4\" so that, at the end of the day, the battery banks were in a satisfactory state of charge and so that, at the same time, the electric station generated a profit. Therefore, it was considered reasonable to set the spending ceiling at USD 100 for the first day and USD 300 for the supposed second day. This variation in the spending ceiling considered the profits added to the budget and, consequently, eliminated the limiting factor that the budget imposed on battery charging in the event of the absence of photovoltaic generation. Figure 6: System parameters’ behavior for a sunny day, “K4” greater than 1. In this scenario, \(SoC_{0}=90\%\), and USD \(\mu=100\). (**a**) SoC (%) of the battery; (**b**) Expense (USD) throughout the day; (**c**) Battery current; (**d**) Grid current. In sequence, we analyzed the behavior of the system parameters from the linear variation in \"K\({}_{4}\)\" as a function of the photovoltaic generation curve. Therefore, the proposal considered valuing the charging of the batteries during maximum photovoltaic production. Another proposal consisted of linearly varying \"K\({}_{4}\)\", taking the cost of energy from the grid as the input variable, maximizing the charging for situations in which the cost was lower. It is important to highlight that for the proposed work, the photovoltaic generation and electricity cost profiles did not present any correlation, being completely independent. Obviously, we could not exclude the possibility that in certain places, such profiles were linearly dependent, which would rule out the need to analyze \"K\({}_{4}\)\" for the two previous proposals. With a view to the proposed variation of \"K\({}_{4}\)\", it is worth considering that when charging the batteries during peak generation, regardless of whether the batteries are charged or not, the energy surplus will naturally flow to the electrical grid. This allows, during the energy cost peak, the stored energy to be used to generate a greater profit, because depending on the form of negotiation, such energy can be dispensed to the grid in the absence of photovoltaic generation and for a more attractive price. For the proposals of a linear variation of \"K\({}_{4}\)\" as a function of the generation and cost profiles, 0.1 and 5 were adopted as minimum and maximum values, with such limits being established, respectively, for situations in which recharging and charging had the highest priority. Considering that the relationship of \"K\({}_{4}\)\" with the generation and cost profiles was not necessarily linear and that, in a real scenario, the profiles' behavior, in addition to being unpredictable, were not correlated, as a strategy to match the previous proposals, a fuzzy system was created, having as inputs the photovoltaic generation curve and the electricity cost curve and, as an output, the value of \"K\({}_{4}\)\". With the proposed logic, the battery was charged more than 90% at the beginning of the day, adopted as 5 AM or 6 AM. The membership functions of the inputs and output are depicted in Figure 7. For the inputs, the strategy was to utilize the trapezoidal forms for the values that were close to the max ranges, which were selected as the minimum and maximum values of the photovoltaic and cost curves. This way, it worked as a crisp number in that region and started to operate as a fuzzy logic operator as the measures increased or decreased. The abbreviation adopted were L for low, M for medium, and H for high. Figure 7: Proposed fuzzy logic membership functions. Given that the fuzzy logic has two inputs with three membership functions each, there were a total of nine rules, presented in Table 1, contemplating each one of the possible cases.