## 3 Methodology to Develop and Execute a Redispatch Model in Real-Time Operation
### Mathematical Methodology to Implement the Modeling of a Redispatch
#### 3.2.7. Mathematical Formulation Defining Maximum Dispatch Power for System Security  
\[\rm P_{max_{D}}=\left(\sum_{\rm i=1}^{8}\ \rm EDAC_{T_{i}}-\sum_{\rm i=EDAC \atop Desado}^{8}EDAC_{T_{i}}-\sum_{\rm i=1}^{8}EDAC_{OTR_{i}}\right)\times FS \tag{15}\]  
where \(\rm P_{max_{D}}\) is the maximum dispatch power in (MW) based on the theoretical automatic load disconnection scheme \(\rm EDAC_{T_{i}}\), real-time automatic load shedding scheme \(\rm EDAC_{OTR_{i}}\), and a safety factor FS with a value between (0,9) applied in the period h.  
The maximum dispatch power is used as a safety parameter that limits any power plant to exploit its generation to the maximum when the safety of the system is put at risk. This work proposes to integrate the maximum dispatch power into the redispatch model to avoid automatic load shedding due to low frequency, as shown in Figure 5.  
2.8. Mathematical Formulation for Gas Volume Stock Control for Thermal Power Plants in Combined Cycle and Open Cycle Configuration  
\[\sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}U_{n}^{h}\times \left(P_{\rm Gas,\ n}^{h}\right)\left|\rm MWh\right|\ \leq\ \frac{\rm StockSeman[m^{3}]}{\rm CEN_{Gas,n}^{h}\left[\frac{m^{3}}{MWh}\right]} \tag{16}\] \[\sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}U_{n}^{h}\times \left(\rm Energia_{Gas,\ n}^{h}\right)\left|\rm MWh\right|\ \leq\ \frac{\rm StockSeman[m^{3}]}{\rm CEN_{Gas,n}^{h}\left[\frac{m^{3}}{MWh}\right]} \tag{17}\]  
where \(\rm P_{Gas,\ n}^{h}\) is the power generated by the n gas-fired power plants and \(\rm Energia_{Gas,\ n}^{h}\) is the energy generated by n gas-fired power plants, while StockSemanal is the volume in m\({}^{3}\) of gas per week in a period h and \(\rm CEN_{Gas,n}^{h}\) is the heat rate in m\({}^{3}\)/MWh. 2.9 Mathematical Model Defining Water Storage of Reservoir Power Plants by a Level of Height Control  
\[\sum_{\text{h=1}}^{\text{H}}\sum_{n=1}^{\text{N}}U_{\text{n}}^{\text{h}}\times( \text{Cota}_{\text{inicial},n}^{\text{h}}-\text{Cota}_{\text{final},n}^{\text{h}}) \times\eta_{\text{n}}^{\text{h}}+\text{Gasto}_{\text{n}}^{\text{h}}\geq\text{E}_{ \text{n}}^{\text{h}} \tag{18}\]  
where \(\text{Cota}_{\text{inicial},n}^{\text{h}}\) is the initial height level of the reservoir and the term \(\text{Cota}_{\text{final},n}^{\text{h}}\) is the final height level of the reservoir measured at (m.s.n.m), while \(\eta_{\text{n}}^{\text{h}}\) corresponds to the efficiency of the turbine in MWh/cm, the term \(\text{Gasto}_{\text{n}}^{\text{h}}\) is the tributary of the reservoir transformed to MWh, and \(\text{E}_{\text{n}}^{\text{h}}\) is the daily accumulated energy in MWh-Day. Methodology Defining the Process of Simulation and Validation of the Redispatch Model Using Optimization Software  
The following methodology is developed to implement a sequence of simulation processes in any optimization software that integrates the theoretical foundations and mathematical expressions required by a redispatch. The modeling structure of a redispatch has a direct coupling axis between generation, transmission, and demand. Figure 6 shows a sequence of six stages of the simulation from the beginning of a redispatch to its result. From stage one to stage four, it is exclusively the generation segment that integrates initial system state constraints (plant on/off state, power level, on hours and off hours), plant technical constraints (maximum solar and wind generation capacity, maximum power and technical minimums), plant timing constraints (start-up times, minimum operation and shutdown times, maximum available hourly and daily energy), and economic constraints (start-up/shutdown costs, fuel price, operation/maintenance cost and heat rate). Meanwhile, stage five corresponds to the transmission segment, which includes the technical restrictions of line impedance and maximum and minimum limits of power flows.