Modeling of Flexibility in Electricity Demand and Supply for Renewables Integration