示例#1
0
def backlog(arr: Arrival,
            ser: Service,
            theta: float,
            prob_b: float,
            tau=1.0,
            indep=True,
            p=1.0) -> float:
    """Implements stationary bound method"""
    if indep:
        p = 1.0

    q = get_q(p=p, indep=indep)

    rho_a_p = arr.rho(theta=p * theta)
    sigma_a_p = arr.sigma(theta=p * theta)
    rho_s_q = ser.rho(theta=q * theta)
    sigma_s_q = ser.sigma(theta=q * theta)

    if rho_a_p >= rho_s_q:
        raise ParameterOutOfBounds(
            f"The arrivals' rho {rho_a_p} has to be smaller than"
            f"the service's rho {rho_s_q}")

    rho_arr_ser = rho_a_p - rho_s_q
    sigma_arr_ser = sigma_a_p + sigma_s_q

    if arr.is_discrete():
        log_part = log(prob_b * (1 - exp(theta * rho_arr_ser)))

        return sigma_arr_ser - log_part / theta

    else:
        log_part = log(prob_b * (1 - exp(theta * tau * rho_arr_ser)))

        return tau * rho_a_p + sigma_arr_ser - log_part / theta
示例#2
0
def output(arr: Arrival,
           ser: Server,
           theta: float,
           delta_time: int,
           indep=True,
           p=1.0) -> float:
    """Implements stationary standard_bound method"""
    if indep:
        p = 1.0
        q = 1.0
    else:
        q = get_q(p=p)

    stability_check(arr=arr, ser=ser, theta=theta, indep=indep, p=p, q=q)
    sigma_sum, rho_diff = get_sigma_rho(arr=arr,
                                        ser=ser,
                                        theta=theta,
                                        indep=indep,
                                        p=p,
                                        q=q)

    try:
        if arr.is_discrete():
            return exp(theta * arr.rho(theta=p * theta) * delta_time) * exp(
                theta * sigma_sum) / (1 - exp(theta * rho_diff))

        else:
            return exp(theta * arr.rho(theta=p * theta) *
                       (delta_time + 1)) * exp(
                           theta * sigma_sum) / (1 - exp(theta * rho_diff))

    except ZeroDivisionError:
        return inf
    def __init__(self, arr: Arrival, ser: Service, indep=True, p=1.0) -> None:
        self.arr = arr
        self.ser = ser

        if indep:
            self.p = 1.0
        else:
            self.p = p
        self.q = get_q(p=p, indep=indep)
示例#4
0
    def __init__(self, ser1: Server, ser2: Server, indep=True, p=1.0) -> None:
        self.ser1 = ser1
        self.ser2 = ser2
        self.indep = indep

        if indep:
            self.p = 1.0
            self.q = 1.0
        else:
            self.p = p
            self.q = get_q(p=p)
 def __init__(self,
              ser1: Service,
              ser2: Service,
              indep=True,
              p=1.0) -> None:
     self.ser1 = ser1
     self.ser2 = ser2
     if indep:
         self.p = 1.0
     else:
         self.p = p
     self.q = get_q(p=p, indep=indep)
示例#6
0
 def __init__(self,
              arr1: Arrival,
              arr2: Arrival,
              indep=True,
              p=1.0) -> None:
     self.arr1 = arr1
     self.arr2 = arr2
     self.indep = indep
     if indep:
         self.p = 1.0
         self.q = 1.0
     else:
         self.p = p
         self.q = get_q(p=p)
    def __init__(self,
                 ser: Server,
                 cross_arr: Arrival,
                 indep=True,
                 p=1.0) -> None:
        self.ser = ser
        self.cross_arr = cross_arr
        self.indep = indep

        if indep:
            self.p = 1.0
            self.q = 1.0
        else:
            self.p = p
            self.q = get_q(p=p)
