This paper presents a global optimization approach aiming to improve the energy efficiency of electrical machines. The process is made on a hybrid stepper motor allowing to simultaneously optimize design and command. This approach is axed around Pontryagin's maximum principle, which is applied to a magnetodynamic model based on permeances network model. The originality of the proposed approach is to obtain in the same process, the minimization of the energy by optimal control and the minimization of the energy by optimal sizing.