Bayesian Optimization with a Finite Budget: An Approximate Dynamic Programming Approach