## 3 Transactive DR Based on Flexibility Potential Evaluation
### Pre-Dispatch Optimization  
In order to effectively evaluate the flexible multi-energy resources of each aggregator, day-ahead pre-dispatch is performed according to the predictive wind-solar and load demand. Prosumer aggregators act as price-takers in order to buy or sell electricity from or to the distribution system operator, while optimizing its own flexible multi-energy resources. (1) Objective function: The objective function of the prosumer aggregator is the minimization of the system's operational costs, including the power procurement cost \(PC_{t,n}\) and the battery degradation cost \(BC_{t,n}\). \[\min\text{F}_{n}=\sum_{t\in\{1,\cdots T\}}(PC_{t,n}+BC_{t,n}) \tag{40}\]  
\[PC_{t,n}=(\mu_{\text{buy},t}E_{buy,t,n}-\mu_{\text{sell}}E_{sell,t,n})\Delta t \tag{41}\]  
\[BC_{t,n}=(E_{\text{ch},t,n}+E_{\text{dis},t,n})\mu_{BES}\cdot\Delta t \tag{42}\]  
(2) Power-flexible loads: The power of load \(P_{pf,t}\) can be shifted within the installed capacity in constraint (43), and is expected to ensure the lowest working value \(EP_{0}\) in (44). \[P_{pf,\min}\leq P_{pf,t}\leq P_{pf,\max} \tag{43}\]  
\[\sum_{t\in\{1,\cdots,T\}}P_{pf,t}\cdot\Delta t\geq E_{p0} \tag{44}\]  
(3) Time-flexible loads: The operation time can be shifted with constant power \(P_{pf0}\) in constraint (45). Depending on the operating mode, they can be divided into two subtypes, including time-continuous and time-discontinuous loads. The work time of time-discontinuous loads could be arbitrarily adjusted within the predefined working time \(t_{1}\), as enforced in constraint (46). The time-continuous loads must continuously work to satisfy the predefined working value \(t_{2}\), as is shown in constraint (47). \[P_{tf,t}=u_{k}\cdot P_{tf_{0}} \tag{45}\]  
\[\sum_{t\in\{1,\cdots,T\}}u_{t}=t_{1} \tag{46}\]  
\[\sum_{r=t}^{t+t_{2}}u_{r}\geq t_{2}\cdot(u_{t+1}-u_{t}) \tag{47}\]  
where \(u_{k}\), \(u_{t}\), \(u_{r}\) are the ON/OFF state variable. (4) Temperature-flexible loads: The operational temperature of these loads \(T_{tf,t}\) can be adjusted within certain limits. The operational temperature is calculated and determined via the outside temperature, colliding power and heating power, as shown in constraint (49):  
\[T_{tf,t}=T_{tf,t-1}+\alpha_{1}(T_{out,t}-T_{tf,t-1})-\alpha_{2}\cdot H_{fcool,t}+\alpha_{2}\cdot H_{tfheat,t} \tag{48}\]\[T_{\min}\leq T_{tf,t}\leq T_{\max} \tag{49}\]  
(5) Switchable loads: This load can be switched into electrical mode or gas mode according to the energy price. Generally, this load would operate at a fixed power \(P_{80}\) or gas \(G_{80}\), as expressed in (50) and (51). Constraint (52) shows the lowest working value \(E_{80}\). \[PC_{t,n}=(\mu_{\text{buy},t}E_{buy,t,n}-\mu_{\text{sell}}E_{sell,t,n})\Delta t \tag{41}\]0  
\[PC_{t,n}=(\mu_{\text{buy},t}E_{buy,t,n}-\mu_{\text{sell}}E_{sell,t,n})\Delta t \tag{41}\]1  
\[PC_{t,n}=(\mu_{\text{buy},t}E_{buy,t,n}-\mu_{\text{sell}}E_{sell,t,n})\Delta t \tag{41}\]2  
where \(v_{t}\) is a switchable state variable. (6) Multi-energy station: The SOC of the battery, heat, and gas storage tanks are expressed in (53), and these ranges are limited in (54) and (55). \[ \begin{bmatrix}SOC_{e,t}\\ SOC_{h,t}\\ SOC_{g,t}\end{bmatrix} = \begin{bmatrix}SOC_{e,t-\Delta t}\\ (1-\eta_{w})SOC_{h,t-\Delta t}\\ SOC_{g,t-\Delta t}\end{bmatrix} + \begin{bmatrix}(\eta_{ch}E_{e,e,h,t-\Delta t}- E_{e,dis,t-\Delta t}/\eta_{dis})\Delta t/E_{bes}\\ (E_{h,e,h,t-\Delta t}-E_{h,dis,t-\Delta t})\Delta t/E_{heat}\\ (E_{g,e,h,t-\Delta t}-E_{g,dis,t-\Delta t})\Delta t/E_{gas}\end{bmatrix}  \tag{53}\]  
\[E_{i,e,h,t}\leq E_{i,ch,\max} \tag{54}\]  
\[ \begin{array}{c}SOC_{e,min}\leq SOC_{e,t}\leq SOC_{e,\max}\\ SOC_{h,min}\leq SOC_{h,t}\leq SOC_{h,\max}\\ SOC_{g,min}\leq SOC_{g,t}\leq SOC_{g,\max}\end{array}  \tag{55}\]  
(7) Multi-energy flow constraints: the supply and demand of multiple energy carriers must be balanced. According to its connection and energy flow, it can be formulated as (56). \[