optimal energy generation