Invariants and the evolution of nonstationary quantum systems