## 2 Mathematical Formulation
### Constraints  
The operation of WTs within MGs is governed by a series of constraints associated with the technical limitations of the grid's equipment, as well as with its operational requirements. These include the line loading limits, the allowable nodal voltage variations, the overall power balance, and the minimum and maximum active power generation limits of both the conventional generators and the WTs. The active power balance in an MG for each hour of operation is represented by the following equation:  
\[P_{i,h}^{gc}-P_{i,h}^{d}+P_{i,h}^{wot}=V_{i  
Equation (5) defines the reactive power balance, ensuring that, at each node and every hour, the reactive power of the system remains within equilibrium.  
\[Q_{i,h}^{gc}-Q_{i,h}^{d}+Q_{i,h}^{net}=V_{i,h}\sum_{j\in\mathcal{N}}Y_{i,j}V_{j,h }\sin\left(\theta_{i,h}-\theta_{j,h}-\varphi_{i,j}\right) \tag{5}\]  
Here, \(Q_{i,h}^{gc}\) represents the reactive power injected by the conventional generators, and \(Q_{i,h}^{d}\) denotes the reactive power demanded by the loads connected to the MG, both at node \(i\) during hour \(h\). Meanwhile, \(Q_{i,h}^{net}\) corresponds to the reactive power supplied by the WTs at the same node and hour. This equation ensures proper management and reactive power balance at each node in the system. In order to limit the active power output of the conventional generators and thereby prevent overloading, Equation (6) is employed. \[P_{i}^{gc,\text{min}}\leq P_{i,h}^{gc}\leq P_{i}^{gc,\text{max}} \tag{6}\]  
Here, \(P_{i}^{gc,\text{min}}\) and \(P_{i}^{gc,\text{max}}\) represent the minimum and maximum active power generation limits of the conventional generators at node \(i\). It should be emphasized that, in grid-connected mode, these power limits are determined by the energy export capabilities of the grid at the connection point, which is the typical scenario. In contrast, during islanded operation, these limits are defined by the power constraints of the diesel generators, which generally range from 40% to 80% of the fossil fuel-based generation plant's nominal capacity. In addition, as shown in Equation (7), it is crucial to establish a constraint on the reactive power of conventional generators in order to ensure that their operation stays within the nominal capacity limits. \[Q_{i}^{gc,\text{min}}\leq Q_{i,h}^{gc}\leq Q_{i}^{gc,\text{max}}, \tag{7}\]  
where \(Q_{i}^{gc,\text{min}}\) and \(Q_{i}^{gc,\text{max}}\) represent the minimum and maximum reactive power limits for each conventional generator at node \(i\). Furthermore, for the islanded operation mode, two additional constraints are incorporated to ensure that the diesel generator installed at the slack node only injects active and reactive power into the system. In this study, the mathematical model considers both the main grid and the diesel generator as conventional generation sources. These constraints, presented in Equations (8) and (9), explicitly prevent power absorption at the slack node. This is crucial because, unlike the grid-connected mode, where the main grid can absorb surplus energy, the diesel generator lacks energy storage or absorption capabilities. As a result, these restrictions are necessary to reflect the physical limitations of the MG and ensure a feasible operational strategy under isolated conditions. \[0\leq P_{i,h}^{gc} \tag{8}\] \[0\leq Q_{i,h}^{gc} \tag{9}\]  
The active power injection of the WTs can be represented using Equation (10). \[P_{i}^{net,\text{min}}\leq P_{i,h}^{net}\leq P_{i}^{\text{net,max}}G_{h}^{net} \tag{10}\]  
where \(P_{i}^{net,\text{min}}\) and \(P_{i}^{net,\text{max}}\) denote the minimum and maximum power limits of the WTs, respectively, while \(G_{h}^{net}\) denotes the wind generation factor at hour \(h\). This factor is determined by the wind speed and the technical characteristics of the wind turbine, i.e., the power generated by the WTs is constrained by both wind availability and the installed capacity of the turbines.