This paper proposes a new optimization algorithm based on the law of gravity. In the proposed algorithm, the black hole sucks up the star that crosses the event horizon, and a white hole emits the star from its event horizon. Both black and white holes attract stars. The white hole-black hole algorithm (WH-BH) starts with an initial population of candidate solutions to an optimization problem and an objective function that is calculated for them. The white hole is selected to be the worst candidate (star), and the black hole will be the best star at each iteration of the WH-BH algorithm. The CEC2014 test functions are applied to evaluate the performance of the WH-BH.