Smart Grid 2.0: Modeling Peer-to-Peer Trading Community and Incentives for Prosumers in the Transactive Energy Grid

Smart Grid 2.0 (SG 2.0) implementation constitutes an additional challenge in the industry and research fields. Energy consumption decreases when producers exchange excess energy consumers, including intelligent consumers, Distributed Generation (DG), such as wind and solar, and Electric Vehicles (EVs). By utilizing Demand Response (DR) based on Real-Time Pricing (RTP), the operation of every device in a smart home can be scheduled. Allowing users to trade energy directly with other energy producers (prosumers) rather than exclusively relying on the grid, peer-to-peer (P2P) energy trading in smart homes lowers energy prices for users. This article focuses on how the DR P2P energy trading affects consumers. The study conducted utilizes a two-stage scheduling technique to reduce consumers' electricity expenses. The initial stage involves arranging each device in the smart home based on RTP employing a deep learning method. The P2P energy trading between consumers in the second phase is made more accessible by the DR and the simulation results exhibit that energy trading decreases electricity bills in smart homes. Utility companies can reduce load during peak hours using DR-based P2P energy trading.


INTRODUCTION
SG 2.0 is an innovative technology that integrates local grids with distributed energy to reduce energy consumption.The former employs advanced A.I. technologies to combine local grids and distributed energy sources, making it an attractive and promising solution for the future.SG 2.0 is selfprocessing and can work with both power transmission and high-end solutions.The energy industry has undergone significant changes in energy demand, resource utilization, management, distribution, and exchange.These changes have led to a new energy-consuming process known as Prosumer [1,2].The industry is also experiencing a massive transformation involving the use of renewable energy sources, increased operational efficiency, and the implementation of smart infrastructure and services.These ecosystem actors continuously improve their work by establishing appropriate legal systems and experimenting with new marketing methods.P2P energy trading is emerging as a viable alternative, allowing end-users to buy or sell electricity to or from other customers instead of solely relying on electrical service providers.However, P2P energy trading in distribution systems presents several challenges, including network limitations, increased communication needs, reduced end-user privacy, and financial stability for utility companies.Numerous experimental and research projects are underway worldwide to face these issues [3].According to [4], Positive Energy Regions (PERs) can be utilized for overgeneration to produce more energy despite their limited Loss of Earning Power (LEP).Photovoltaic (PV) panels are a suitable renewable energy source for PEDs due to their ease of installation, increased capacity, and low maintenance costs.Distributed PV systems are prevalent in the household PV market due to their affordability and the multiple household control they provide.They are, therefore, better suited to densely populated urban areas.Local energy sharing is expected to increase the use of electricity generated from PV systems.Individuals and small to medium-sized private or public businesses will drive this, depending on the market setup and available support.However, there are more effective strategies than relying on contributions for long-term PV stabilization.Due to the difficulty in accessing capital, current business models, such as power purchase agreements and net metering, are limited to small-scale PV systems.It may be necessary to restructure business practices to utilize distributed energy supply, demand, and sharing.Therefore, consumers with small PV systems must sell their excess power to the grid at market prices without assistance.PV customers may experience financial losses, further damaging the network's stability and reliability [5].
In [6], the authors reported that the EU Commission's proposed budget for renewable energy includes energy communities that allow for local energy trading on a European scale.The energy sector has adopted a new business strategy known as P2P trading.In this economic model, prosumers and consumers organize into energy societies, where they can offer their surplus production to other participants.The infrastructure of the grid should be designed to accommodate this new model.To comply with new regulations to increase the use of solar power while reducing the need for incentives, optimal planning and modeling of PV P2P business models are required.When analyzing the situation and discussing ways to trade power in the future, it is essential to consider the three ways to own a PV system: consumer, community equity, and third-party liability [7].In [8], the authors describe three solar PV consumer business idea specifications.The first category is the single direct user group, where one customer generates PV power onsite.The second category is the local collective user group, where several users share the PV electricity produced without a public grid.The final group comprises a range of energy models in areas with numerous buildings fitted with PV cells.In these areas, users directly consume locally produced PV energy and the excess energy is shared via a public or private microgrid.The business process involves various properties in each set of boundary conditions, leading to many possibilities and uncertainties.It is crucial to comprehend and test the different potential designs and combinations.Currently, there is limited regulatory and modeling research on P2P energy trading.The community-owned PV system is gaining popularity as a developing business model in areas where people share energy, as it could be a profitable way to promote the use of PV systems [9].DSM was only considered in early studies on the smart grid to decrease energy costs in the smart home.This plan reduces energy costs by shifting loads when energy prices are low.Authors in [10,11] conducted a research supporting this strategy.Recent studies have also shown that combining DSM with energy storage and renewable energy can reduce costs [12,13].These contributions have provided optimization models with timelines for optimized power sources and loads.Authors in [14] focused on energy trading between microgrids in the smart grid.However, none of these methods can lower energy costs in intelligent homes because they do not consider trading energy with nearby houses.P2P energy trading is a relatively new idea for families.P2P service providers offer metering and billing services and manage the distribution network [15,16].These projects worked with DSM to develop business models instead of exclusively concentrating on lowering energy costs.In [17], the authors created a community mini grid with an online market where each house could trade energy.Two-level programming was used to describe an optimization problem, and the relationship between mini-grid prices and the Supply-Demand Ratio (SDR) was examined.Authors in [18] emphasized the importance of presenting customers with accurate information when comparing prices.In [19], the authors used an SDR method to demonstrate that customer costs are comparable.Authors in [20] reported on the impact of energy storage systems on consumer-to-consumer trade.They compared the total energy held by all users to the total energy sent by all users.Nevertheless, none of the above technologies integrates DSM with P2P trading.In [21], the authors suggested that a P2Pbased grid approach can decrease the energy costs of all microgrids and increase the value of locally Distributed Energy Resources (DERs).In [22], the authors suggest that a smart grid can reduce energy costs using an integrated demand management system that works with P2P energy trading.Authors in [23] recommend a distributed DSM system integrated with community energy trading to lower household electricity prices in a small community grid with a BT storage unit, establishing a good relationship between buyers and sellers.Authors in [24] proposed an energy-sharing scheme that responds to price and demand.
During the recent years, there has been considerable discussion about the role of multifactor power management systems in microgrids.In [25], the authors discussed some multifactorial schemes that control network power.Game theory can be employed as a mathematical method to examine how consumers and market participants interact.Research has primarily focused on the interaction between consumers and customers within the context of a contract.Support methods were employed to address contracts that provided secure electricity supply against unfavorable low market prices and financial losses resulting from imbalances between supply and demand in the spot market [26,27].In [28], the authors proposed a robust supply chain coordination model based on a quantity discount contract that considers only fixed demand loads To maximize the benefits of P2P trading, it is essential to establish multiple homes and RESs competing with one another.The optimization of energy costs is typically described using linear or nonlinear programming.Linear programming is commonly used to address the concepts of linear optimization.It is important to note that solving a linear model requires less time than solving a nonlinear model.Although the optimization model is nonlinear, it can still be solved quickly.However, nonlinear optimization models take much longer than the linear ones, so such optimization techniques cannot be used to solve these problems.Therefore, this article discusses setting up a sustainable hybrid PV battery storage system to manage household energy while considering grid outages and Demand Response (DR).An optimization design is proposed to decrease energy costs while maintaining system reliability.DR is achieved through incentives, such as tariffs based on usage, real-time pricing, and the scheduling of widely used appliances that can or cannot be moved.Additional case studies were simulated to provide a comparison, considering different battery power rates and the amount of renewable energy used in lower and higher cases.Furthermore, this study analyzes various limitations concerning grid dependability, including the effect on project expenses and the impact of demand response methods.
This study suggests the use of P2P energy trading with hardware scheduling in smart homes to tackle the limitations.The report emphasizes the subsequent significant contributions: Firstly, smart homes provide users with various distinctive technologies, including loads, DGs, and EVs.Additionally, there are two different categories of smart home appliances: those that use temperature control and those that use electricity control.Real-Time Pricing (RTP) employs the DL algorithm to arrange the timetable for each intelligent home device.The adoption of DR allows for P2P power trading between two entities, namely the masters and consumers, resulting in a reduction in electricity costs for both parties involved.

