## 4 Mathematical Implementation of the Problem
### Technical and Economical Constraints
#### GB constraints in H-MG n  
The limit of the power generated by GB is shown in Equation (60). \[0\leq P^{GB}_{h,ht,n}\leq\bar{P}^{GB}_{h,ht,n} \tag{60}\]  
Equation (61) shows the cost resulting from thermal power generated by GB while Equation (62) presents the amount of fuel consumed using GB and Equation (63) determines the price bid range for selling power through GB. \[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]\[FU_{h,n}^{GB}=\frac{P_{h,ht,n}^{GB}}{\xi_{ht}^{GB}} \tag{62}\]  
\[CO_{h,ht,n}^{GB}\leq\pi_{h,ht,n}^{GB}\leq 2\times CO_{h,ht,n}^{GB} \tag{63}\]  
The revenue resulting from thermal power sold by GB is shown in Equation (64). \[U_{h,ht,n}^{GB}=\pi_{h,ht,n}^{GB}\times P_{h,ht,n}^{GB} \tag{64}\]  
Equations (65)-(67), respectively, are the functions regarding GB pollution, the cost of pollution causing by purchasing from GB, and the cost of fuel consumed. \[E_{h,i}^{GB}=\psi_{1E}^{\ i}\times(P_{h,i}^{GB})^{2}+\psi_{2E}^{\ i}\times(P_{ h,i}^{GB})+\psi_{3E}^{\ i},\hskip 28.452756 pt(\psi_{1},\psi_{2},\psi_{3})_{E}^{ i}\epsilon R^{+} \tag{65}\]  
\[CO_{h}^{E,GB}=\alpha_{i}^{GB}\times E_{h,i}^{GB}\times\Delta h \tag{66}\]  
\[CO_{h,F,i}^{GB}=\pi^{F}\times P_{h,i}^{GB}\times\Delta h \tag{67}\]  
**Consumer constraints DR constraints**  
Equation (68) shows that the amount of shift-able power must be less than or equal to the difference between the total consumed power and the total generated power. The linear inequality in Equation (69) indicates the amount of available power that can be allocated to the DR. Equations (70) and (71) show that the DR limit between two consecutive intervals must not exceed a certain value. \[P_{h,n}^{DR_{d}}\leq(P_{h,n}^{TGP}-P_{h,n}^{TCP}).(m_{h,n}^{DR_{d}}) \tag{68}\]  
\[P_{h,n}^{DR^{ch}}\leq(P_{h,n}^{TGP}-P_{h,n}^{TCP}).(1-m_{h,n}^{DR_{d}}) \tag{69}\]  
\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]0  
\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]1  
The appliances of H-MGs in each time interval \(n\) are divided into two divisions, namely essential as non-shift-able (NSH), and shift-able. Let \(\vartheta_{Tot,n}=[P_{n,h}^{APP(\gamma)}]\) be the total load of H-MG n, at time h. In addition, \(APP(\gamma)\) is \(\gamma\)th appliance and \(APP(NSH)\) is the set of all \(NSH\) (non-shiftable) appliances. Equation (72) denotes the total load demanded/produced of H-MG n at time h.  
\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]2  
In Equation (73), \(PO_{n,h}^{APP(\gamma)}\) is expressed as demand position vector of load \(APP(\gamma)\) of H-MG n at time h. If \(PO_{n,h}^{APP(\gamma)}=0\), the \(APP(\gamma)\) has been shifted to another time, otherwise it equals 1. \[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]3  
For each H-MG n at time h, DR constraints consist of three divisions, namely DRP, DRE, and DRPE constraints, which are described in Equations (74), (75), and (76), respectively. \[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]4\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]5  
\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]6  
**ATL and AEL constraints**  
Equations (77) and (78) are the costs resulting from electric and thermal power purchased by AEL and ATL. In addition, Equations (79) and (80) present the price bid interval for power purchased by AEL and ATL. \[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]7  
\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]8  
\[CO^{GB}_{h,ht,n}=ngp_{h}\times FU^{GB}_{h,n} \tag{61}\]9  
\[FU_{h,n}^{GB}=\frac{P_{h,ht,n}^{GB}}{\xi_{ht}^{GB}} \tag{62}\]0  
\[FU_{h,n}^{GB}=\frac{P_{h,ht,n}^{GB}}{\xi_{ht}^{GB}} \tag{62}\]1  
**TD constraints**  
Equation (81) is the cost of thermal power bought by Thermal Dump (TD) while Equation (82) states the offer price range for power bought by TD. \[FU_{h,n}^{GB}=\frac{P_{h,ht,n}^{GB}}{\xi_{ht}^{GB}} \tag{62}\]2  
\[FU_{h,n}^{GB}=\frac{P_{h,ht,n}^{GB}}{\xi_{ht}^{GB}} \tag{62}\]3  
**REF constraints**  
Equations (83)-(87) state the modeling of REF.