A rational analysis of alternating search and reflection in problem solving