我无法获得输出以显示诸如clock,interarrival之类的参数 说回溯(最近一次呼叫最近)时发生错误: 文件“”,第1行,位于 NameError:未定义名称“ s”。
import numpy as np
class simulation:
def __init__(self):
self.num_customer = 0
self.clock = 0.0
self.t_arrival = self.generate_interarrival()
self.t_departure = float('inf')
self.num_arrivals = 0
self.num_departure = 0
self.wait_t = 0.0
def advance_time(self):
t.event = min(self.t_arrival,self.t_departure)
self.total.wait = self.num_customer*(t.event-self.clock)
self.clock=t.event
if self.t_arrival <= self.t_departure:
self.handle_arrival_event()
else:
self.handle_departure_event()
def handle_arrival_event(self):
self.num_customer +=1
self.num_arrivals +=1
if self.num_customer <=1:
self.t_departure =self.clock +self.generate_service()
self.t_arrival = self.clock + self.generate_interarrival()
def handle_departure_event(self):
self.num_customer -=1
self.num_departure +=1
if self.num_customer >=0:
self.t_departure = self.clock +self.generate_service()
else:
self.t_departure +float('inf')
def generate_interarrival(self):
return np.random.exponential(1./3)
def generate_service(self):
return np.random.exponential(1./4)
np.random.seed(0)
s = simulation()
输出结果 追溯(最近一次通话): 文件“”,第1行,位于 NameError:名称“ s”未定义