Optimizing Energy Systems