Gravar-mail: Optimal energy management of a microgrid system