Trajectory optimization for eco-driving taking into account traffic constraints