A. Distributed Power Sharing
The term Distributed Power Sharing describes a residential neighborhood community consisting of an Energy Pool Unit (EPU), Smart Homes (SHAs), and Traditional Homes (THAs).The SHAs are equipped with energy storage, such as Battery (BT), which enables them to sell excess energy to the EPU and purchase stock at market prices in real time.Non-market households can purchase electricity from the EPU at lower prices than the retail market when electricity is insufficient.The solar panels installed by THAs can sell their excess energy to the energy collector at a price higher than the Feed-in Tariff (FinT).Decentralized agents negotiate the buying and selling process through a pool as illustrated in Figure 1.This section describes how P2P energy exchange can efficiently operate in six families with variable output and consumption patterns.Figure 1 depicts the energy conservation process among customers through exchanging energy and optimizing the distribution network.If residents consume more energy locally than the P2P market produces, the grid sets the price for its sale.Following a surge in demand at the local exchange, the distribution business procures electricity at the prevailing grid prices.The P2P market structure seeks to minimize energy expenses and enhance societal well-being by optimizing pricing among nearby households.The model was specifically developed to aid six individual homes in four distinct settings.Users can monitor their Return on Investment (ROI) and expenses using the model interface.Home PV systems, Energy Storage Systems (ESSs), and EVs are used for both energy generation and consumption.This technique empowers consumers to actively engage in the market by identifying the most economically efficient energy consumption.We introduce a precise approach for calculating exchange expenses.The sophisticated exchange algorithms, utilizing double auctions, consider the interests of both consumers and producers.This reduces the commercial motivation for a P2P house.According to popular belief, the surplus-to-demand ratio facilitates P2P trading.A series of minor blackouts, where immediate demand must always be met even if the utility network fails, are modeled.Starting time and duration of each event are determined arbitrarily.It is recommended to use files containing blackout data to create power blackout scenarios.The generated files can be used with the reverse conversion approach to create domestic power that collects and resells excess electricity from prosumers, consumers, and DGs at a discount.The energy in the pool comes from smart homes and DGs.All participants in the energy pool market must adhere to the principle of voluntarism and accept surplus-to-demand market prices.
Authors in [29,30] proposed a methodology that reflects current retail prices and the home energy profile.The cost may exceed the retail market price when supply exceeds the demand.The authors discuss network blackout cases based on various constraints.During a power blackout, the entire network is inaccessible, resulting in no energy flow between homes and UGs.In this case, resources such as the PV-BT system must be provided to the domestic system during a power outage to prevent domestic power blackouts that would avert the domestic system from selling electricity to the UGs. Scenario B: In the event of a power outage, SHAs purchase additional energy from the EPU, considering the real-time electricity price.
 Scenario C: THAs purchase energy from the EPU at a discounted rate during periods of oversupply.
 Scenario D occurs when there is insufficient energy available during peak hours.In this scenario, THAs purchase the energy required to meet the demand at a lower cost than the V2G/retail market price.However, the EPU cannot supply the THAs with the power deficit needed.
 Scenario E occurs when THAs have excess power and the EPU is deficient in strength.In this scenario, THAs sell their extra energy to the energy pool in higher prices than the FinT.