示例#8
0
def delay_prob(arr: Arrival,
               ser: Server,
               theta: float,
               delay_value: int,
               indep=True,
               p=1.0,
               geom_series=False) -> float:
    """Implements stationary standard_bound method"""
    if indep:
        p = 1.0
        q = 1.0
    else:
        q = get_q(p=p)

    stability_check(arr=arr, ser=ser, theta=theta, indep=indep, p=p, q=q)
    sigma_sum, rho_diff = get_sigma_rho(arr=arr,
                                        ser=ser,
                                        theta=theta,
                                        indep=indep,
                                        p=p,
                                        q=q)

    try:
        if not geom_series:
            if arr.is_discrete():
                return exp(
                    -theta * ser.rho(theta=q * theta) * delay_value) * exp(
                        theta * sigma_sum) / (-rho_diff * theta)
            else:
                tau_opt = 1 / (theta * ser.rho(theta=q * theta))
                return exp(
                    -theta * ser.rho(theta=q * theta) * delay_value) * exp(
                        theta *
                        (ser.rho(theta=q * theta) * tau_opt + sigma_sum)) / (
                            -rho_diff * theta * tau_opt)

        if arr.is_discrete():
            return exp(-theta * ser.rho(theta=q * theta) * delay_value) * exp(
                theta * sigma_sum) / (1 - exp(theta * rho_diff))
        else:
            tau_opt = log(arr.rho(theta=p * theta) /
                          ser.rho(theta=q * theta)) / (theta * rho_diff)
            return exp(-theta * ser.rho(theta=q * theta) * delay_value) * exp(
                theta * (arr.rho(theta=p * theta) * tau_opt + sigma_sum)) / (
                    1 - exp(theta * tau_opt * rho_diff))

    except ZeroDivisionError:
        return inf
示例#9
0
def delay(arr: Arrival,
          ser: Server,
          theta: float,
          prob_d: float,
          indep=True,
          p=1.0,
          geom_series=False) -> float:
    """Implements stationary standard_bound method"""
    if prob_d < 0.0 or prob_d > 1.0:
        raise IllegalArgumentError(f"prob_b={prob_d} must be in (0,1)")

    if indep:
        p = 1.0
        q = 1.0
    else:
        q = get_q(p=p)

    stability_check(arr=arr, ser=ser, theta=theta, indep=indep, p=p, q=q)
    sigma_sum, rho_diff = get_sigma_rho(arr=arr,
                                        ser=ser,
                                        theta=theta,
                                        indep=indep,
                                        p=p,
                                        q=q)

    if not geom_series:
        if arr.is_discrete():
            log_part = log(prob_d * theta * (-rho_diff))
            return (sigma_sum - log_part / theta) / ser.rho(theta=q * theta)
        else:
            tau_opt = 1 / (theta * ser.rho(theta=q * theta))
            log_part = log(prob_d * theta * tau_opt * (-rho_diff))
            return (tau_opt * ser.rho(theta=q * theta) + sigma_sum -
                    log_part / theta) / ser.rho(theta=q * theta)

    if arr.is_discrete():
        log_part = log(prob_d * (1 - exp(theta * rho_diff)))
        return (sigma_sum - log_part / theta) / ser.rho(theta=q * theta)
    else:
        tau_opt = log(arr.rho(theta=p * theta) /
                      ser.rho(theta=q * theta)) / (theta * rho_diff)
        log_part = log(prob_d * (1 - exp(theta * tau_opt * rho_diff)))
        return (tau_opt * arr.rho(theta=p * theta) + sigma_sum -
                log_part / theta) / ser.rho(theta=q * theta)
示例#10
0
def backlog_prob(arr: Arrival,
                 ser: Service,
                 theta: float,
                 backlog_value: float,
                 tau=1.0,
                 indep=True,
                 p=1.0) -> float:
    """Implements stationary bound method"""
    if indep:
        p = 1.0

    q = get_q(p=p, indep=indep)

    rho_a_p = arr.rho(theta=p * theta)
    sigma_a_p = arr.sigma(theta=p * theta)
    rho_s_q = ser.rho(theta=q * theta)
    sigma_s_q = ser.sigma(theta=q * theta)

    if rho_a_p >= rho_s_q:
        raise ParameterOutOfBounds(
            f"The arrivals' rho {rho_a_p} has to be smaller than"
            f"the service's rho {rho_s_q}")

    rho_arr_ser = rho_a_p - rho_s_q
    sigma_arr_ser = sigma_a_p + sigma_s_q

    try:
        if arr.is_discrete():
            return exp(-theta * backlog_value) * exp(
                theta * sigma_arr_ser) / (1 - exp(theta * rho_arr_ser))

        else:
            return exp(-theta * backlog_value) * exp(
                theta * (rho_a_p * tau + sigma_arr_ser)) / (
                    1 - exp(theta * tau * rho_arr_ser))

    except ZeroDivisionError:
        return inf