To simulate bicycle traffic accurately, it is essential to capture how bicyclists react to features of the infrastructure such as the longitudinal gradient of a bicycle path. Bicycling requires human-powered motion, and the power output provided by bicyclists differ significantly among bicyclists due to physical capabilities and preferences. Therefore, the objective of this paper is to investigate the connection between power output and gradient in bicycle traffic, with the purpose of developing a power-based model that predicts accurately the speed of bicyclists. Based on trajectory data of free-riding bicyclists travelling on a non-flat bicycle path segment, we estimate changes in power output as a function of gradient considering the physical forces acting on a bicycle. The results suggest a linear correlation between power output and gradient; while bicyclists increase their power output on the uphill as gradient increases, they decrease their power output on the downhill as gradient increases. By implementing this correlation into a traffic simulation algorithm, we show that the simulation captures well the impact of gradients in a population of bicyclists as it reproduces similar speed profiles. We conclude that bicyclists adapt their power output to compensate for the gradient and its associated change in speed, and that the impact of gradient varies greatly among bicyclists. Furthermore, we conclude that power-based modelling of free-riding bicyclists is an attractive alternative to investigate further.