SMS: Adaptation in stochastic environments