optimizing energy contracts