This work addressed the problem regarding the optimal integration of battery systems (BS) in grid-connected networks (GCNs) with the purpose of reducing energy losses and CO2 emissions, for which it formulates a mathematical model that considers the constraints associated with the operation of GCNs in a distributed generation environment that includes BS and variable power generation related to photovoltaic (PV) distributed generation (DG) and demand. As solution strategies, three different master–slave methodologies are employed that are based on sequential programming methods, with the aim to avoid the implementation of commercial software. In the master stage, to solve the problem regarding the location and the type of batteries to be used, parallel-discrete versions of the Montecarlo method (PMC), a genetic algorithm (PDGA), and the search crow algorithm (PDSCA) are employed. In the slave stage, the particle swarm optimization algortihm (PSO) is employed to solve the problem pertaining to the operation of the batteries, using a matrix hourly power flow to assess the impact of each possible solution proposed by the master–slave methodologies on the objective functions and constraints. As a test scenario, a GCN based on the 33-bus test systems is used, which considers the generation, power demand, and CO2 emissions behavior of the city of Medellín (Colombia). Each algorithm is executed 1000 times, with the aim to evaluate the effectiveness of each solution in terms of its quality, standard deviation, and processing times. The simulation results obtained in this work demostrate that PMC/PSO is the master–slave methodology with the best performance in terms of solution quality, repeatability, and processing time.