Optimization and Control of Electrical Machines