P2P Energy Trading: An Optimal Solution for Energy Shortage in Pakistan

Green energy can help in protecting the environment. Moreover, its continuous supply increases the quality of life and indeed the economic development of a country. The power sector in Pakistan is continuously under stress due to the imbalance between the demand and supply of energy. Pakistan has abundant renewable energy resources, i.e., solar, hydro, wind, etc., which are the main elements of green energy. This study first evaluates the existing power sector in Pakistan. Then, we proposed a peer-to-peer energy trading framework that helps in reducing the stress on the power sector in Pakistan by meeting the local energy demands of the consumers with the help of local energy generation. In the proposed peer-to-peer energy trading market, a novel method for determining the uniform energy trading price is proposed. This proposed pricing method increases the utilities of the market participants i.e., saving in energy bills for consumers and profitability for the sellers. The proposed study assumes that solar energy is provided from the energy producer side. Solar energy penetration on various ratios starting from 14% to 35% is tested on environment and consumer satisfaction levels. We conducted comprehensive experiments to validate the proposed method and the results suggest that a 35% penetration of solar in each subdivision can be helpful to decrease the current stress on Pakistans’ power sector. Furthermore, it also helps in reducing the carbon emission footprint.


I. INTRODUCTION
The availability of energy is correlated with rising GDP and also helps to enhance the quality of life [1]. Meanwhile, Pakistan is suffering from a severe shortage of energy due to failure to meet the growing demand from an increasing population and the development of industries and agriculture [2]. To overcome this energy shortage, several reforms were made in the late 90s to develop a stable energy system that ensures reliable access to energy. These reforms involved structural transformations, organizational innovations, and regulatory developments [3]. Under structural The associate editor coordinating the review of this manuscript and approving it for publication was Z. G. Zang . transformation, a state-owned enterprise became vertically unbundled, resulting in the transfer of business structures, i.e., the change from a monopoly system to a single buyer model.
In contrast, organizational innovations led to the creation of administrative institutions such as market operators and regulators [4]. Despite all these struggles and reforms, the energy sector in Pakistan is still under stress. According to the World Bank reports, Pakistan is still facing an energy shortage [5]. For this reason, urban domestic consumers have to face an energy outage(Load shedding) ranging from 8 to 12 hours on a daily basis [5], [6]. The problem of energy shortage in Pakistan is more devastating in rural areas where people face energy outages for about 15 to 16 hours per day [7]. This massive energy shortage results in increasing tariffs, increase in circular debt and deterioration of the quality of life [8], [9]. Besides these effects, it also severely affects the overall performance of the energy sector and creates an alarming situation for economic growth [10], [11]. The consequences of the upsurge of energy shortages have been immense for industrial, retail, and agricultural consumers. The economy of Pakistan has been virtually paralyzed. Only in the textile sector, about 40% of its manufacturing jobs have been badly affected [12].
Various factors such as inappropriate planning, obsolete power plants with inefficient transmission systems, and poor governance are some of the leading causes behind the collapse of Pakistan's energy sector [13], [14], [15]. Besides these factors, political influence, instability, and absence of substantial investments create a lot of hindrance in deploying the hydro projects and increase reliance on the other expensive sources of energy such as imported fuels and natural gas reserves which are also one of the root cause for this energy crisis and increase in energy tariff [16], [17]. The high dependability on fuels and natural gas combustion for the generation of energy also creates many problems with health issues and increases the pollution level in Pakistan. According, to the Air quality index(AQI), Pakistan is the fifth most polluted country globally with an annual PM2.5 average of 74.3µg/m 3 [18]. Moreover, according to the World Bank report, the current utilization ratio of fuel and natural gas reservoirs in the generation of energy will lead to the elimination of these reservoirs by the end of the year 2025 and By the year 2030, Pakistan will run out of natural gas [5]. Moreover, deviant activities such as bribes, corruption, and bureaucratic influence cannot be ignored in the delay or energy crisis [19]. These activities also lead to the result of a poor rate of energy bill recovery [20].
Public awareness is very critical in energy conservation, and sometimes the incentives found will contribute to the effective management of existing resources [21]. National Electric Power Regulatory Authority (NEPRA) also proposed reforms to support public awareness policies such as Net metering, financial incentives, and carbon pricing [22]. Under the proposed net metering policy of NEPRA, an energy consumer is encouraged to generate his energy by employing renewable energy resources and can sell it to the national grid under the mutual agreement and thereby offering them a seamless energy option to their consumers [23], [24]. Geographically Pakistan is abundant in distributed renewable energy resources, i.e., wind, and solar. Proper utilization of such resources can prove an excellent solution to overcome the current energy shortage in Pakistan.
Several studies have been carried out to analyze the energy crisis in Pakistan. The author in [25] estimates that the magnitude of the direct rebound will affect residential electricity consumption. In his proposed work, he used time-series data from the year 1973 to 2016. By deploying the co-integration econometric technique and error estimation, he found that the magnitude of the direct rebound effect is 69.5 percent in the long run, and 42.9 percent in the short run. However, his proposed work does not consider the transmission losses and installed system capacity. In [26] authors presented a detailed review of energy planning and policy formulation in Pakistan.
Zakaria and Noureen [27] used a long-range alternate energy planning model to analyze the structure of the electric power sector in Pakistan. In their proposed work, they used historical data for electricity demand and supply. Their results demonstrate that fuel cost is one of the most dominant factors that influence the overall cost. However, the proposed work was evaluated with the fixed-line loss rate. Another study using stochastic frontier to analyze the cost-effectiveness of energy distribution utilities in Pakistan has been found in [28]. This proposed study evaluated eight distribution utilities having data for the year 2003-2013. The result of this study reveals that distribution companies are 27.5% costinefficient. Moreover, studies found in [2], [3], [21], and [29] provide a general overview of the energy shortage in Pakistan. However, according to the authors' best knowledge, the effect of solar penetration and P2P energy trading is not addressed on Pakistans' premises.
Peer-to-Peer (P2P) energy trading is a new paradigm shift from unidirectional centralized to bi-directional decentralized energy trading markets [30], [31], [32], [33]. Several countries have deployed their pilot projects to transform their existing energy infrastructure [34], [35], [36], [37]. In the P2P energy trading markets, renewable energy sources are used as the main resources to generate green and healthy energy such as solar panels, wind turbines, etc., Renewable energy conversion through artificial photosynthesis has proved an environment-friendly route to harness green energy from sunlight. The processes to convert solar light into useful fuels comprised of photocatalysis, photovoltaic, etc., which rely on the utilization of semiconductors as active photocatalysts and sunlight absorbers for photovoltaic [38]. Photovoltaic devices as renewable alternatives are well explored and can be the best contenders in the energy marketplace. To date, several kinds are introduced and commercialized including amorphous and crystalline silicon (c-Si), a thin film based (CdTe, CIGS, etc), dye-sensitized, and the latest evolution of perovskite solar cells. The current market is dominated by the c-Si solar cells due to their elongated lifetimes (25 years) but they are expensive as compared to other counterpart technologies [39]. Perovskite solar cells (PSCs) are cheaper as compared to the market occupier c-Si, and their power-perweight ratios (PSC; 23WKg −1 ) are far better than c-Si solar cells (0.1WKg −1 ) [40]. Moreover, c-Si is very expensive as compared to perovskite semiconductors as the latter can be synthesized through a facile chemical process involving the alkali-metals such as cesium, lead, methylammonium, etc. In terms of power conversion efficiency, PSCs (25.7%) are comparable to c-Si (26.1%) but the long-term stability and lifetime of PSCs are just a few thousand hours, which are still under experimental investigations but are going to be commercialized in near future [41]. A series of optimizations are reported to enhance the PCE and stability of PSCs including the dopants, organic polymers as moisture resistant, and thin-layered organic interlayers to prevent intrinsic electrical losses such as hysteresis. The action of the organic moiety is always to address the ion migration from where the currentvoltage (I-V) hysteresis usually arises. So, the progressive research to place PSCs near commercialization standards [42] is still underway, and PSCs would be the next photovoltaic market occupiers in near future.
In this context, this study is aimed to evaluate the effect of solar penetration in the East region of Pakistan. This study discusses the energy shortage and proposes a structured framework within the existing infrastructure for energy distribution among consumers. The proposed framework helps to reduce the effect of energy outages on consumers. Also, a uniform pricing method is proposed which increases the revenues of the energy sellers and reduces the energy bills for the consumers. The rest of this paper is organized as follows: Section 2 discusses the existing infrastructure. Section 3 presents the proposed energy trading and distribution infrastructure. In Section 4, the discussion is extended toward the energy market clearing mechanism. The results are discussed in Section 5, followed by a conclusion in Section 6.

