  In this paper we consider mean-field optimal control problems with selective
action of the control, where the constraint is a continuity equation involving
a non-local term and diffusion. First order optimality conditions are formally
derived in a general framework, accounting for boundary conditions. Hence, the
optimality system is used to construct a reduced gradient method, where we
introduce a novel algorithm for the numerical realization of the forward and
the backward equations, based on exponential integrators. We illustrate
extensive numerical experiments on different control problems for collective
motion in the context of opinion formation and pedestrian dynamics.
