###### Abstract  
This paper proposes an interconnection of the MATLAB and GAMS software interfaces, which were designed based on a master-slave methodology, to solve the mixed-integer nonlinear programming (MINLP) model problem associated with the problem regarding the optimal location and sizing of static distribution compensators (D-STATCOMs) in meshed and radial distribution networks, considering the problem of optimal reactive power flow compensation and the fact that the networks have commercial, industrial, and residential loads for a daily operation scenario. The objective of this study is to reduce the annual investment and operating costs associated with energy losses and the installation costs of D-STATCOMs. This objective function is based on the classical energy budget and the capacity constraints of the device. In the master stage, MATLAB software is used to program a discrete version of the sine-cosine algorithm (DSCA), which determines the locations where the D-STATCOMs will be installed. In the slave stage, using the BONMIN solver of the GAMS software and the known locations of the D-STATCOMs, the MINLP model representing the problem under study is solved to find the value of the objective function and the nominal power of the D-STATCOMs. To validate the effectiveness of the proposed master-slave optimizer, the 33-node IEEE test system with both radial and meshed topologies is used. With this test system, numerical comparisons were made with the exact solution of the MINLP model, using different solvers in the GAMS software, the genetic-convex strategy, and the discrete-continuous versions of the Chu and Beasley genetic algorithm and the salp swarm optimization algorithm. The numerical results show that DSCA-BONMIN achieves a global solution to the problem under study, making the proposed method an effective tool for decision-making in distribution companies.  
G 2023 16 138  
voltages typically between 15 and 10 kV [4]. One of the best options to reduce energy losses is distributed generation (DG). When building distribution networks, a radial topology is often used to reduce the financial costs of conductors and safety equipment. Nevertheless, their initial investment and installation costs can be very high, especially when compared to the installation of capacitor banks and strategies, such as grid reconfiguration [5]. Moreover, one of the disadvantages of distribution networks when it comes to installing capacitor banks is that it does not allow considering the daily demand of active, reactive, and customer energy for a scenario in which reactive power is injected in fixed steps [6; 7].  
The economic factor is important for utilities, especially regarding energy losses at the time of distribution. This can directly affect the finances of the company in charge of supervising and maintaining the system. In addition, thanks to the increase in unbilled energy, tariffs for the service's end users can be increased to compensate for economic losses. In Colombia, the energy losses of the electricity system are between 1.5% and 2.0% of the total energy produced. In medium-sized grids, energy losses can vary from 5% to 18% [2]. According to the regulating bodies, loss levels below 10% correspond to networks where maintenance has been carried out simultaneously with device replacements, and scores above 10% are associated with poor management of distribution systems [2].