Joint Optimization of Energy Consumption and Completion Time in Federated Learning