Consider a ride hailing service, where the fare needs to be dynamically adjusted. I know there are many machine learning driven models possible, but here I am looking for a simpler and sensible mathematical formula.

The fare itself is modelled by a surge factor $s$, with which the actual fare varies as a monotonically increasing function (added platform fee, and some other business logics). So, I need to update the surge factor every two minutes as $s_1, s_2, s_3...$etc. The $s_n$ at any moment is to be determined by the following parameters

  1. An unmet demand $u_n\geq0$
  2. An excess demand factor $e_n\geq0$
  3. Previous surge $s_{n-1}\in\mathbb{R}$
  4. A ceiling $h>0$ and a floor $l<0$, so that $s$ will always stay within the range, i.e. $l\leq s\leq h$.

So basically, at each step, I have to find $\delta_n\in\mathbb{R}$ so that $s_n=s_{n-1}+\delta_n$. I am looking for some good candidate functions to calculate $\delta_n=f\left(s_{n-1}, u_n, e_n, h, l\right)$ with the following properties that I think are desirable

  • Monotonically increasing (or non decreasing) with $u_n$ and $e_n$. Of course, more demand means usually higher price
  • Obey the constraint to keep $s_n$ between the floor and ceiling (I can apply a final clip function for this)
  • Somehow, the step size $\delta_n$ (which can be positive or negative, depending on if we are experiencing a surge, or easing demand) should be adaptive to how far is it from the limit in the direction it is moving in. That means, suppose $\delta_n>0$, then how big the step is, is also a function of $h-s_{n-1}$. If it has more room to rise, it will rise a bit faster than when it is almost hitting $h$. Same when it falls towards $l$.

The decisions on when to raise the surge ($\delta_n>0$) or reduce it ($\delta_n<0$) is already mostly made. I am just trying to come up with a sensible step size in the desirable direction respecting the above constraints. So any idea for candidate functions (preferably one that can be implemented easily in python) will be sincerely appreciated. Cheers!