Optimal management of renewable and fossil fuel energy systems in a smart community