next up previous
Next: Computation Time. Up: Implementation Previous: Implementation

Step (1c): Procedure when the $ k$th packet $ b_k$ of $ B$ is taken from $ S$.

For each $ j=j_k,j_k+1,\ldots,k   (j_1=1)$ do the following computations.
  1. Compute $ f(k,j)$
    When we move graph $ A$ and $ B$ along the Y-axis so that $ a_0$ and $ b_{j-1}$ are at the same level 0 on the Y-axis, the two graphs (named as $ A'$ and $ B(j)$) are repositioned as follows:

      $\displaystyle A':\quad \langle (t(a_1),a_1-a_0), (t(a_2),a_2-a_0),\ldots,(t(a_n),a_n-a_0) \rangle$    
      $\displaystyle B(j):\quad \langle (u(b_1),b_1-b_{j-1}),\ldots,(u(b_{j-1}),0),\ldots,(u(b_k),b_k-b_{j-1}),\ldots \rangle\enspace .$    

    $ f(k,j)$ is the index of $ A'$ at which $ a_{f(k,j)}-a_0$ is the lowest position above $ b_k-b_{j-1}$, and is computed using $ f(k-1,j)$ as the starting position by the following equation.

    $\displaystyle f(k,j) = \left\{ \begin{array}{l} \min\{i \vert a_i-a_0 > b_k - b...
...-1}\}) n+1 \quad \mbox{ if } a_n-a_0 \leq b_k - b_{j-1} \end{array} \right.$ (3)

    $ f(k,j)=n+1$ is a special case indicating that the height of graph $ B(j)$ above 0 exceeds that of $ A'$ so that no more packet $ b_i (i>k)$ of $ B$ is needed for computing $ M(i,j)$ for $ j$.

  2. Compute $ g(k,j),l(k,j),$ and $ M(k,j)$
    We then compute $ M(k,j)$, the area surrounded by graph $ A'$ and $ B(j)$ in the range $ [0, b_k- b_{j-1}]$ on the Y-axis. $ g(k,j)$ is the maximum difference and $ l(k,j)$ is the minimum difference on the X-axis between $ A'$ and $ B(j)$ in the range $ [0, b_k- b_{j-1}]$ on the Y-axis. These values are computed using the values at $ k-1$ by the following equations.

    \begin{displaymath}\begin{split}M(k,j) &= M(k-1,j) &+ \left\{ \begin{array}{ll...
...box{ if } f(k-1,j)=f(k,j)=n+1 \end{array} \right. \end{split}\end{displaymath} (4)
    \begin{displaymath}\begin{split}L(k,j) &= v(b_k,a_{f(k-1,j)}) \times \left((a_{f...
...times \left((b_k-b_{j-1})-(a_{f(k,j)-1}-a_0)\right) \end{split}\end{displaymath} (5)
    \begin{displaymath}\begin{split}g(k,j)&=\max\{g(k-1,j), \max\{v(b_k,a_i) \vert...
...n\{v(b_k,a_i) \vert f(k-1,j)\leq i\leq f(k,j)\}\} \end{split}\end{displaymath} (6)

    If $ f(k,j)=n+1$, the last term of (6) is not added, and $ v(b_k,a_{n+1})$ is not counted in (7) either.

  3. Compute $ \hat{M}(k,j)$
    If $ f(k,j)=n+1$, the range on the Y-axis of $ B(j)$ covers the range on the Y-axis of $ A'$ ( $ [0,d] \subset [b_0-b_{j-1}, b_k-b_{j-1}]$). Then $ M'(k,j)$, the area surrounded by two graphs when we move $ B(j)$ as close as possible to $ A'$ along the X-axis, can be computed by the following equation.

    $\displaystyle M'(k,j) = \min\{ \left\vert M(k,j) - g(k,j)\times d \right\vert, \left\vert M(k,j) - l(k,j) \times d \right\vert \} $

    We can compute $ \hat{M}(k,j) = \min\{M'(k,i) \vert  i\leq j\}$ by the following equation if either $ \hat{M}(k,j-1)$ or $ M'(k,j)$ is defined.

    $\displaystyle \hat{M}(k,j) = \min\{\hat{M}(k,j-1), M'(k,j)\}$ (7)

After all the computations for $ j=1,2,\ldots,k$ are done, $ M(k)=\hat{M}(k,k)$ is the area surrounded by graph $ A$ and $ B(k)$ in the vertical range of $ A$ when $ B(k)$ moves horizontally and vertically without crossing $ A$ so that $ B(k)$ is as close as possible to $ A$, where $ B(k)$ is a sub array of $ B$:

$\displaystyle B(k):\quad \langle (u(b_1),b_1), \ldots, (u(b_k), b_k) \rangle $

If $ M(k)$ is not defined, the deviation for $ B(k)$ from $ A$ cannot be defined. We can delete objects (such as $ b_j$) associated with $ j=j_k-1,j_k+1,\ldots,j_{k+1}-2$ allocated in memory except for the ones at the minimum. ($ j_k$ is defined by $ j_{k+1} = \max\{j \vert j\geq j_k, f(k,j)=n+1\}$    or $ j_{k+1}=1$    if $ f(k,1)\leq n$.)

When we have finished processing all the packets in $ B$ and suppose the number of packets in $ B$ is $ m$, the deviation for $ B$ from $ A$ is obtained by $ M(m)/d$.


next up previous
Next: Computation Time. Up: Implementation Previous: Implementation
Yoda 2000-11-20