A Framework for the Evaluation of the Cost and Benefits of Microgrids