B. Energy Pool Unit
It gets additional power from consumers, Distributed Generators (DGs), and renewable energy sources and sells it at a lower price in the retail market or a Real-Time Rate (RTP).
SHAs sell power to the pool, and DG sells the excess power.The surplus-to-demand ratio determines the market price of an energy pool unit [31].Equation (1) estimates the neighborhood's retail market price of electricity and energy consumption.If the overall load profile is high, the price may be greater than the retail price (supply is higher than demand).The surplus/demand ratio enhances P2P commerce.

C. Smart Home Agent 1) Reinforcement Q-learning
It is one of the most important ways for machine learning to make optimal choices in a world where nothing is known.The reward and the changed state of the environment are returned to the agent by the environment.The agent continues to learn until the latter provides greater advantages.The agent's main goal is to choose the optimal policy that offers the most rewards.The policy is how the agent behaves in a given scenario.This paper hypothesizes that a Markov decisionmaking process defines the environment.The agent state transition depends only on the current state and the action set in the current state without considering all the previous conditions and actions.

2) Home Agent Model
The SHA charges and discharges the BT unit based on the energy pool price and the home village demand.The BT is the most vital, controllable piece of equipment in the proposed P2P trading system, enabling users to become involved.The BT model is illustrated in (2) [32,33].The capacity is the main terminology when studying battery modeling.The battery functions in discharge current and electrolyte temperature, which affect the state of battery charge.
In household BT, the SHA must manage power in real time for the benefit of the customers.The BT's decision will affect battery capacity, public retail, and neighborhood pricing.
 Discharge case: The SHA would buy energy from the retail market or the local energy pool if the remaining energy did not fulfill the user's needs (Scenario D).The BT may discharge more electricity than needed to trade energy.
