  We design, by invariant-based inverse engineering, driving fields that invert
the population of a two-level atom in a given time, robustly with respect to
dephasing noise and/or systematic frequency shifts. Without imposing
constraints, optimal protocols are insensitive to the perturbations but need an
infinite energy. For a constrained value of the Rabi frequency, a flat $\pi$
pulse is the least sensitive protocol to phase noise but not to systematic
frequency shifts, for which we describe and optimize a family of protocols.
