Reducing energy consumption, regardless of fuel or electricity, of ground vehicles is a paramount pursuit in academia and industry. Current research concentrates exclusively on the improvement of the vehicle, but accepts the road conditions as external influences. The innovation of this article is to consider the road conditions, particularly the grade angle, as design variables. It is assumed that the stochastic speed trajectories of all vehicles on the road can be modelled by a Markov chain. The expected value of the average energy consumptions of all vehicles running on the road is defined as the objective function. The optimisation problem is solved by dynamic programming with Markov model. Evaluations have been made on both simulated and measured speed trajectories. For the simulated speed trajectories, the optimal road grade profile designed by the method saves up to 22% energy compared with a flat road. For the measured speed trajectories, the optimal road grade profile saves up to 2.7% transportation energy compared with the actual road profile. Application of this method on building road could lead to considerable energy saving.This is an open access article under the terms of the Creative Commons Attribution License, which permits use, distribution and reproduction in any medium, provided the original work is properly cited.