II. EXISTING ENERGY INFRASTRUCTURE
The energy sector entities under the governance of the Government of Pakistan are encapsulated in Fig. 1 From this figure, it can be seen that Pakistan has four primary Public and Private energy producers, i.e., Water and Power Development Authority (WAPDA), Pakistan atomic energy commission, Independent Power Plants(IPPs), and Karachi Electric Supply Company (KESC). All energy generation companies (GENCO) utilize energy generation sources, i.e., water, fuel, natural gas, etc., to generate energy according to their installed and operating capacities. After energy generation, the National Transmission and Dispatch Company (NTDC) services are deployed to transmit it to the distribution companies (DISCO). Further distribution companies are responsible for transmitting and distributing the energy at the provincial, regional, and consumers' doorsteps.  This study is limited to the eastern region of Pakistan which is served by LESCO. From now we only discuss the energy facts and figures related to the LESCO.
For the eastern region, Lahore Electric Supply Company (LESCO) is the leading energy supplier. It provides energy to Lahore, Kasur, Okara, Nankana, and Sheikhupura civil districts. This company was founded in 2001 after the vertical integration of the WAPDA scheme, previously known as the Lahore Area Electricity Board (AEB), and its distribution network consisted of sixty-eight 132-kV and fourteen 66-kV sub-stations. Presently, it has one hundred thirty-four 132-kV and seven 66-kV substations [43].
LESCO is divided into nine circles. Each circle is responsible for the transportation of energy to several divisions. Each division is further divided into subdivisions to distribute the energy to the consumers' doorstep. Fig. 2 presents the layout of the LESCO and its interconnected substations. LESCO distributes the consumers into different categories such as domestic, commercial, industrial, agricultural, and public lighting. According to the report [20], the number of consumers in each category is increasing every year. Table 2 presents the 5-year comparisons of category-wise increase in the number of consumers.
With the increasing number of consumers, the consumers' energy demand is also increased exponentially. Table 3 presents the category-wise demand of consumers.
To satisfy the energy demand of consumers, LESCO purchased energy units from several GENCO through NTDC. Table 4 presents the difference in units purchased by LESCO to the sold units along with percentage losses.
In Table 4 units sold column represented the number of units consumed by the consumers along with the lost units due to loss. However, the recovery of the energy bills consumed by the consumers also plays a vital role in the financial condition of LESCO. Energy theft and non-recoverable energy bills also deteriorate the financial condition of LESCO. According to the report [20], the average collection of energy bills by domestic consumers is 98.26% compared to 86.09% for agricultural consumers.  In contrast, the recovery ratio from the commercial and industrial consumers is 98.64% and 93.88% respectively. The overall percentage of recovery for the fiscal year 2016-17 was 99.20% this percentage dropped to 95.93% for the fiscal year 2017-18 due to energy theft cases.
Transmission and distribution losses in LESCO are also increasing every year, leading to complaints about the nominal voltage regulation. Table 5 presents the number of complaints along with percentage transmission and distribution losses over the five years from 2013 to 2018.
As described earlier in Section I, there are 8 to 12 hrs energy outages per day which deteriorates the quality of life. To manage the energy outage, each division cuts the energy supply in subdivisions according to the outage plan of the circles. However, to reduce the energy outage and support a green energy environment, LESCO introduces net metering. Under this concept, each consumer through renewable energy sources can generate their energy, and in the case of excess, they can inject energy into the system. To promote and facilitate this opportunity. LESCO reserves some capacity for net metering in some of its connected divisions [43].
Furthermore, each division also deploys the net metering paths with its connected subdivisions. Using these paths, each consumer in subdivisions generates their energy and injects the excess energy into the subdivisions. This energy is aggregated and distributed at the divisional level with the other subdivisions where it is needed. When subdivisions do not require energy, this energy is injected into the circle where other circles use it or injected into the national grid. The amount of energy injected by the consumers depends on the consumers who use renewable energy sources, i.e., solar, wind, biomass, etc. This is along with the line capacity available for net metering. Fig. 3 and Fig. 4 show the numbers of consumers in each subdivision along with the capacity available for net metering.

