## 3 Proposed Scheme for Prosumer-Based Energy Sharing
### Problem Formulation  
In the proposed scenario, the total number of prosumers is \(I\), indexed by \(i\). There are \(N\) suppliers with surplus energy \(\Phi_{n}\) and \(M\) users with an energy shortage \(\psi_{m}\) so that \((N+M)\subseteq I\). The problem is to optimize the power in \(j\)th hour and share the energy among the users so that the shortage is minimized by maximum utilization of surplus energy. This requires finding the shortage/surplus energy of each user, which naturally leads us to following Equations. \[\tau_{ij}=\beta_{ij}+G_{ij} \tag{1}\]  
\[\Phi_{nj}=\tau_{nj}-\xi_{nj}\ \forall\ \tau_{nj}>\xi_{nj} \tag{2}\]  
\[\psi_{mj}=\tau_{mj}-\xi_{mj}\ \forall\ \tau_{mj}<\xi_{mj} \tag{3}\]  
where,  
\(\tau_{ij}\) is the total energy of the \(i\)th user in \(j\)th hour. \(\beta_{ij}\) is the renewable energy (kW) of the \(i\)th user in \(j\)th hour. \(G_{ij}\) is the grid energy (kW) of the \(i\)th user in \(j\)th hour. \(\xi_{nj}\) is the consumption (kW) of the \(i\)th user in \(j\)th hour. \(\Phi_{nj}\), \(\Psi_{mj}\) are the surplus and shortage of energy respectively. Note that there are a number of options available to the selling user. Users may prefer to sell energy only if they possess more renewable energy than required, e.g., the user may switch off the expensive grid power if sufficient solar power is available and sell only if there is surplus renewable energy. However, for simplicity, we assume that the users want to sell any form of surplus energy available to them. The problem has been formulated in such a way that maximum possible surplus energy is allocated to those with a shortage. Furthermore, the total price associated with surplus energy is taken into account. This in turn ensures that the selling users with minimum prices are selected by the optimization algorithm. As we will see later, the relative importance of maximizing the allocation of surplus energy to the users with a shortage and minimizing the associated price can be controlled. The total price associated with \(n\)th selling user in the \(j\)th hour is:  
\[\zeta_{nj}=\Phi_{nj}C_{nj} \tag{4}\]  
Figure 2: Prosumer-based energy sharing. where \(C_{nj}\) is the per unit price. The objective function becomes:  
\[\min\sum_{n=1}^{N}w\zeta_{nj}x_{nj}-\Phi_{nj}x_{nj} \tag{5}\]  
subject to  
\[\sum_{n=1}^{N}\Phi_{nj}x_{nj}\leq\sum_{m=1}^{M}\psi_{mj} \tag{6}\]  
\[0\leq w\leq 1 \tag{7}\]  
\[x_{nj}=\left\{ \begin{array}{ll}1,&if\text{ }energy\text{ }of\text{ }user\text{ }n\text{ }\text{ }\text{is committed in time slot }j\\ 0,&\text{otherwise}\end{array} \right.\]  
Note that in Equation (5) price of the energy being sold, \(\zeta_{nj}\), is minimized while utilization of surplus energy, \(\Phi_{nj}\), is maximized. In other words, the objective here is to allocate the surplus energy to the users with a shortage as much as possible while at the same time choosing those surplus options which are at a lower price. This in turn minimizes the demand-supply mismatch while taking into account price of surplus energy. The weight '\(w\)' in Equation (5) is used to control the bias between \(\zeta_{nj}\) and \(\Phi_{nj}\). If shortage is to be minimized at any cost, then the variable '\(w\)' takes a value of zero. Note also that the users with a shortage will be dealt one at a time based on any of the following criteria. 1. Give priority to the user according to a single criterion. We have chosen capacity of renewable energy for this, as such users offer greater share in PESM. This approach motivates the other users to install or increase the renewable resources. However other criteria are also possible such as price of surplus energy, contribution of surplus energy in last 24 h etc. 2. Another approach is to use multiple criteria. We have used capacity of renewable energy, price of surplus energy and contribution of surplus energy in 24 h for this purpose. The user that contributed more as compared to others according to above-mentioned criteria gets higher priority.