Traded energy reduces the supply-to-demand ratio, depreciating the power of the local energy pool.
 Charge Case: The agent must purchase electricity from the retail market or the local energy pool.
If there is no energy storage in the energy pool, the agent must buy electricity from the retail market.The Markov Decision Process (MDP) may be an excellent alternative for optimal decision-making with numerous associated stages.

D. Single Home Sharing Energy 1) PV Supply
It makes controlled power near a PV module with a Maximum Power Point Tracking (MPPT) controller and a DC/DC converter.The production of PV energy on rooftops is described by [34]: 2) Household Load Consumption An agent is allocated to follow up the total home energy demand defined by the set of appliances consumption (lighting, heating, leisure, baking, etc.) [35]: 3) BT Energy Storage Unit Equation ( 5) defines how much power a BT can provide.Charging and discharging its two activities.The same equation describes the BT state of charge, which is limited by its capacity.It depicts the initial and final loading conditions of the system.Finally, (5) shows how much energy is stored in a storage unit over a typical period and under specific conditions [37].

4) Objective Function
An objective function is a mathematical equation for maximizing production benefits.The outcome depends on interdependent factors.It is a formula designed to meet profit and production targets.The goal of this study is to keep the cost of the THA (PV/BT) for a detached house as low as possible over its lifetime (see (6)).The capital cost is given by: The annual cost is given by: The daily cost is given by: The objective function is given by:

5) Energy Balance
The energy balance is centered on the basic thermodynamic principle according to which energy cannot be destroyed, but can be gained, lost, or conserved by a system.The condition achieved when the energy consumption is equal to the energy expenditure is called an energy balance.To reach this standard, it is anticipated that the energy management system will be able to program devices in a flexible manner.As a result, the constraint (7) must be fulfilled at all times [38].