III. PROPOSED ENERGY INFRASTRUCTURE AND ITS MODELING
The proposed energy infrastructure is shown in the Fig. 5.
It can be seen that LESCO is considered an energy market M . This energy market M is segmented into several segments m i such that m i ⊆ M . A segment m i can be referred to as a circle. A circle m i is further divided into several divisions D j such as D j ⊆ m i . Each division D j is further divided into several subdivisions SD k such that SD k ⊆ D j . There are several consumers C who demand energy in each subdivision, and there are several producers P who have the capacity and VOLUME 10, 2022 89618 VOLUME 10, 2022 installed infrastructure for the generation of energy using renewable energy sources, i.e., solar and wind.
From the above information, the general mathematical formulation of LESCO can be represented as: The proposed system assumes that in each subdivision SD k , there is a sub-divisional coordinator, a virtual system. The energy consumers and producers can interact with each other through the sub-divisional coordinator. The main objective of the sub-divisional coordinator is to handle and monitor the energy trading activities inside the subdivision only. Energy trading activities of the sub-divisional coordinator include keeping a record of the energy demand requested by the consumers and energy supply by the producers. One more key responsibility of the sub-divisional coordinator includes determining the participants' energy trading price and making sure the accessibility of the energy according to his decision in the case when there is no energy availability from the grid. However, in the case of grid availability, the sub-divisional coordinator makes sure that energy supplied by the energy producers can be traded with the other peer subdivisions.
To avail this opportunity, each energy consumer or producer first registers him/herself in the sub-divisional system. For registration as an energy consumer, a consumer C i should submit the required information, i.e., name, address, balance of energy tokens in their wallet, to the sub-divisional coordinator. When registering as an energy producer names and addresses are proposed. Energy token is just like a virtual currency that can be purchased from sub-divisional offices after making payments. One energy token is used for one-kWh energy trading.
Smart meter technology is an efficient way to keep a record of energy demand and energy supplied by the participants [44], [45]. Therefore, in the proposed system, it is assumed that both energy consumers and producers will have smart meters at their premises. At any time t an energy consumer C i is supposed to submit the information about his demand E dem , whereas an energy producer P i is supposed to submit the amount of energy E sur he/she is willing to trade with others along with the offered price Tp off .
Due to stochastic and seasonal variation of renewable energy sources, i.e., solar the supply capacity of energy producers is limited; it is impossible to meet all the consumers' energy demand (E dem ). To handle this challenge, the sub-divisional coordinator instructs the energy consumers to submit their demand and the need for energy factor ξ . This need for energy parameter ξ can vary ranging from 0 to 1. From the reported values of energy factor, ξ three types of energy users are identified by the sub-divisional coordinator as (i) Low demand consumers, (ii) Medium demand energy consumers, and (iii) High demand energy consumers. Based on the gathered information sub-divisional coordinator will determine the energy trading price TP which will be discussed briefly in Section IV-A and distribute the energy among the consumers.
Both energy consumers and producers under the proposed system use LESCO's infrastructure for the transmission and distribution of renewable energy. Therefore, each sub-divisional coordinator will impose some fee (φ) in terms of service charges for managing and transportation of energy. Half of this service fee φ applies to energy consumers and the other half is imposed on energy producers. However, rationality and false reporting about the demand of consumers cannot be ignored. Therefore, handling this challenge and restricting false reporting sub-divisional coordinator imposes some extra fee θ rather than the service charges on those energy consumers who report high energy factor ξ . By doing this, the proposed system reduces the effect of false reporting and treats everyone equally. The proposed system gives high preference to those energy consumers whose need for energy factor ξ is high. Giving preference to those consumers is based on the fact they are paying more than the other consumers, and it is most beneficial for the sub-divisional revenue gathering terms.

