Optimal planning of battery systems for power losses reduction in distribution grids