The evolution of a cluster of particles and the invariants of a time-dependent oscillator