IV. MARKET CLEARING MECHANISM
Market clearing plays a significant role in the energy trading platform as it incentivizes the participants to participate in energy trading activities. Time of usage of energy also has a dominant effect on the market clearing mechanism. Many researchers proposed several methods to determine the market-clearing price, such as a mixed-integer-based linear method proposed in [47] to determine the market-clearing price. In [48] Benders-like decomposition method is proposed for determining the market-clearing signal. Bi-level modeling is used in [49] to determine the market-clearing signal. Competition is an effective way to increase the trust level in the energy trading platform and motivates the participants to participate in energy trading activities that have not been addressed in these studies.
Considering the effects of competition, several researchers used a double auction mechanism in their studies to find the pricing signal [50], [51], [52], [53]. In these studies, a producer offered price should be less than the grid selling price. Although it is an effective technique to increase consumers' savings because consumers' purchase prices will be less than the grid selling price. However, it is not always a good option for energy producers to offer their prices less than the grid selling prices. Especially in the case when there is an uninformed outage from grid supply. This situation creates an opportunity for energy producers to generate high revenue.
In this context, we proposed a novel method inspired by MinMax method [54] which incorporates the competition among the energy producers to select the market-clearing signal.

A. PROPOSED MARKET CLEARING MECHANISM
As stated in Section III, each producer will inform the sub-divisional coordinator about the amount of energy  τ he is willing to trade with others along with the offered price Tp off . Based on the amount of energy E sur sub-divisional coordinator will make sets for the producers such as: 89620 VOLUME 10, 2022 where P i represents a producer who contributes more energy compared to the others and TP i is associated with his/her offered price. Similarly, each consumer also informs the sub-divisional coordinator about the energy factor ξ , which determines how much energy an energy consumer needs. At the time (t), when all consumers and producers submit this information to the sub-divisional coordinator need to find out the number of consumers who requested high energy levels among the available consumers. From the subdivisional point of view, a consumer having high ξ has a strong energy demand; for this type of consumer price of energy does not matter. Such consumers' selection reflects that they put the high energy supply producers at the topmost front compared to the other producers who are offering low energy. Whereas a consumer having a small value for ξ is considered more sensitive to the price of energy. In such types of consumers, they give high preference to such producers who offered the lowest price among the others. In this manner, the sub-divisional coordinator computes the score for all energy producers. Let us suppose that SC(P 1 , P 2 ) represents the pairwise score for producer P 1 against producer P 2 then the producer P win is selected as the winner by the MinMax method given as: As the sub-divisional coordinator uses ranked pairs among the available producers, there are three variants: winning votes, Margin, and Pairwise opposition are used in the proposed method to determine the winner producer. Based on sub-divisional evaluation let d(P 1 , P 2 ) be the number of consumers who rank P 1 over P 2 . These variants define the number score SC(P 1 , P 2 ) for energy producer P 1 against P 2 as: Eq. (4) represents the number of consumers' preferences P 1 over P 2 , in the case when the score increases the number of consumers who prefer P 2 over P 1 . If not, then the score for P 1 against P 2 will be zero. This variant is known as winning votes.
Eq. (5) is known as the margin variant which defines the number of consumers preferences P 1 above P 2 minus the number of consumers preferences P 2 over P 1 . Eq. (6) describes the third variant which is called pairwise opposition and it is defined as the number of consumers' preferences P 1 over P 2 regardless that more consumers prefer P 1 over P 2 or vice versa.
In the proposed market clearing mechanism, a subdivisional coordinator will select an energy producer P i as a winner who satisfies either all three variants or at least two.

