Optimal Design of Energy Systems