Distributed demand-side optimization in the smart grid