# Reward Function for Reinforcement Learning model

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.

• Could you please elaborate a bit more on the other variables ? What are $K$, $v$ and $r_{penalty}$ ? Sep 14, 2022 at 22:26
• @nathanraynal K is a constant, v is velocity and $r_{penalty}$ is penalty when constraints are violated. Dec 23, 2022 at 8:55