Model car queueing with two gates

124 Views Asked by At

Say a school has two gates at which parents can pick up their kids. One gate is only for primary school students and the other is only for secondary school students. The school has a primary school to secondary school population ratio of $p:s$.

enter image description here

Now, say I have cars queueing behind the two gates, with each cars assigned to be whether for picking up primary school students or secondary school students based on the population ratio (labeled "p" and "s" in the image). Each car takes $w$ seconds to pick up their kids (equal time at both primary gate and secondary gate). And $s$ cars have to wait and queue behind $p$ cars to pick up their kids.

I would like to model this queueing system and find out after time $t$, what is the total number of students that are picked up from the school.

Should I use the Poisson process? How should I approach this problem? Any advice would be appreciated.

1

There are 1 best solutions below

5
On BEST ANSWER

I am not sure I understand correctly your problem - please add remarks if needed

let's say that each $w$ time you will have one of following events:

  1. car $p$ waits for student and there is no $s$ car in front- so one car is waiting
  2. $s$ car is waiting and behind him is car $s$ so also one car is waiting
  3. there was two cars in queue $p$ and $s$ so two cars are waiting now let's count probability that we will have pair $ps$ in sequence

in general it's markov process from here we will create transition matrix $m$, you can derive $p(S)\ p(P)\ p(PS)$ (here it will be difficult) and assign weights $1\ 1\ 2$ and compute $E(X)$

\begin{array}{|c|c|c|} \hline \text{from\to} & P & SS & PS \\ \hline P & \frac{p}{p+s} & \frac{s^2}{(p+s)^2} & \frac{sp}{(p+s)^2} \\ \hline SS & 0 & \frac{s}{p+s} & \frac{p}{p+s} \\ \hline PS & \frac{p}{p+s} & \frac{s^2}{(p+s)^2} & \frac{sp}{(p+s)^2} \\ \hline \end{array}

now create vector initial vector $v_1 = (\frac{p}{p+s}, \frac{s^2}{(p+s)^2}, \frac{sp}{(p+s)^2})$ (fill exact values s and p into these structures) and count in for loop $v_{n+1} = v_n*m$ at each step vector $v$ will have probabilities of events $(p(P), p(SS), p(PS))$ and you can calculate $EX_n = (1,1,2) * v_n$ which will be expected value of students picked up at step $n$

#given  m, v, n
sum_x = 0
for i in range(n):
  v = v * m
  sum_x += [1,1,2] * v.T
return sum_x

```