Learning to control dynamic systems