The aim of this work is the development of an optimization model in order to minimize the cost of Leaf Community microgrid. This cost is a sum of energy cost and the maintenance cost of the energy storage system (ESS). The developed objective function is constrained and the problem here is solved by using the method of genetic algorithms at Matlab. The genetic algorithm decides about the transportation of the energy from or to the ESS and it calculates an optimum cost. The optimization time horizon is 24 h ahead, thus the prediction of energy production and consumption was necessary. This was achieved by using neural networks. In order to verify the performance of the developed model, some scenarios were tested. This study concludes that a management of a microgrid can achieve energy and money savings.