def simrun(a, b): sim = simulus.simulator() # create an anonymous simulator dc = simulus.DataCollector( system_times='dataseries') # statistics collection q = mg1(sim, 1.2, a, b, dc) # create m/g/1 queue sim.run(1000) return dc.system_times.mean()
def __init__(self, num_proc, backfill, path): self.jobs = {} self.schedule = [] self.waiting = [] self.running = [] self.backfill = backfill self.path = path self.stats = {} self.cluster = Cluster(num_proc, num_proc, num_proc) self.sim = simulus.simulator()
def sim_run(qdis): global sim, inter_arrival_time, service_time, server sim = simulus.simulator() inter_arrival_time = exp_generator(1.2, sim.rng().randrange(2**32)) service_time = truncnorm_generator(0, 1.6, sim.rng().randrange(2**32)) dc = simulus.DataCollector(system_times='dataseries(all)') server = sim.resource(collect=dc, qdis=qdis) sim.process(gen_arrivals) sim.run(50000) return np.array(dc.system_times.data())
def sim_run(): global sim, inter_arrival_time, service_time, server, low_waits, high_waits sim = simulus.simulator() inter_arrival_time = exp_generator(1.2, sim.rng().randrange(2**32)) service_time = truncnorm_generator(0, 1.6, sim.rng().randrange(2**32)) dc = simulus.DataCollector(system_times='dataseries(all)') server = sim.resource(collect=dc, qdis=simulus.QDIS.PRIORITY) sim.process(gen_arrivals) low_waits, high_waits = [], [] sim.run(50000) return np.array( dc.system_times.data()), np.array(low_waits), np.array(high_waits)
def __init__(self, input, n, location_sampler=random.sample, strategy_generator=lambda: random.uniform(.5, 1.), rate_generator=lambda: abs(random.normalvariate(1, .5)), person_mover=random.uniform, fire_mover=random.sample, fire_rate=2, bottleneck_delay=1, animation_delay=.1, verbose=False, **kwargs): ''' constructor method --- graph (dict): a representation of the floor plan as per our specification n (int): number of people in the simulation ''' self.sim = simulus.simulator() self.parser = FloorParser() self.animation_delay = animation_delay self.verbose = verbose with open(input, 'r') as f: self.graph = self.parser.parse(f.read()) self.numpeople = n self.location_sampler = location_sampler self.strategy_generator = strategy_generator self.rate_generator = rate_generator self.person_mover = person_mover self.fire_mover = fire_mover self.fire_rate = fire_rate self.bottleneck_delay = bottleneck_delay self.kwargs = kwargs self.setup()
in_systems.append((sim.now, len(queue))) waits.append(sim.now - t) # there are remaining customers in system if len(queue) > 0: # schedule the next customer's departure sim.sched(depart, offset=next(service_time)) random.seed(13579) # global random seed queue = deque() in_systems = [(0, 0)] waits = [] sim = simulus.simulator('ssq') inter_arrival_time = exp_generator(1.2, sim.rng().randrange(2**32)) service_time = exp_generator(0.8, sim.rng().randrange(2**32)) sim.sched(arrive, offset=next(inter_arrival_time)) sim.run(10000) print('wait times: %r...' % waits[:3]) print('number customers in systems: %r...' % in_systems[:3]) waits = np.array(waits) print("wait time: mean=%g, stdev=%g" % (waits.mean(), waits.std())) # area under curve divided by time is the # average number of customers in system auc, last_t, last_l = 0, 0, 0 for t, l in in_systems:
demand_response_arrival = True # create a job dictionary with the necessary job information job = { "job_id": raw_job["job_id"], "submit_time": raw_job["submit_time"], "num_req_processors": raw_job["num_req_processors"], #number of required processors "freq": freq, "regress_coeff_runtime": runtime_reg, "regress_coeff_power": power_reg, "dr_arrival": demand_response_arrival, } processed_jobs.append(job) # instead of passing actual runtime as arguments, regression # coefficients is passed runtime_reg = regression(freq, runtime, 2) # regression coefficients for runtime power_reg = regression(freq, power, 3) # regression coefficients for power usage return processed_jobs model_parameters = { "debug_options": set(["job_stat"]), } trace_file_path = "../data/UniLu-Gaia-2014-5K" jobs = process_trace_jobs(trace_file_path) sim = simulus.simulator() JobScheduler(sim, jobs, model_parameters) sim.run()
# the arrived customer is the only one in system if len(self.queue) == 1: # schedule the customer's departure self.sim.sched(self.depart, offset=next(self.service_time)) def depart(self): '''Event handler for customer departure.''' log.info('%g: customer departs (num_in_system=%d->%d)' % (sim.now, len(self.queue), len(self.queue) - 1)) # remove a customer from the head of the queue t = self.queue.popleft() self.in_systems.append((self.sim.now, len(self.queue))) self.waits.append(self.sim.now - t) # there are remaining customers in system if len(self.queue) > 0: # schedule the next customer's departure self.sim.sched(self.depart, offset=next(self.service_time)) if __name__ == '__main__': logging.basicConfig() logging.getLogger(__name__).setLevel(logging.DEBUG) random.seed(13579) # global random seed sim = simulus.simulator('mm1') # create a simulator instance q = mm1(sim, 1.2, 0.8) # create the m/m/1 queue sim.run(10)
def __init__(self): self.sim = simulus.simulator() self.pre = None # Pre-event function self.pre_args = None self.post = None # Post-event function self.post_args = None
def simrun(a, b): sim = simulus.simulator() # create an anonymous simulator dc = simulus.DataCollector( system_times='dataseries') # statistics collection q = mg1(sim, 1.2, a, b, dc) # create m/g/1 queue sim.run(1000) return dc.system_times.mean() if __name__ == '__main__': # set debug level logging (will print all info messages) logging.basicConfig() logging.getLogger(__name__).setLevel(logging.DEBUG) random.seed(13579) # global random seed sim = simulus.simulator('mg1') # create an anonymous simulator instance q = mg1(sim, 1.2, 0, 0.8) # create the m/g/1 queue sim.run(10) # turn logging to warning level (will skip all info messages) logging.getLogger(__name__).setLevel(logging.WARNING) x = np.linspace(0.1, 3.0, 10) print('b\tmean\tlow\thigh') for b in x: # list of mean wait time from 25 trials z = [] for _ in range(25): z.append(simrun(0, b)) z = np.array(z)