## 1 Introduction  
Reactive power plays an important role in maintaining the stability and reliability of transmission and distribution power systems. As a consequence, various dynamic (synchronous generators, synchronous condensers, and solid-state devices) and static reactive power sources (capacitive and inductive compensators, as well as inverter-based distributed generators) have been deployed over the past few decades [1]. In particular, reactive power generation (RPG) units have been deployed at the optimal location for voltage control in transmission and distribution systems. If reactive power is not appropriately compensated, receiving ends may experience voltage variations outside \(\pm 5\%\) of the rated voltage, possibly leading to automatic tripping of protection devices and low power factors. Optimally allocating RPG units is one of the optimal power flow (OPF) problems, and the solution has been sought by using meta-heuristic, search, and optimization algorithms. The former includes annealing and fuzzy clustering [2], the evolution approach [3], genetic algorithms (GAs) [4], krill herd algorithms [5], particle swarm optimization (PSO) [6], seeker algorithms [7], and whale optimization [8]. The search algorithms contain backtracking [9], cuckoo [10], differential [11], direct [12], and harmony search methods [13]. The optimization algorithms (as conventional methods) involve decomposition methods [1], dynamic programming [14], gradient-based optimization [15], interior-point methods [16], linear approximation [17], mixed integer programming [18, 19], quadratic programming [20], teaching-based learning [21], and decision-making algorithms [22]. As renewable energy deployments increase, the optimal allocation of RPG units should take photovoltaic (PV) systems [23], wind turbine generators (WTGs) [24, 25], and microgrids [26] into account. For example, the effect of optimally allocated distributed generation (DG) units on energy savings [27], generation resource allocation [28], distribution networks [29], peak load reduction [30], reliability [31], voltage and losses [32], and Volt/Var control and management [33] have been examined. In these studies, the optimally allocated DG units could improve the voltage profile, reduce peak load and energy losses of distribution networks, and improve reliability. The GA approach of solving an optimization problem can find more desirable solutions to the objective function, as a result of the operations of mutation and crossover [34]. The GA can be also programmed relatively more easily than other algorithms. Thus, an OPF problem for DG (with the ability to control Volt/Var) has been solved by the GA [35]. That study optimized DG units in the IEEE 13- and 34-bus test feeders, using the GA that minimizes variations of each bus voltage and the installation costs of DG units. Static Var compensators (SVCs) are optimally allocated to reduce power losses and voltage deviation using the GA [36]. Recently, an RPG optimization problem in the IEEE 14- and 57-bus test systems as input with interval uncertainties (i.e., real power losses) was solved by a GA [4]. An RPG optimization problem with DC transmission links and converters for high-voltage direct current (HVDC) systems added to the constraints was also solved by a GA [37]. In addition, an RPG optimization problem for a system that included PV, WTGs, converter models, and energy storage systems was solved by a GA [38]. However, neither of the previous studies optimized the location and capacity of RPG units by the bus impedance matrix power-flow calculation method with the constraint of varying demand. The bus impedance matrix method, which is useful for short-circuit studies, is usually not used, because it is difficult to apply to tap-changing transformers. Thus, an objective of this study is to enhance the bus impedance matrix power-flow method to model tap-changing transformers.