In this paper is addressed the optimal power flow problem in direct current grids, by using solution methods based on metaheuristics techniques and numerical methods. For which was proposed a mixed integer nonlinear programming problem, that describes the optimal power flow problem in direct current grids. As solution methodology was proposed a master–slave strategy, which used in master stage three continuous solution methods for solving the optimal power flow problem: a particle swarm optimization algorithm, a continuous version of the genetic algorithm and the black hole optimization method. In the slave stages was used a methods based on successive approximations for solving the power flow problem, entrusted for calculates the objective function associated to each solution proposed by the master stage. As objective function was used the reduction of power loss on the electrical grid, associated to the energy transport. To validate the solution methodologies proposed were used the test systems of 21 and 69 buses, by implementing three levels of maximum distributed power penetration: 20%, 40% and 60% of the power supplied by the slack bus, without considering distributed generators installed on the electrical grid. The simulations were carried out in the software Matlab, by demonstrating that the methods with the best performance was the BH/SA, due to that show the best trade-off between the reduction of the power loss and processing time, for solving the optimal power flow problem in direct current networks.