Particle Systems in Dynamics, Optimization, and Learning