V. PROPOSED SYSTEM OBJECTIVES 1) CONSUMERS' OBJECTIVES
Every consumer expects that there would not be an outage in the supplied energy so that he/she can run the daily routine life activities uniformly. Moreover, the energy price should be low so that he/she does not face any financial burden while using energy. However, in the case of limited energy supply and uninformed energy outages from the grid, it creates many problems to run their daily routine activities. In this case, the price of energy dominates over the availability of energy; hence consumers' first objective is to procure the energy on a prior basis when there is no energy supply from the grid. For this reason, a consumer has a higher price tolerance if the system ensures the supply of energy to them. If ω is the factor that measures the availability of energy to the consumers, then consumers' satisfaction level SL con will be equal to 1 if ω = 1 and will be 0 otherwise. From the consumers' perspective, the objective function of a consumer can be written as: 2) PRODUCERS' OBJECTIVES Energy producers' are the entities that generate their energy using renewable energy sources. This produced energy is meant for their usage along with trading with others in the case of surplus. Suppose an energy producer generates an amount of E gen by employing renewable sources, and E selfcon is the self-consumption of a producer. In that case, the surplus energy he/she can trade with others can be found as: While trading this surplus energy, a producer prefers to sell it at a high price to increase his/her revenue. In terms of revenue, the objective function of an energy producer can be expressed as: To achieve high revenue, the amount of energy a producer can produce plays a significant role. In the proposed study, we only consider that the producer uses a solar panel on their  rooftop to generate clean energy. In the production of solar energy, the environment also plays an important role. The proposed study is on the premises of the East region of Pakistan called Lahore. This region is one of the most feasible places in Pakistan for deploying solar panels due to its workable temperature range and sunlight duration. Based on the data gathered from [46] Fig. 6 shows the average temperature range along with the sunlight duration throughout the year 2018.
Besides the weather condition, the installed system capacity and its associated losses are essential factors for determining the accurate estimation of the generated solar energy.  For assessment of the generated solar energy, the proposed method uses the following equation for solar energy generation given as: where A represents the total solar panel area measured in (m 2 ), r is the solar panel efficiency, H is the annual solar radiation, and PR is the performance ratio. To achieve a more accurate estimation of solar energy, inverter losses, temperature losses, DC and AC wire losses are also considered.

