Mathematical optimization techniques for demand management in smart grids