Self-Adaptation to Device Distribution in the Internet of Things