3) SUB-DIVISIONAL COORDINATORS' OBJECTIVES
In the proposed system, the objectives of the sub-divisional coordinator include energy trading among the participants keeping in view the existing power system reliability and efficiency. If E dem and E sur are the total demand requested VOLUME 10, 2022 by the consumers and total energy supplied by the producers respectively, then the power balance equation can be written as: where ∆ represents the transmission and distribution losses. At the time (t) after gathering the information about the consumers' energy factor ξ and producers' injected energy E sur sub-divisional coordinator first determines the market clearing signal TP as described in Section IV-A. At any time interval, t the positive value of Eq. (11) represents the case when there is excess in demand, and less supply is available. In such a case, when the market-clearing signal is less than the grid selling price, then the sub-divisional coordinator will distribute the energy demand among the consumers so that their energy bills can be reduced. The difference in energy will be imported from the grid so that consumers' satisfaction level which is measured in terms of the availability of energy in the proposed study, can be maximized. The objective function of the sub-divisional coordinator can be expressed as: However, when the market-clearing signal value is higher than the grid selling price and grid supply is also available, the sub-divisional coordinator will make sure that the offered energy will be traded with his peer sub-divisional coordinator or injected into his division. In this case, if grid energy is not available sub-divisional coordinator will distribute the offered energy to their energy consumers to maintain the power balance equation Eq. (11). In the case when the local sub-divisional generated energy is insufficient to meet the energy demand sub-divisional coordinator will import the energy from his peer sub-divisional coordinator to maintain the power balance in Eq. (11) or try to keep the minimum difference between the demand requested by energy consumers and their supplied energy. In limited energy availability, a sub-divisional coordinator will first distribute the energy to the high energy demand consumers before filling the others.

