Exemplo n.º 1
0
def pytest_funcarg__sim(request):
    if request.param == 'default':
        return Simulation.Simulation()
    elif request.param == 'step':
        return SimulationStep.SimulationStep()
    elif request.param == 'trace':
        return SimulationTrace.SimulationTrace()
    elif request.param == 'rt':
        return SimulationRT.SimulationRT()
    elif request.param.startswith('global'):
        if request.param.endswith('default'):
            Globals.sim = Simulation.Simulation()
        elif request.param.endswith('step'):
            Globals.sim = SimulationStep.SimulationStep()
        elif request.param.endswith('trace'):
            Globals.sim = SimulationTrace.SimulationTrace()
        elif request.param.endswith('rt'):
            Globals.sim = SimulationRT.SimulationRT()
        return Globals.sim
Exemplo n.º 2
0
def test_accumulate_in_time():
    """Tests accumulation over simulation time"""
    s = Simulation()
    s.initialize()
    m3 = Monitor(name='third', sim=s)
    T3 = Thing(name='Job', M=m3, sim=s)
    assert m3.startTime == 0, 'Accumulate startTime wrong'
    s.activate(T3, T3.execute(), 0.0)
    s.simulate(until=30.0)
    assert m3.startTime == 0, 'Accumulate startTime wrong'
Exemplo n.º 3
0
def test_activate():
    """Test of "activate" call"""
    s = Simulation()
    s.initialize()
    r = Activatetest(sim=s)
    try:
        activate(r, r.run())  ## missing s.
    except FatalSimerror:
        pass
    else:
        assert False, "expected FatalSimerror"
    s.simulate(until=1)
Exemplo n.º 4
0
def test_put_store():
    """Test of "yield put,self,store" """
    s = Simulation()
    s.initialize()
    store = Store()  # wrong sim
    r = PutStoretest(sim=s)
    s.activate(r, r.run(store=store))
    try:
        s.simulate(until=1)
    except FatalSimerror:
        pass
    else:
        assert False, "expected FatalSimerror"
Exemplo n.º 5
0
def test_request():
    """Test of "yield request,self,res" """
    s = Simulation()
    s.initialize()
    res = Resource()  # wrong sim
    r = Requesttest(sim=s)
    s.activate(r, r.run(res=res))
    try:
        s.simulate(until=1)
    except FatalSimerror:
        pass
    else:
        assert False, "expected FatalSimerror"
Exemplo n.º 6
0
def test_queueevent():
    """Test of "yield queueevent,self,evt" """
    s = Simulation()
    s.initialize()
    evt = SimEvent()  ## wrong sim
    w = Queueeventtest(sim=s)
    s.activate(w, w.run(event=evt))
    try:
        s.simulate(until=1)
    except FatalSimerror:
        pass
    else:
        assert False, "expected FatalSimerror"
Exemplo n.º 7
0
def test_get_level():
    """Test of "yield get,self,level" """
    s = Simulation()
    s.initialize()
    levl = Level()  # wrong sim
    r = GetLeveltest(sim=s)
    s.activate(r, r.run(level=levl))
    try:
        s.simulate(until=1)
    except FatalSimerror:
        pass
    else:
        assert False, "expected FatalSimerror"
Exemplo n.º 8
0
def test_observe_no_time():
    """Observe with time being picked up from now()"""
    s = Simulation()
    s.initialize()
    m = Monitor(name='No time', sim=s)
    t = Thing(m, sim=s)
    s.activate(t, t.execute(), 0.0)
    s.simulate(until=20.0)
    assert m.yseries() == (0, 10, 5), 'yseries wrong:%s' % (m.yseries(), )
    assert m.tseries() == (0, 10, 20), 'tseries wrong:%s' % (m.tseries(), )
    assert m.total() == 15, 'total wrong:%s' % m.total()
    assert m.timeAverage(
        10.0) == 5.0, 'time average is wrong: %s' % m.timeAverage(10.0)
Exemplo n.º 9
0
	def __init__(self):
		self.numberOfcores = 1
		#self.scale_par = scalePar
		#self.contentType = 'All'
		self.workload = list([0.0])
		self.rand = random.mtrand.RandomState()
		self.process = Simulation()
		self.queueLengthMon = Monitor(sim=self.process, name = 'Queue length')
		self.workLoadMon = Monitor(sim=self.process, name = 'Workload')
		self.waitTimeMon = Monitor(sim=self.process, name = 'Wait Time in System')
		self.processorCores = Resource(self.numberOfcores,sim=self.process,monitored=True, monitorType=Monitor) #number of cores
		self.queueLength = list([0])
		self.serviceTimesMon = list([])
		self.interArrivalTime = Tally(sim=self.process)
Exemplo n.º 10
0
def run_simulation( t, steps, runs ):
    for r in range( runs ):
        sim = Simulation()
        sim.initialize()
        
        bank = Bank( monitored=True, monitorType=Tally, sim=sim )
        bank.setServicetime( t )

        src = CustomerGenerator( sim=sim )
        sim.activate( src, src.produce( bank ) )

        sim.startCollection( when=steps//2 )
        sim.simulate( until=steps )
        
        print t, bank.waitMon.mean()
Exemplo n.º 11
0
rho = lam / mu

NoRejected = 0
NoInService = 0
Busy = 0

JobRate = lam
JobMax = 10000

JobTRACING = 0
JobGenTRACING = 0

## Model/Experiment ------------------------------

seed(111333)
s = Simulation()
BM = Monitor(sim=s)
MT = Monitor(sim=s)

s.initialize()
jbg = JobGen(sim=s)
s.activate(jbg, jbg.execute(1.0, JobMax, mu), 0.0)
s.simulate(until=20000.0)

## Analysis/output -------------------------

print 'bcc'
print "time at the end =", s.now()
print "now=", s.now(), " startTime ", BM.startTime
print "No Rejected = %d, ratio= %s" % (NoRejected, (1.0 * NoRejected) / JobMax)
print "Busy proportion (%6s) = %8.6f" % (