Relaxation of the magnetic state of a ferromagnetic–superconducting layered structure