How protandry and protogyny affect female mating failure: a spatial population model