A sex ratio theory of gregarious parasitoids