Abstract : Controlling several and possibly independent moving agents in order to reach global goals is a tedious task that has applications in many engineering fields such as robotics or computer animation. Together, the different agents form a whole called swarm, which may display interesting collective behaviors. When the agents are driven by their own dynamics, controlling this swarm is known as the particle swarm control problem. In that context, several strategies, based on the control of individuals using simple rules, exist. This paper defends a new and original method based on a centralized approach. More precisely, we propose a framework to control several particles with constraints either expressed on a per-particle basis, or expressed as a function of their environment. We refer to these two categories as respectively Lagrangian or Eulerian constraints. The contributions of the paper are the following: (i) we show how to use optimal control recipes to express an optimization process over a large state space including the dynamic information of the particles; and (ii) the relation between the Lagrangian state space and Eulerian values is conveniently expressed with graph operators that make it possible to conduct all the mathematical operations required by the control process. We show the effectiveness of our approach on classical and more original particle swarm control problems.