Smart Microgrids and Virtual Power Plants in a Hierarchical Control Structure