Heat pump optimization