  We derive a first order optimality condition for a class of agent-based
systems, as well as for their mean-field counterpart. A relevant difficulty of
our analysis is that the state equation is formulated on possibly
infinite-dimensional convex subsets of Banach spaces, as required by some
problems in multi-population dynamics. Due to the lack of a linear structure
and of local compactness, the usual tools of needle variations and
linearisation procedures used to derive Pontryagin type conditions have to be
generalised to the setting at hand. This is done by considering suitable
notions of differentials and by a careful inspection of the underlying
functional structures.
