Modeling and optimization of HVAC energy consumption