In this work, we address the problem of optimally integrating photovoltaic distributed generators (PV) and distributed static compensators (D-STATCOMs) in distributed electrical systems (DES). Previous methods have struggled with the complexities of non-linear mathematical models and the integration of operating and investment costs while meeting the operational constraints of these devices. We propose a solution using a master-slave methodology that combines a discrete-continuous version of the multiverse optimization algorithm (MVO), with a matrix power flow method based on successive approximation (MAX). This approach aims to reduce annual costs by efficiently managing the grid’s operating costs and the investment and operational costs of PV and D-STATCOMs. Various researchers have suggested methodologies for solving the problem of optimal D-STATCOM integration in DES, focusing on minimizing investment and operating costs as the objective function. However, these studies often lack comparative methodologies and statistical analysis to validate the performance of their proposed approaches. Additionally, they do not consider the impact of variable power demand. We compared our methodology with other master-slave approaches that utilize different optimization algorithms, including the vortex search algorithm (VSA), crow search algorithm (CSA), a continuous genetic algorithm (GA), and the particle swarm optimization algorithm (PSO). These comparisons were made using two test systems with 33 and 69 nodes, which incorporate variations in power demand and PV production from a region in Colombia. Our statistical analysis included evaluations of the best and average solutions, standard deviations, differences between the best and average solutions, and a dispersion analysis using box-and-whisker plots. The results demonstrate that MVO outperforms other methods, providing the best results with reduced processing times in both test systems.