def __init__ (self, eid, mask, ts, ack, otp): self.msg_type = MSG_OTP_ACK self.eid = IPAddr(eid) #EID to register #self.mask = struct.pack('>I', mask)#EID mask self.mask = mask gammaplain = Gamma(eid, mask, ts, ack, otp) self.gamma = gammaplain.encrypt() return
def append(self, item): pre = self.head curr = self.head temp = item[0] if self.head == 0: self.head = Node(item) return else: val = curr.docno curr = curr.next while curr != 0: val += Gamma.__gammaUncompress__(curr.docno) pre = curr curr = curr.next # val += Gamma.__gammaUncompress__(curr.docno) item[0] = Gamma.__gamma__(temp - val) pre.next = Node(item)
def Test2(): env=simpy.Environment() gamma = Gamma([2,3],[0.4,0.6]) B = EmbeddedBuffer(env,gamma) Source = Source_Geo(env,"Source",0.6,B) Server = Server_Geo(env,"Server",0.2,B) env.run(until=20) print ("Buffer average length = ",B.average_length) print ("Average throughput = ",Server.average_throughput) print ("Blocking probability = ",Source.blocking_probability)
def output(self): p = self.head if p == 0: print('empty') s = '' count = p.docno s += str(count)+','+str(p.tf)+'|' p = p.next while p != 0: # print(count) count += Gamma.__gammaUncompress__(p.docno) s += str(count)+','+str(p.tf)+'|' p = p.next return s
def increase(self, docno): if self.is_empty(): # print('Linklist is empty.') return False p = self.head docno_val = p.docno while p.next != 0 and not docno_val == docno: # 匹配docno p = p.next docno_val += Gamma.__gammaUncompress__(p.docno) # 解压?没懂 if docno_val == docno: p.tf += 1 # 词项频率加一 return True else: return False
def increase(self,value): if self.is_empty(): #print('Linklist is empty.') return False p = self.head docno_val=p.docno while p.next!=0 and not docno_val == value: p = p.next docno_val += Gamma.__gammaUncompress__(p.docno) if docno_val == value: p.tf+=1 return True else: return False
def output(self): p = self.head if p == 0: print('empty') s = '' count = p.docno s += str(count) + ',' + str(p.tf) + '|' p = p.next while p != 0: # print(count) count += Gamma.__gammaUncompress__(p.docno) s += str(count) + ',' + str(p.tf) + '|' p = p.next return s
def Simulate(y, rand_seed, simulation_length): env = simpy.Environment() random.seed(rand_seed) stencil, alphas = get_stencil_and_alphas(y, y_min_bound, y_max_bound, stencil_size, s, r) gamma = Gamma(stencil, alphas) C = EmbeddedBuffer(env, gamma) Source = Source_Geo(env, "Source", arrival_probability, C) Server = Server_Geo(env, "Server", service_probability, C) env.run(until=simulation_length) average_length = C.average_length average_throughput = Server.average_throughput blocking_probability = Source.blocking_probability return average_length, average_throughput, blocking_probability
def gamma(x): return Gamma(float(x))