The size and complexity of modern astronomical surveys has grown to the point where, in many cases, traditional human scheduling of observations is tedious at best and impractical at worst. Automated scheduling algorithms present an opportunity to save human effort and increase scientific productivity. A common scheduling challenge involves determining the optimal ordering of a set of targets over a night subject to timing constraints and time-dependent slew overheads. We present a solution to the `Traveling Telescope Problem' (TTP) that uses Mixed-Integer Linear Programming (MILP). This algorithm is fast enough to enable dynamic schedule generation in many astronomical contexts. It can determine the optimal solution for 100 observations within 10 minutes on a modern workstation, reducing slew overheads by a factor of 5 compared to random ordering. We also provide a heuristic method that can return a near-optimal solution at significantly reduced computational cost. As a case study, we explore our algorithm's suitability to automatic schedule generation for Doppler planet searches.