The Resilience of a Swarm Ecosystem Under Environmental Variation