A. Energy Trading Community
The MDP contains a set of states' S(i), including the SOC i , price, and the community price.A set of procedures for each state is set, involving buying or selling different amounts of electricity to the retail market or local power pool.The Q-value Q(s, a) for the various actions when the agent is in the S state is recorded.Q-value learning uses a weighted average of the previous and new data.The agent can choose the actions with the highest Q value.The optimum active combination is provided by (8) [40,41].Equation (8.1) seeks to find the actual state(s) and tends to provide the best combination of action for all rules.Equation (8.2) aims to connect the output groups (N(s)) to the Q value.The Q-learning Trad-Algorithm-1 provides the Energy Trading community, including both smart and Trad users.
where Min(N(s)) signifies the application of the operator to the output groups N(s), q(i, a) is the q value that corresponds to the aggregated rule i for the chosen action a. Next, the action sequence is applied and the new states are acquired by calculating H(s',a) and Q value changes.
where H (s', a) is the maximum function, and the Q value for the new case s', V (s, a, s) and Փ are identical to the ones in (9).Ultimately, the q value will be changed during each operation following (9.3).Where β is the learning rate and w(i, a) refers to the value of truth deformed to the chosen action a according to rule i.

A. System Initialization
The proposed approach suggests that integrating a storage system would be beneficial only if the existing electrical system functions perfectly.The installation of a PV array could save money.According to the optimization problem, a storage system is unnecessary because the power system is perfectly stable.Solar panels have reduced user expenses in two ways.Firstly, during peak hours, smart homes can operate autonomously.Secondly, excess energy can be sold to the power company for a profit.Figures 2(a In peak periods, the grid can provide any deficit power (Figures 2(c) and 2(d)).This section analyzes the effect of renewable energy storage on cost reduction.Anything between 0% and 100% of domestic renewable energy can be stored anywhere.The relationship between storage capacity and cost savings is also examined through the employment of three scenarios: inconsiderable (less than 50%), medium, and large (up to 50%).The total cost of each system is calculated implementing the single-house model when the houses do not exchange energy.Additionally, the proposed algorithm calculates the cost of trading between homes and the utility.Figure 2(f) displays the energy savings to the grid resulting from the price disparity between these two systems.It portrays the relationship between grid savings and homes during peak hours (non-RES).Each house has a minimum amount of energy stored.The life of the storage device is affected by falling below this minimum energy level.To save money and keep energy levels above this minimum, households should charge their energy storage devices in the early slots, even if unnecessary.Inefficient charging of storage devices increases energy costs.Therefore, storage penetration rates above a certain threshold.Adding energy storage to a grid is initially advantageous due to lower energy costs, but this advantage diminishes as storage capacity increases.The energy savings storing energy on the grid are negligible.This article analyzes grid trading and the impact of solar panel penetration on costs and savings.The expenses and protection of energy storage capacity are also discussed.Figure 2(f) demonstrates how the percentage of households with storage devices affects the overall cost of the microgrid.The inefficiency of the load increases energy costs for homes that use storage devices.The cost curves increase with storage penetration, and smaller energy storage reduces overhead.The cost curves increase with storage penetration, and smaller energy storage reduces overhead (see Appendix B).A regional meteorological station provided the most recent measurements of the specified data for 12 hours [1].

B. Case Study: Multi-Houses 1) Results considering Grid without Blackouts
The proposed approach suggests that the integration of an ESS would only be beneficial if the existing electrical system is functioning perfectly.The installation of a PV array could save money.According to the optimization problem, a storage system is not necessary because the power system is perfectly stable.Solar panels have reduced user expenses in two ways.During peak hours, smart homes can operate autonomously.Excess energy can be sold to the power company for a profit.Figures 3(a) and 3(b) depict the sequencing of the PV system and the total number of devices for a typical day when ESSs are used.The PVs and ESSs strive to meet the lunchtime household need.During peak periods the grid can provide the deficit power (Figures 3(c) and 3(d)).This section examines the impact of RES on reducing expenses.The relationship between storage capacity and cost savings is explored using inconsiderable (less than 50%), medium, and large (up to 50%) scenarios.The single-house model calculates the total cost of each system when the houses do not exchange energy.Similarly, the proposed algorithm calculates the cost of trading between homes and the utility.Figures 5(e) and 5(f) show the energy savings to the grid from the price disparity between these two systems.They exhibit the relationship between grid savings and home usage during peak hours (non-RES).Figures 3(e Fig. 3.A typical day without blackouts.

2) Daily Performance Results
Figure 4 reveals how each house in the TOU and RTP cases, benefits from the excess solar energy.Based on the idea behind the proposed method, the results indicate the behavior of each node λ-Connect i and the impact of TOU and RTP parameters.Each home manages its energy consumption during RTP and TOU. Figure 4 displays the best P2P EMS implementation parameters compared to home #λ-Connect1 running independently.House #2 exports PV electricity to house #λ-Connect1 from 11:00 am.At 3:00 pm, the additional PV energy from house #2 is stored in the HBSS of house #λ-Connect1.To reduce duty cycles and degradation costs, the EMS requires the ESS in House # λ-Connect2 to operate less efficiently and more expensively than the HBSS in-house #1. Figure 4(e) discloses that the in-house ESS discharged energy to supply the consumption of House # λ-Connect2 and stored the excess energy.This procedure increases the deterioration cost of the ESS.The reduction in daily energy expenses in house 1 compensates for the rise in battery degradation expenses.Figure 4(h) illustrates that house # λ-Connect2 imports energy from house 2 at no energy sharing costs.House #1 imports energy for free from its surplus from 6:00 am to 11:00 am and from 4:00 pm to 7:00 pm to minimize its reliance on power from the supplier at high rates.At 7:30 am, the rated capacity of the homes) exceeded the surplus (Table I).The PV array is used to meet this additional load.If the energy limit is managed efficiently, the energy consumption of many households (λ-Connect2, λ-Connect6) will not exceed it.This will prevent customers and prosumers from having to purchase expensive energy.Node Connect has been verified in both TOU and RTP modes.

3) Annual Performance Results
Figure 5 demonstrates the way the change in Home # λ-Connect1 annual consumption affects the percentage reduction in the annual cost of EMS for all nodes in the community.It shows that as node λ-Connect1 annual consumption increases, its annual percentage reduction increases.As household #1's annual consumption increases, (a) its annual percentage reduction decreases from 8.2% to 6.0%, (b) its percentage reduction decreases from 11.0% to 9.789% and then remains the same, (c) its percentage reduction decreases to 0.25%, and (d) its percentage reduction increases to 6.0% (see Table IV).Figure 5 indicates that as a node's load in an EMS community increases, most excess generation is used internally, leaving little energy to share with other homes.As in the case of household #1, the percentage reduction in the household's annual energy cost decreases.As a result, other nodes in the neighbourhood (e.g. home # λ-Connect2 and # λ-Connect4) will reduce their annual energy costs due to the lack of energy.Figures 5(c) and 5(d) demonstrate the annual consumption effects with and without outage events.Figure 5(d) presents two smart customer handling and storage processes from T = 0 to ΔT d .Figure 5(e) compares retail and community prices with limited solar penetration.The community price is higher because the local power pool has acquired less solar power.This will limit the return on battery storage devices employed by smart users and will participate in the societal energy trade.Contrary to the idea, only some people will buy electricity from the power pool.The electricity costs for the smart user are also higher than in the first example.Similarly in (Figure 5(f)), the presented algorithm can benefit consumers.The trade actions of both agents are comparable, which indicates the algorithm's reliability.According to Figure 5(d), the proposed approach may lead to cost savings for both users of the energy community.The proposed methodology is solid and pervasive.Fuzzy Q-learning seeks to increase renewable energy usage.For example, the surplus-to-demand ratio is high when solar energy is plentiful in the middle of the day.

4) Low Solar Penetration
To prove that the proposed algorithm increases the use of renewable energy, it is implemented for the case of the addition of renewable energy penetration.In this scenario, local energy pool collects only 30% of solar energy, which could increase the price of the community and reduce participation in the energy exchange (see Figure 6).Intelligent THA agents, trade with the neighborhood's energy pool when there is low solar penetration, as observed in Figure 6(f).The power pool and smart user do not exchange electricity from ΔT c to ΔT d .Community prices increase while solar energy penetration is low.Users then sell or store electricity.The phenomena mentioned above demonstrate the algorithm's accuracy.After empirically learning to maximize energy management, the agent chooses the best version based on the q-value table.Although it is less effective than global optimization, continuous form-free online processes are nevertheless possible.Smart consumers can reduce their electricity costs and make the use of solar energy easier with the help of the proposed methodology.Utilizing the suggested fuzzy Qlearning algorithm, the augmented consumer revenue from the use of renewable energy can encourage renewable energy growth.Neighborhoods' monthly energy costs can be reduced in various ways.An intelligent, energetic community with a community energy pool is thus provided.Effect of changing the annual consumption of House No. 1 on the % reduction of the community pool while participating in the home energy management system with RTP and TOU and with/without outages.

