Optimal Distributed Energy Resource Control and Scheduling in a Microgrid Framework