## 3 Methodology to Develop and Execute a Redispatch Model in Real-Time Operation
### Mathematical Methodology to Implement the Modeling of a Redispatch  
The numerical methodology proposed for the redispatch model corresponds to the implementation of nine mathematical formulations of a technical, economic, and environmental nature, as shown in Figure 4.  
First, there is the objective function that allows minimizing the global cost of redispatch, which depends on the cost of conventional generation, renewable generation, start-up cost, detention cost, and energy not supplied, as shown in Equation (1). Second, we integrate the variable generation cost constraints by a polynomial function of the heat rate, as shown in Equations (2) and (3). Thirdly, three thermal states of the starting costs (hot, warm, and cold) are defined as a function of the on and off times, according to Equations (4)-(8). In fourth place, there are the technical restrictions of the dispatch power between technical minimum and maximum generation, according to Equation (9). Finally, in fifth place is the power balance coupling constraint, according to Equations (10) and (11).  
In addition, the main contribution of this work is highlighted and corresponds to the numerical equations of technical and economic constraints from point 3.1.6 to 3.1.9 of this section. Point 3.1.6 of this section describes Equations (12)-(14), which correspond to the primary power reserve, spinning reserve, and cold reserve, intended for frequency control, and directly related to the ancillary services market. Section 3.2.7 describes a safety constraint called maximum dispatch power to avoid load shedding due to low frequency, as shown in Equation (15). Finally, points 3.1.8 and 3.1.9 of this section correspond to the mathematical modeling of gas volume stock control for thermal power plants and hydro generation storage through a level of control level for large reservoir hydro plants, as shown in Equations (16)-(18).  
Figure 4: General structure of the mathematical methodology for a redispatch.  
3.2.5. Coupling Constraint Defining the Balance of Power Generation to Supply Demand and Grid Losses  
\[\sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}\left[\rm U_{n}^{h}\times P _{\rm n}^{h}\right]\ =\ \rm PDx_{SEN}^{h}+P_{L}^{h} \tag{10}\]  
\[\sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}\left[\rm U_{n}^{h}\times P_{\rm min }^{h}\right]\leq\rm PDx_{SEN}^{h} \tag{11}\]  
where \(\rm P_{n}^{h}\) is the power generated by plant n in hour h, to supply \(\rm PDx_{SEN}^{h}\), which is the demand in hour h and the system losses \(\rm P_{L}^{h}\) in hour h. In addition, it must be fulfilled that the minimum power \(\rm P_{\rm min}^{h}\) of all the power plants is less than or equal to the power demand of the system \(\rm PDx_{SEN}\).  
2.6. Determination of Power Reserves for Frequency Control and its Relationship to the Complementary Services Market  
\[\rm RGPh\leq\ \sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}U_{n}^{h}\times \left(\%Resp(\pm)_{n-central}^{h}\times P_{\rm max}^{h}\right) \tag{12}\]  
\[\rm RGU^{h}\leq\ \sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}U_{n}^{h}\times \left(P_{\rm max}^{h}-P_{n}^{h}\right) \tag{13}\]  
\[\rm RGB^{h}\leq\ \sum_{\rm h=1}^{\rm H}\sum_{\rm n=1}^{\rm N}U_{n}^{h}\times \left(P_{n}^{h}-P_{\rm min}^{h}\right) \tag{14}\]  
where power reserves are established by the \(\rm RGPh\) as the primary reserve, \(\rm RGU^{h}\) is the spinning reserve, and \(\rm RGB^{h}\) is the reserve for lowering the generation of the n plants in period h. These primary and secondary power reserves are a function of the dynamic response factor \(\%Resp(\pm)_{n-central}^{h}\), maximum power \(\rm P_{max}^{h}\), and the dispatch power \(\rm P_{n}^{h}\).