In solving optimization problems for building design and control, the cost function is often evaluated using a detailed building simulation program. These programs contain code features that cause the cost function to be discontinuous. Optimization algorithms that require smoothness can fail on such problems. Evaluating the cost function is often so time-consuming that stochastic optimization algorithms are run using only a few simulations, which decreases the probability of getting close to a minimum. To show how applicable direct search, stochastic, and gradient-based optimization algorithms are for solving such optimization problems, we compare the performance of these algorithms in minimizing cost functions with different smoothness. We also explain what causes the large discontinuities in the cost functions.