An execution, monitoring and replanning approach for optimal energy management in microgrids