Quantifying flexibility for smart grid services