Adapting to a changing environment