Distributed Energy Optimization of Micro-grids