I am trying to create a reinforcement learning model to control the acceleration of a car. I am designing the model such that initially the acceleration is provided and then deceleration is provided so that the the car covers a particular distance and the end velocity comes out to be zero.
The reward function I have come up till now looks like this: $$R = (f(x_t) - f(x_{t-1}))*K - \frac{v}{|f(x_t)|} - r_\text{penalty}$$ where $f(x_t) = -|x_t - x_d|$ is the error function.
Based on this reward function, the model learns to provide acceleration. However, it doesn't provide any deceleration causing the velocity to be very high at the end.
The objective of the model is to find the right time when it should change from acceleration to deceleration.