4.1.4. Transient-State Constraints

The transient variables, such as the transient frequency deviation, transient voltage deviation, and relative power angle, of the generators should meet:

$$
\Delta f\_{\mathcal{S}}^{\text{d,min}} < \Delta f\_{\mathcal{S}}^{\text{d}}(p) < \Delta f\_{\mathcal{S}}^{\text{d,max}} \left(\mathcal{g} = 1, \cdots, N\_{\text{G}}\right), \tag{11}
$$

$$
\Delta V\_m^{\text{d,min}} < \Delta V\_m^{\text{d}}(p) < \Delta V\_m^{\text{d,max}} \ (m = 1, \dots, N\_\text{B}), \tag{12}
$$

$$
\Delta \delta\_{\mathbb{S},r}(p) < \Delta \delta^{\max} \text{ (s, } r = 1, \dots, N\_{\mathbb{G}}\text{)},\tag{13}
$$

where *N*G is the total number of the generators; Δ*f* d,max *g* and Δ*f* d,min *g* are the upper and lower limits of the transient frequency deviation at generator *g*; Δ*V*d,max *m* and Δ*V*d,min *m* are the upper and lower limits of the transient voltage deviation at bus *m*; Δδ*<sup>s</sup>*,*<sup>r</sup>* is the power angle difference between generators *s* and *r*; and Δδmax is the maximum power angle difference between any two units during the transient process.

Equations (11) and (12) are the transient deviation limits of the frequency and voltage. Equation (13) is the transient limit of the power angle difference.

#### *4.2. Decision-Making Procedure of the Emergency Control Strategy*

As described in Section 4.1.1, the priority and the control action time of the emergency resources are different. In the decision-making process, the resources are optimized in order of priority, which is HVDCs, pumped storages, and interruptible loads. Only when the adjustable amount of the resource with high priority is insufficient to maintain the security and stability will the resource with low priority be adjusted. Therefore, the types of control resources that need to be adjusted should be determined firstly according to the power shortage and the control strategy obtained from the off-line table. Then, those with high priority are adjusted to the maximum adjustment amount, and those with low priority are optimized by solving the decision-making model.

As for the solution method, there are two kinds that can be used to solve the non-linear decision-making problems: One is to transform the non-linear function to a linear function, such as the trajectory sensitivity-based method in [30], and the other is to handle the problems with AI algorithms. In the study, the latter one is adopted, in which the BAS algorithm [40] and TS simulation are combined to obtain the optimal control strategy. Considering that the BAS algorithm may take several iterations during the decision-making process and the influence of the control strategies brought by the steady-state model in TS simulation is relatively small, TS simulation is used to improve the overall efficiency. At the same time, it should be noted that the decision variable corresponding to the pumped storages is an integer variable. In the optimization, it is treated as a continuous variable, and finally rounded to the nearest integer to obtain the decision-making result.

The specific decision-making procedure is as follows and the flowchart is shown in Figure 4.

**Figure 4.** Flowchart of the decision-making procedure.

Step 1: Initialization of the decision-making model.

Determine the types of control resources that need to be adjusted through comparing the adjustable amount of the resources and the power shortage. Obtain the control strategy corresponding to the pre-determined contingency and the current operating condition through an approximate search of the off-line control strategy table. If the control resource types in the control strategy are the same as those determined based on the power shortage, then the control strategy is used as the initial population *x*; otherwise, if the control resource types in the control strategy differ from those determined based on the power shortage, the control resource types are consistent with those determined based on the power shortage, and the resource with the lowest priority in the control resource types will be optimized, with the initial adjustment amount as 0. Then, initialize the decision-making model with the current operating state data, initial population *x*, and other solution parameters. The solution parameters include the variable step-size parameter *E*, the step-size *s*p, the distance between left and right populations *d*0, and the number of iterations *n*.

Step 2: Fitness value calculation of the current population.

Update the TS simulation model with the current control strategy, i.e., the current population *x*. Then, extract the deviations of the frequency and voltage described in Section 3.3 through traversing the simulation results. Finally, calculate the fitness value of the current population based on the fitness value function shown in Equations (1)–(5).

Step 3: Update of the population.

Assume that the beetle forages randomly in any direction, then the direction vector from its right antenna to the left antenna should also be random. Therefore, the optimization problems in *k*dim dimensional space can be represented and normalized by a random vector:

$$D = \frac{\text{rands}(k^{\text{dim}}, 1)}{\left| \text{rands}(k^{\text{dim}}, 1) \right|} \Big| \tag{14}$$

where *k*dim is the spatial dimension and *rands*() is a random function.

To imitate the activities of the beetle's left and right antennae, populations *xl* and *xr* are defined to represent a population in the left-side and right-side searching areas, respectively:

$$
\mathbf{x}\_l - \mathbf{x}\_l = d\_0 \cdot \mathbf{D},
\tag{15}
$$

$$\mathbf{x}\_{l} = \mathbf{x} + d\_{0} \cdot \mathbf{D} / 2,\tag{16}$$

$$\mathbf{x}\_{\mathbf{r}} = \mathbf{x} - d\_0 \cdot \mathbf{D} / 2. \tag{17}$$

Then, the fitness values of populations *xl* and *xr* are calculated based on TS simulation results and Equations (1)–(5), and expressed as *f* left and *f*right, respectively.

Finally, the position where the beetle will go next, i.e., the next population, can be determined by comparing the fitness values *f* left and *f*right based on Equation (18):

$$\mathbf{x} = \begin{cases} \mathbf{x} + E \cdot \mathbf{s}^{\mathsf{P}} \cdot \mathbf{D} \left( f^{\text{left}} < f^{\text{right}} \right) \\ \mathbf{x} - E \cdot \mathbf{s}^{\mathsf{P}} \cdot \mathbf{D} \left( f^{\text{left}} > f^{\text{right}} \right) \end{cases} \tag{18}$$

The variable step-size parameter *E* is between 0 and 1, and 0.95 is an acceptable value here. Step 4: Termination criteria

If the difference between the fitness values of two adjacent populations is less than the threshold value ε or the number of iterations *n* has reached the maximum value, as shown in Equation (19), then the decision-making is terminated and the new population is considered as the optimal emergency control strategy; otherwise, take the previous population as the input and perform step 2 and step 3 again until Equation (19) is met:

$$f\_n - f\_{n-1} \le \varepsilon \text{ or } n \ge n^{\text{max}},\tag{19}$$

where *fn* and *fn*−<sup>1</sup> are the fitness values of the *n*th iteration and (*<sup>n</sup>*−<sup>1</sup>)th iteration, respectively; and *n*max is the maximum number of iterations.
