Hamelin: A model for collective adaptation based on internal stimuli