VI. DISCUSSION OF THE RESULTS AND SUGGESTION
In this section, we present the results of the proposed model and provide suggestions. For this purpose, we used the eastern city of Pakistan, i.e., Lahore, where LESCO operates as DISCO. LESCO is divided into nine circles having thirty-nine total divisions and each division having multiple sub-divisions. This proposed model is evaluated on the Lahore 1st circle which is divided into six divisions and twenty-six subdivisions. The data includes energy consumers' demand, the number of consumers, the capacity of the net metering path, transmission , and distribution losses in each subdivision taken from LESCO officials and NTDC websites. The temperature data used to calculate solar energy generation is obtained from Climate Change Knowledge Portal [46]. The CO 2 emission values produced by the coal and natural gas-driven power plants are used as 0.55kg per kWh [57]. For energy demand data, we equally distribute the total population in a subdivision into three types to classify energy consumers. From this, we get three types of energy consumers (i) Low energy demand consumers having demand from (2.5kWh to ≤ 3kWh) (ii) medium energy demand consumers (3kWh to ≤ 4kWh) and (iii) high energy demand consumers (demand ≥ 4kWh). Losses that have been considered in this work such as Ac and Dc cable losses, inverter losses, and temperature losses are selected according to the guidelines provides in [55], [58], and [59]. The effect of temperature on solar energy generation is taken from [59]. The efficiency of the inverters is assumed to be 95%. For the sake of simplicity, we assumed that the low energy demand consumers have a low energy factor 0 ≤ ξ ≤ 0.4. Energy need factor for medium energy users varies from 0.4 ≤ ξ ≤ 0.7 and the value of ξ varies from 0.7 ≤ ξ ≤ 1 for high energy demand consumers.
For solar generation, we first take 14% of the population in a subdivision and divide the energy producers into three types (i) Low-level energy producers who use solar panels of capacity 3.3kWh (ii) Medium-level energy producers who use a solar panel of capacity 5kWh and (iii) High-level energy producers who use a solar panel of capacity 7kWh then we increase the solar penetration up to 20% and 35% of the population size in the subdivision. Furthermore, in the proposed work, we do not consider the effect of storage elements, i.e., batteries. This selection is made intentionally as the authors assumed that setup required with storage elements is expensive due to battery cost, and battery degradation cost and also has a very long payback period [56]. The consumers' energy demand and producers' solar-generated energy are sampled over a 30-minute time interval for a year.
Grid selling price is considered as 4¢/kWh. Service charges for all types of consumers are considered as 1¢/kWh and additional charges imposed only on high energy demand, and medium energy demand consumers are 2¢/kWh and 1¢/kWh respectively. The proposed model is evaluated by measuring the consumers' satisfaction level, which increases with the availability of energy supply in the case when grid supply is not present. For this purpose, we first considered the solar penetration of about 14% of the total population in a subdivision and discussed the total percentage utilization of the net metering path capacity. Then solar penetration level is increased from 14% to 20% and 35%, and with this increase, some suggestions will be provided in the context of a recommended net metering capacity path by evaluating the consumers' satisfaction level. Table 6 presents the LESCO 1st circle facts and figures about the number of consumers, available capacity for net metering, along with line losses.
From Table 6, it can be seen that some of the subdivisions do not have a dedicated net metering path. For such types of VOLUME 10, 2022  subdivisions in the proposed work, we assumed the value as 6.18 (MWh).
LESCO will maintain the balance between the demand and limited supply of energy. An energy outage has occurred at the subdivisional level. To experiment, we assumed that if a division consists of N subdivisions, then at time t only N /2 subdivisions will avail the energy from his divisions. Moreover, if grid supply is available at subdivision i then his peer subdivision j will face the energy outage from the grid. On these bases, the experiment is performed over the data of one year.
To demonstrate the working of the proposed model, we first take a random division (Badamibagh) and its associated subdivisions from Table 6 and explain how our proposed model is working. There are four subdivisions associated with the Badamibagh division named Data Nagar, Shadbagh, Chahimran, and Wasanpur. From this information proposed model makes two pairs of peer subdivisions as pair-1(Datanagar ←→ Shadbagh) and pair-2 (Chahimran ←→ Wasanpur). So in these pairs, if grid supply is available in one subdivision, then there will be no grid availability in the second subdivision. Take random time slot t = 17 in daylight the energy consumers in the Data Nagar subdivision submit information about the demand for energy to the sub-divisional coordinator along with the need for energy factor ξ . The total energy demand of energy consumers at the sub-divisional coordinator is E dem = 30.5614 MWh. This demand includes the energy demand for type-1 consumers having ξ = (0 − 0.4), type-2 having ξ = (0.4−0.7) and type-3 having ξ = (0.7−1). As we equally distribute the total population into three equal parts, each type of energy consumption is about 33.33% of the total population. All energy producers also submit the amount of surplus E sur they have along with the offered prices Tp off . The total surplus energy available at the Data Nagar with 14% solar generation including line and other losses such as inverter losses, AC and DC wire losses, Temperature losses is E surplus = 4.3348 MWh. The grid availability at this time slot t = 17 is found to be 0 at the Data Nagar subdivision. For the sake of simplicity, we assumed that the energy producer of Type-1 offered their prices at 5¢/kWh the offered prices of type-2 and type-3 are assumed to be 5.4¢/kWh and 6¢/kWh respectively. The same prices are also assumed in other subdivisions. From this information, the sub-divisional coordinator firstly determines the market-clearing price TP.
Since we equally distribute the total population into three types of consumers so in this way each type of consumer i.e., type-1 to type-3 are each representing 33.33% of the total population of Data Nagar. Based on this, the sub-divisional coordinator first makes a list that reflects the selection of energy producers for each type of energy consumer. The selection list of energy producers can be represented as: Type From Eq. (13), it can be seen that type-3 energy demand consumers highly prefer high energy producers because they want to fulfill their energy on a prior basis and for this, they initiated the high energy producers to inject their energy into the system so that the consumer energy needs can be fulfilled. Whereas low-demand energy consumer-prefer type-1 producers because their prices are low. The Table uses Eq. (4) to Eq. (6) to find out the winning energy producers so that his offered price will be selected as the trading price T p . In Table 7, 'A' represents the energy consumers who prefer the energy producer listed in the column to the energy VOLUME 10, 2022 producers listed in a row. 'B' represents the consumers who prefer the energy producer listed in the row to the energy producer in the column. From Table 7, it can be seen that the energy producer of type-2 is winning the most in all variations described in Eq. (4) to Eq. (6). Therefore sub-divisional coordinator will use their offered price as the market-clearing price Tp. Now, the total surplus available at the sub-divisional coordinator is E sur = 4.3348 MWh, but the total demand requested by energy consumers is E dem = 30.5614 MWh. About these two values, the deficit between the demand and available surplus is 26.2266 MWh. As grid supply is not available, the sub-divisional coordinator will import the energy with his peer sub-divisional coordinator Shadbagh.
In Shadbagh, grid supply is available; therefore, energy generated by the producers can be sold in his peer subdivision. The total available surplus at Shadbagh subdivision at 14% solar penetration is found to be 4.2777 MWh.
By importing this amount of energy, the energy difference between demand and supply at Data Nagar will reduce from 26.2266 MWh to 21.9489 MWh. However, there is still a large difference between the requested demand and the available surplus that is not fulfilled as there is no source available from where the energy can be imported. For distributing this energy the sub-divisional coordinator first considers type-3 consumers as they are paying more. After fulfilling the type-3 VOLUME 10, 2022 consumers if some energy will be left it will be distributed among type-2 and type-1 consumers respectively. The same process is repeated with an increase in penetration of solar from 14% to 20% and 35%. Based on the findings, Fig. 7 presents the satisfaction level of the energy consumers for one day in these three solar penetration ratios.
From Fig. 7(a), it can be seen that by deploying the solar at 14% only partial need for energy demand for consumer type-3 is fulfilled. Whereas if the solar penetration is increased from 14% to 20%, most of the demand for consumer type-3 is fulfilled. However, if a further increase is made from 20% to 35% energy demand of type-3 consumers is 100% fulfilled whereas the energy demand for the type-2 consumer is also fulfilled as shown in Fig. 7(b)(c). Moreover, in some instances, the energy consumption of type-1 also gets the energy from the proposed system. By using the solar penetration of 14% total 99.75% line capacity of net metering will be used. However, if the solar penetration is increased from 14 to 35%, the recommended line capacity for net metering is 8-MWh with a utilization factor of 97%. The proposed model is evaluated on oneyear data. Fig. 8 presents the satisfaction level of energy consumers for one year. From Fig. 8(a), it can be seen that by using solar penetration at 14%, the satisfaction level for type-3 consumers is increased from 992 to 1223.44, which presents a 23.33% increase in the satisfaction level. However, compared with the baseline value of 1488, there is a reduction in satisfaction level of about 17.7795%. This is because the proposed system is not using the storage devices which provide energy in the absence of solar light. Table 8 compares the total satisfaction level for one-year data of all types of consumers by using the solar penetration from 14% to 35% in the Data Nagar subdivision.
A similar process is carried out at time slot t = 19 when there is no grid supply at the Shadbagh subdivision. At this time, Data Nagar will provide its surplus energy. Fig. 9 presents the satisfaction level for consumers at subdivision Shadbagh for one day.
From Fig. 9(c), it can be seen that 35% solar penetration affects more on all types of consumers. The solar penetration and its effect on consumers' satisfaction level over one year are presented in Fig. 10. The percentage change in satisfaction level of consumers for one other solar penetration can be observed in Fig. 10 and Table 9.
Solar penetration effects on other divisions are presented in Fig. 11 and Fig. 12. From these figures, it can be well observed that solar penetration at the rate of 35% has a significant impact on the energy consumers' satisfaction level as it meets all the energy demand for the type-3 and type-2 energy consumers along with partially fulfilled demand for energy type-1 consumers. Regarding 35% solar penetration Table 10 provides recommended capacity for net metering at each subdivision with its percentage utilization factor.
Based on the trading price TP, the total revenue earned by the energy producers after paying grid charges is shown in Fig. 13(a). Fig 13(b) and (c) are presenting the grid revenues and reduction in CO 2 by using solar energy. It can be seen that the 35% utilization of solar energy not only increases the consumers' satisfaction level but also reduces CO 2 emissions.

