Optimal operation of Smart Grids with demand side management