The insertion of distributed generation units in power grids is becoming an increasingly attractive alternative for electricity end users. This new scenario prepares utilities to meet these options, directly influencing the networks operation, control and planning under their concession areas.One of the multiple problems arising from distributed or decentralized generation is the proper allocation of distributed generators in electric grids. This research presents a new computational tool to address this issue that optimally and simultaneously allocates five photovoltaic distributed generation units in electric networks.'Optimal allocation' refers to the objective the proposed solution should achieve. In this case, this research aims to identify the buses of an electric distribution network where the injection of distributed electric power can minimize electrical losses.The proposed computational tool consists of an algorithm based on the metaheuristic optimization technique, Pattern Search, developed in MATLAB. The proposed algorithm connects with the Open Distribution System Simulator (OpenDSS) to run power flow and thus calculate the objective function (electrical losses).The author used a case study based on IEEE 123-Node Test Feeder to test the proposed solution performance. Loads in this network were modeled throughout the day using data from a São Paulo State concessionaire's field measurements, which the National Electric Energy Agency (ANEEL) makes available upon request. In addition, the author also included the solar radiance registered by São Paulo City weather stations.Results show the efficiency of the methodology developed in this research and indicate that applying it to different types of networks is possible.