In this paper, we establish a mathematical framework that allows us to optimize the speed profile and select the optimal gears for heavy-duty vehicles (HDVs) traveling on highways while varying parameters. The key idea is to solve the analogous boundary value problem (BVP) analytically for a simple scenario (linear damped system with quadratic elevation profile) and use this result to initialize a numerical continuation algorithm. Then, the numerical algorithm is used to investigate how the optimal solution changes with parameters. In particular, we gradually introduce nonlinearities (air resistance and engine saturation), implement different elevation profiles, and incorporate external perturbations (headwind and traffic). This approach enables real-time optimization in dynamic traffic conditions, therefore may be implemented on-board.