V.
DISCUSSION The price will remain between the finite and retail costs, thanks to the proposed pricing methodology.Statistics showcase that this pricing scheme can help pure energy users reduce their monthly energy expenditure while boosting energy customers' profits.Reinforcement Q-learning can be applied to SG 2.0, e.g. in trading community energy.This ability allows SG 2.0 to constantly improve its methods and options for managing its energy demand.The proposed case study allowed SG 2.0 and renewable home energy generation to be more efficient for both consumers and prosumers.The community power pool will provide cheaper electricity, and smart users can sell the additional power to the community.SG 2.0 can change the user from a consumer to a prosumer.Through storage and control systems, users can engage in the energy market, influencing electricity pricing and boosting profits.The results revealed that reinforcement Q-learning solved the energy demand cost with high and low PV penetration.In this vein, the Q-Learning approach can be used to solve ongoing concerns related to SG 2.0.A typical day with blackouts.Table II displays the results when grid blackouts are considered in the problem.The obtained outcomes are only considered in PV and battery cases.It is noticed that under similar electricity use, the consumer's energy costs are lower than the customers'.Two users and three clients were engaged to assess the algorithm's consistency and accuracy.the electricity usage for all consumers is comparable.Prosumer 1 has a SOC of 0.45, while Prosumer 2 has a SOC of 0.29.The findings derived from these two cases, both with and without the PV and BT can be pinpointed.

