def utilization(self): # server util: offered load to a single server leb = self.erlB(use_log=True) la = self._A(self.c, self.b, use_log=True) la1 = e_ut.log_trick([[la, 1], [0, -1]]) lb1 = e_ut.log_trick([[0, 1], [leb, -1]])[0] lx1 = np.log(self.a) - np.log(self.m) + lb1 - leb lx = e_ut.log_trick([la1, [lx1, 1]])[0] return np.exp(self.prob_m(use_log=True) + lx)
def sla_prob(self, t, use_log=False): # prob(W <= t) self.queue_ok(string=self.__str__()) lw = e_ut.log_trick([[0, 1], [self.wait_SF(t, use_log=True), -1]])[0] # 1 - p(W>t) = 1 - p3 exp(-alpha t) if use_log is False: return np.exp(lw) else: return lw
def abn_prob(self, use_log=False): # prob(abn) eq.5.23 lw0 = self.sf(0, use_log=True) lps = self.poor_svc_prob(0, use_log=True) lt = e_ut.log_trick([[lw0, 1], [lps, -1]])[0] if use_log == True: return lt else: return np.exp(lt)
def prob_m(self, use_log=False): # Prob(m) eq 5.5 eb = self.erlB(use_log=True) la = self._A(self.c, self.b, use_log=True) ld = e_ut.log_trick([[0, 1], [eb + la, 1], [eb, -1]])[0] lp = eb - ld if use_log == True: return lp else: return np.exp(lp)
def poor_svc_prob(self, t, use_log=False): # Prob(W>t & ~ABN) eq 5.20 la = self._A(self.c, self.b * np.exp(-self.theta * t), use_log=True) lsf = self.sf(t, use_log=True) lr = np.log(self.a / self.m) lx = e_ut.log_trick([[0, 1], [-la, -1]])[0] ly = lsf + self.theta * t - lr + lx if use_log == True: return ly else: return np.exp(ly)
def sla_prob(self, t, use_log=False): # prob(W<= t & !ABN) lp = e_ut.log_trick([[0, 1], [self.abn_prob(use_log=True), -1], [self.poor_svc_prob(t, use_log=True), -1]])[0] try: if use_log == True: return lp else: return np.exp(lp) except RuntimeWarning: s_ut.my_print('Runtime warning::sla_prob::' + self.__str__() + 't: ' + str(t) + ' lp' + str(lp)) if use_log == True: return lp else: return np.exp(lp)
def _gl(self, t): la = self._A(self.c, self.b, use_log=True) lgt = e_ut.log_gamma_lwr(self.c, self.b * np.exp(-self.theta * t)) lg0 = e_ut.log_gamma_lwr(self.c, self.b) if np.isinf(lgt): if np.isinf(lg0): # i.e. 0/0 in the natural scale: use asymptotics ln = self.c * np.log(self.b) - self.c * self.theta * t +\ e_ut.log_trick([[0, 1], [np.log(self.c), 1], [np.log(self.c) + np.log(self.b) - self.theta * t, -1]])[0] ld = np.log(self.c) + np.log(1 + self.c) + e_ut.log_gamma_lwr(self.c, self.b) return ln - ld else: # num = 0 and den > 0 in the natural scale return -np.inf else: return la + lgt - lg0
def erlC(self, use_log=False): # P(wait > 0) = sum_{k>=m} p(k) != p(Q=m) self.queue_ok(string=self.__str__()) if self.m - self.a > 0: l_c = e_ut.log_trick([[0, 1], [-self.m * np.log(self.a) + self.a + np.log(self.m - self.a) + e_ut.log_gamma_upr(self.m, self.a), 1]])[0] if use_log is False: return np.exp(-l_c) else: return -l_c else: if use_log is False: return 1.0 else: return 0.0