Energy cost weighting code.