VI. CONCLUSION
This article proposes combining Demand Response (DR) using Real-Time Pricing (RTP) with peer-to-peer (P2P) energy trading to lower electricity expenses for prosumers and consumers.An accurate algorithm was initially employed to arrange the timing of smart home gadgets.A complex algorithm was used to maximize photovoltaic (PV), wind, storage, and Electric Vehicle (EV) resources in prosumer areas.In the second stage, users exchange excess electricity with other consumers who source it from the grid.Prosumers can effectively supply power to customers at a fair price by monitoring and identifying surplus power.Implementing P2P energy trading in smart homes successfully reduced costs for users and providers.Consumers 1 and 2 reduced their electricity expenses by 9.023 and 2.689 units, respectively, by obtaining power directly from customers instead of the grid.Prosumers 1 and 2 can reduce their electricity costs by 20.205 and 15.898 units by participating in P2P energy trading.The simulation results demonstrate the efficacy of the proposed method in decreasing power costs for both prosumers and consumers.

Figure 1
demonstrates potential scenarios for distributed energy-sharing villages.The energy scenarios are:  Scenario A is achieved when the community's SHAs are connected with BTs.SHAs can sell any excess energy to the EPU in real time.In a power outage, SHAs purchase additional energy from the EPU.

Fig. 2 .
Fig. 2. (a) Solar radiation (w/m 2 ) during winter and summer, (b) total load consumption and (c)-(d) load consumption during cloudy and sunny days, (e) data available for main grid breakdowns occurring in KSA, (f) TOU and RTP prices taken into account in the simulation during 2022.
) and 3(f) show how the percentage of households with storage devices affects the overall cost of the microgrid.It demonstrates that load inefficiency increases energy costs when using storage devices (cost curves increase with storage penetration).Smaller energy storage reduces overhead.Therefore, storage only saves money with renewable energy sources or microgrid connections.www.etasr.comKhayyat & Ben Slama: Smart Grid 2.0: Modeling Peer-to-Peer Trading Community and Incentives for …
Fig. 5.Effect of changing the annual consumption of House No. 1 on the % reduction of the community pool while participating in the home energy management system with RTP and TOU and with/without outages.
Fig.6.A typical day with blackouts.