VII. CONCLUSION
Continuous energy supply is mandatory for a better quality of life and also for economic development in any country. In this paper, we consider Pakistans' current energy shortage as a case study. Since 1990, there are about 8 to 12 hours of energy outages in a day. Therefore, this creates a lot of problems for the people in Pakistan and is a great hindrance to the countrys' economic growth. For this problem, we first evaluate the existing energy infrastructure of Pakistan. Then keeping in view the present challenges and issues, a peer-topeer energy trading model is proposed. In the proposed peerto-peer energy trading platform, we proposed a novel method for determining the uniform pricing for energy trading among participants. The proposed pricing scheme brings fairness to an energy market by promoting competition among the energy sellers and increases the utilities of the market participants i.e., reduction in energy bills for consumers and an increase in profitability for sellers. In the proposed work, the energy producers are assumed to deploy solar panels for their energy production. Moreover, the generated energy is traded with others through the sub-divisional coordinator. Different solar penetration starting from 14% to 35% is tested, and the finding reveals that 35% solar penetration helps a lot to meet the energy demand of the consumers during the daytime. Also, this 35% solar penetration has remarkable effects on the reduction in CO 2 emissions. In the proposed work some factors have not been discussed so far which may have significant effects such as batteries and storage constraints, financial and participants' privacy concerns, etc. Further, blockchain can be deployed in the proposed work to make a tamper-proof financial transaction system. These factors will be considered in future work to make the proposed system more effective.