  We present a formalism for computing the complexity of metastable states and
the zero-temperature magnetic hysteresis loop in the soft-spin random-field
model in finite dimensions. The complexity is obtained as the Legendre
transform of the free-energy associated to a certain action in replica space
and the hysteresis loop above the critical disorder is defined as the curve in
the field-magnetization plane where the complexity vanishes; the nonequilibrium
magnetization is therefore obtained without having to follow the dynamical
evolution. We use approximations borrowed from condensed-matter theory and
based on assumptions on the structure of the direct correlation functions (or
proper vertices), such as a local approximation for the self-energies, to
calculate the hysteresis loop in three dimensions, the correlation functions
along the loop, and the second moment of the avalanche-size distribution.
