Variational theory for the pinning of vortex lattices by impurities.