Try   HackMD

佇列系統期末整理

目錄

Birth-Death Process(BDP)

  • 在 CTMC 的基礎上定義出來的一種 process

  • 基礎定義:

    1. Pj(t)=P(X(t)=j),t0,j0,X(0)=r,r0
      ,其中
      X(0)=r
      代表 initial state 在
      r
    2. Pr(0)=P(X(0)=r)=1
      (initial state probability)
    3. Pi,k(s,t)=P(X(t)=k|P(s)=i), 0st<
      (同前面 DTMC 和 CTMC 定義)
    4. Pi,k(t)=Pi,k(0,t)=P(X(t)=k|P(0)=i)
      (time homogeneous)
  • 討論間隔時間為極短時 (

    h0+,可假設只會發生一種事件):

    1. if
      |ki|2,Pi,k(t,t+h)=o(h)
      ,也就是發生改變兩個狀態值的機率極低。
    2. if
      |ki|1,Pi,k(t,t+h)=

      {[ai(t)+κ(t)]h+o(h),k=i+1,i01[ai(t)+bi(t)+κ(t)]h+o(h),k=i,i>01[a0(t)+κ(t)]h+o(h),k=i=0[bi(t)]h+o(h),k=i1,i1
      • a(t)
        代表 birth rate
      • b(t)
        代表 death rate
      • κ(t)
        代表 immigration rate (immegrate in),底下的部分假設這個數值為
        0

time-homogeneous BDP

  • ai(t)ai, bi(t)bi

  • transitional functions:

    {Pi,0(t)=a0Pi,0(t)+b1Pi,1(t)Pi,k(t)=(ak+bk)Pi,k(t)+ak1Pi,k1(t)+bk+1Pi,k+1(t),k>1

  • sojourn time(waiting time

    dk for change of state from state
    k
    ) is exponentially distributed,
    dk=ak+bk

    • 並且這個數值與到達 state
      k
      前的路徑無關
    • 在 state
      k
      時,前往
      k+1
      的機率
      pk=akdk
      ,前往
      k1
      的機率
      qk=bkdk
      • 對於 state
        0
        來說,一開始的
        p0=1
        ;再次抵達 state
        0
        後,
        q0=1
        ,也就是不再離開 state
        0
  • If

    p0=1,0<pk<1,k1

    1. Pk(t)
      滿足下列 ODE:
      {P0(t)=a0P0(t)+b1P1(t)Pi,k(t)=(ak+bk)Pk(t)+ak1Pk1(t)+bk+1Pk+1(t)
    2. 對於所有
      k0
      ,極限
      limtPk(t)=πk
      存在,而且與 initial distribution 無關。(limiting distribution)
      • 如果
        limk=0ρk<
        ,其中
        ρ0=1,ρk=a0a1ak1b1b2bk,k1
        ,那
        πk>0,k0
        而且符合下式
        {π0=[j=0ρj]1πk=ρkπ0
      • 如果
        limk=0ρk=
        ,那
        πk=0,k0
        。 (limiting distribution 不存在)
  • balance equation

    • local balance equation(只討論單邊的鄰居)
      {akPk+bk+1Pk+1=0bkPk+ak1Pk1=0
    • global balance equation(所有鄰居都要討論)
      (ak+bk)Pk+ak1Pk1+bk+1Pk+1=0

Definition of Queueing system

  • Notation

    • (A/B/c/d/e/x)
  • Arrival process(

    A)

    • 使用 intearrival time 的 distribution 描述,並且假設各段 interarrival time 互相獨立。
    • 可能受到顧客數量影響
  • Service process(

    B)

    • 用來描述 server 服務 customer 的 process
    • 在基礎的 queueing model 內假設是 i.i.d random variables
    • 可能受到顧客數量影響
  • 對於 arrival process 和 service process 可能有以下幾種參數:

    • M
      : Memoryless,也就是 exponential distribution
    • Er
      : order-r Erlang distribution
    • Hr
      : order-r hyperexponential distribution
    • D
      : deterministic (固定不變的常數)
    • G
      or
      GI
      : 某個 i.i.d 的 distribution
  • System structure

    • c
      : server 的數量有幾個
    • d
      : System capacity,也就是整個 queueing system 可以容納多少顧客(包含 queue size 和 server count)。(default value:
      )
      • 如果
        c=d
        ,代表這個 queueing system 內沒有任何 waiting room(buffer)。
      • 如果
        c<d
        ,顧客從開始進入 queueing system 到開始被服務的時間稱為 waiting time。
    • e
      : 顧客的總數量 (default value:
      )
  • Service displine(

    x)

    • server 是如何服務 customer 的,預設是 FIFO(FCFS)。

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Work-conserving property

  • 如果顧客進入 queueing system 時有空閒的 server,這個顧客會立即被服務。

Customer loss probability

  • q=limnmnn
    mn
    代表這
    n
    個顧客中沒成功進入 system 的顧客數量。

Waiting time distribution

  • F(x): waiting time distribution 的 CDF
    {F(x)=limnFn(x),x>0Fn(x)=1nn=1nJwix ,x>0

    其中
    wi
    是第
    i
    位顧客的 waiting time。

  • Mean waiting time

    • W(1)=limn1n(W1++Wn)
      ,此時的
      W(1)
      就是 mean waiting time。
      • W(k)=limn1n(W1k++Wnk)
        ,這個算法是計算更高維度的 mean waiting time。
  • Busy period

    • [an,bn),an<bn<an+1,n1
      • idle period:
        [bn,an+1)
    • 這寫法代表 第
      n
      次的 busy period
  • Queue Length distribution

    • L(t),t0
      : 在時間
      t
      時 system 內的顧客數量。
    • L¯k(t)
      : 在時間
      (0,t)
      內,有
      k
      個顧客的時間比例。
      • pk=limtL¯k(t),k0

Little's law(formula)

  • 系統中平均顧客數 = arrival rate * 平均顧客在系統內的時間

    • L=λT
  • 這個算法與以下條件無關:

    • 系統的定義
    • Arrival(Service) time distribution
    • Server 數量
    • Waiting room(buffer) 大小
    • Service discipline

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

  • 其他變種
    • 只針對 Queue 來看
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →
    • 只針對 Server 來看
      Image Not Showing Possible Reasons
      • The image file may be corrupted
      • The server hosting the image is unavailable
      • The image path is incorrect
      • The image format is not supported
      Learn More →

Poisson Arrivals See time Average(PASTA)

  • 在穩定態時,在 state
    k(k>0)
    的機率相等於在一個 customer arrives 時看到 system 在 state
    k
    的機率。
    • 用數學式來表示為
      limtP(L(t)=k)=limtP(L(t)=k|Ek(t)),k0
      • 其中
        L(t)
        為在
        t
        時間時 system 內的顧客數,
        Ek(t)
        則是在時間 t 時發生了 arrival。

M/M/1 queue

  • 1個 server,system size 為無限
  • arrival process: poisson process with rate
    λ
  • service process: exponentially distributed with rate
    μ
  • service disciplne: FCFS
  • work-conserving service process

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

state transition probability

  • Pi,j(t)=P(N(t)=j|N(0)=i)
    ,
    Δ
    值極小

{pi,i+1(Δ)=λΔ+o(Δ),i=0.1,pi,i1(Δ)=μΔ+o(Δ),i=1,2,pi,i(Δ)=1(λ+μ)Δ+o(Δ),i=1,2,p0,0(Δ)=1λΔ+o(Δ)

global balance equation

{λpn1+μpn+1(λ+μ)pn=0,n1μp1λp0=0,n=0

迭代法解

  • 目標是求得
    p0
    pn
    的 close form

μp1λp0=0p1=λμp0
λp0+μp2(λ+μ)p1=0

p2=1μ((λ+μ)p1λp0)=1μ((λ+μ)λμp0λp0)=1μ(λ2μp0)=λ2μ2p0

pn=(λμ)np0

  • 定義
    ρλμ
    為 ultilization factor(rate)

n=0ρnp0=111ρp0=1, if ρ<1p0=1ρpn=ρn(1ρ)

透過 generating function 解

  • 定義
    P(z)=n=0znpn, |z|1
    (
    z
    是複數平面上一點,在單位圓內)
    {(λ+μ)pn=λpn1+μpn+1, n1λp0=μp1, n=0

    /μ
    後寫成
    {ρpn=ρpn1+pn+1, n1ρp0=p1, n=0

    同乘上
    zn
    並將所有式子相加起來
    (ρ+1)n=1znpn+ρp0=ρn=1znpn1+n=0znpn+1

    的係數盡可能調成與
    P(z)
    一致
    (ρ+1)n=0znpnp0=ρzn=1zn1pn1+1zn=1zn+1pn+1(ρ+1)P(z)p0=ρzP(z)+1z(P(z)p0)(ρz2ρzz+1)P(z)=(1z)p0P(z)=p01ρz

    boundary condition: z = 1
    P(z=1)=n=01npn=n=0pn=1=p01ρp0=1ρ,P(z)=1ρ1ρz, ρ<1, |z|1

    P(z)=1ρ1ρz=n=0(1ρ)ρnzn=n=0znpnpn=(1ρ)ρn

long-term system

  • mean system size

    N¯=i=0iPi=ρ1ρ=λμλ

  • 因為 service time 是 exponential distirbution,剩餘的 service time (waiting)也是 exponential distribution

  • mean system time

    D(t)=i=1N(t)Yi+Y

    • Yi
      : service time of customer
      i
    • Y
      : remaining service time
  • E(D(t))=D¯=E(Y1)N¯+E(Y)=1μλμλ+1μ=1μλ

waiting time distribution

  • Tq
    : random variable representing time spent waiting in queue
  • Dq(t)
    : CDF of
    Tq
  1. t = 0

    q(n)Pr{n in system at arrival}

    • q(n)=p(n)
      in M/M/1

    Dq(0)=Pr{Tq0}=Pr{Tq=0}(waiting time can not be negative)=Pr{system is empty at arrival}=q0=p0=1ρ

  2. t > 0

    Dq(t)=Pr{Tqt}=n=1Pr{Tqt|n in system at arrival}×Pr{n in system at arrival}+Pr{Tq=0}=n=1Pr{time for n service completion|n in system at arrival}×pn+p0=n=1(1ρ)ρn0tμ(μx)n1(n1)!eμxdx+(1ρ)=(1ρ)ρ0tμeμxn=1(ρμx)n1(n1)!+(1ρ)=(1ρ)ρ0tμeμx(1ρ)+(1ρ)=ρ0tμ(1ρ)eμ(1ρ)x+(1ρ)=ρ[1eμ(1ρ)t]+(1ρ)=1ρeμ(1ρ)t

    Dq=E[Tq]=0tdDq(t)=0t[ρμ(1ρ)eμ(1ρ)t]dt=ρ1μ(1ρ)

system time distribution

  • T
    : random variable representing time a customer stays in the system
  • D(t)
    : CDF of
    T

D(t)=Pr{Tt}=n=0Pr{Tt|n in system at arrival}×qn=n=0(1ρ)ρn0tμeμx(μx)n(n)!dx=(1ρ)0tμeμxn=0(ρμx)n(n)!dx=(1ρ)0tμe(1ρ)μxdx=1e(1ρ)μtD¯=1μ(1ρ)=1μλ

  • Xs
    : number of customers being served
    • E(Xs)=0q0+1(1q0)=(1p0)=ρ
    • with Little's Law:
      E(Xs)=λ¯x¯=λ1μ=λμ=ρ
  • X
    : number of customers in the system
    • E(X)=k=0kpk=ρ1ρ
  • Xw
    : number of customers waiting in the system
    • E(Xw)=k=0(k1)pk=k=0kpkk=0pk=ρ21ρ

System time, waiting time, service time 的關係

  • T
    : system time
  • W
    : waiting time
  • x
    : service time

T=W+xT¯=W¯+x¯
用 Little's Law 可以得到

  • T¯=E(X)λ=1μ(1ρ)
  • W¯=E(Xw)λ=ρμ(1ρ)
  • x¯=1μ

T¯ 也可用另一種方式計算得到
T¯=x¯+k=0kx¯pk

M/M/c queue

state transition probability

{Pi,i+1(Δ)=λΔ+o(Δ),i=0,1,Pi,i1(Δ)=iμΔ+o(Δ),0icPi,i(Δ)=1(λ+iμ)Δ+o(Δ),0icPi,i(Δ)=1(λ+cμ)Δ+o(Δ),ic

global balance equation

{0=(λ+nμ)pn+λpn1+(n+1)μpn+1,0<n<c0=(λ+cμ)pn+λpn1+(n+1)μpn+1,nc0=λp0+μp1

pn=λnμpn1=(λμ)n1n!p0,n=1,2,,c1
pn=λcμpn1=(λμ)n1c!1cncp0,nc

p0=[1c!(λμ)c1(1λcμ)+j=0c1(λμ)j1j!]1

  • ρ=λcμ,r=λμ
  • pn=

    {rnn!p0,0<n<crncncc!p0,nc

L, Lq, W(T), Wq(Tq)

  • L
    : mean number of customers in the system
  • Lq
    : mean number of customers in the queue
  • W
    : mean system time
  • Wq
    : mean waiting time in the queue

Lq=n=c+1(nc)pn=n=c+1(nc)rncncc!p0=rcc!p0n=c+1(nc)(rc)nc=rcc!p0n=c+1(nc)(ρ)nc=rcc!p0ρ(1ρ)2=rcc!(1ρ)2p0

L=Lq+r=rcc!(1ρ)2p0+r


T¯=x¯+W¯=1μ+k=cE(W|k)pk(a)
E(T)=1μ+k=ckc+1cμpk

T¯=1μ+k=ckc+1cμpc(λcμ)kc=1μ+pccμk=c(kc+1)(λcμ)kc=1μ+pccμi=1i(λcμ)i1=1μ+cμpc(cμλ)2


Dq(0)=Pr{Tq=0}=Pr{c1 in system at arrival}=n=0c1qn=p0n=0c1rnn!,p0=(rcc!(1ρ)+n=0c1rnn!)1=1rcc!(1ρ)p0Pr{Tq>0}=rcc!(1ρ)p0


Dq(t)=Pr{Tqt}=n=cPr{nc+1 completionst|n in system at arrival}qn+Dq(0)=n=0rccncc!p00tcμ(cμx)nc(nc)!ecμxdx+Dq(0)=rc(c1)!p00tμecμxn=0(rμx)nc(nc)!dx+Dq(0)=rc(c1)!p00tμeμ(cr)xdx+Dq(0)=rc(c1)!(cr)p00tμ(cr)eμ(cr)xdx+Dq(0)=rcc!(1ρ)(1e(cμλ)t)+Dq(0),Dq(0)=rcc!(1ρ)p0=1rcc!(1ρ)(1e(cμλ)t)=1Pr{Tq>t}Pr{Tq>t}=rcc!(1ρ)(1e(cμλ)t)


Pr{Tq>0}=rcp0c!(1ρ),Pr{Tq>t}=rcp0c!(1ρ)e(cμλ)t
Pr{Tq>t|Tq>0}=Pr{Tq>t}Pr{Tq>0}=1e(cμλ)t

Finite-Source Queue

  • λn=

    {(Mn)λ, 0n<M0, nM
  • μn=

    {nμ, 0n<ccμ, nc
tags: 1111_courses queueing system