当前位置: 首页>>代码示例>>Python>>正文


Python Simulation.initialize方法代码示例

本文整理汇总了Python中SimPy.Simulation.initialize方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.initialize方法的具体用法?Python Simulation.initialize怎么用?Python Simulation.initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimPy.Simulation的用法示例。


在下文中一共展示了Simulation.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: configure_scheduling

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
def configure_scheduling():
    global SIMULATION_END_T
    sim.initialize()
    pynnn.setup()
    SIMULATION_END_T = 0
    RATE_ENC_RESPAWN_DICT.clear()
    POP_ADAPT_DICT.clear()
开发者ID:agravier,项目名称:pycogmo,代码行数:9,代码来源:pynn_scheduling.py

示例2: testBackPressureLoopTwoServers

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
 def testBackPressureLoopTwoServers(self):
     Simulation.initialize()
     s1 = server.Server(1,
                        resourceCapacity=1,
                        serviceTime=4,
                        serviceTimeModel="constant")
     s2 = server.Server(2,
                        resourceCapacity=1,
                        serviceTime=4,
                        serviceTimeModel="constant")
     c1 = client.Client(id_="Client1",
                        serverList=[s1, s2],
                        replicaSelectionStrategy="primary",
                        accessPattern="uniform",
                        replicationFactor=2,
                        backpressure=True,
                        shadowReadRatio=0.0,
                        rateInterval=20,
                        cubicC=0.000004,
                        cubicSmax=10,
                        cubicBeta=0.2,
                        hysterisisFactor=2,
                        demandWeight=1.0)
     observer = Observer([s1, s2], c1)
     Simulation.activate(observer,
                         observer.testBackPressureLoopTwoServers(),
                         at=0.1)
     Simulation.simulate(until=100)
开发者ID:jean-li,项目名称:kwiken,代码行数:30,代码来源:backpressure_test.py

示例3: test_accumulate_in_time

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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'
开发者ID:prajeshbhat,项目名称:simulacao-trabalho,代码行数:12,代码来源:test_monitor.py

示例4: test_observe_no_time

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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)
开发者ID:prajeshbhat,项目名称:simulacao-trabalho,代码行数:14,代码来源:test_monitor.py

示例5: test_activate

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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)
开发者ID:MaximeCheramy,项目名称:simso-web,代码行数:14,代码来源:test_simident.py

示例6: test_put_store

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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"
开发者ID:MaximeCheramy,项目名称:simso-web,代码行数:15,代码来源:test_simident.py

示例7: test_request

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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"
开发者ID:MaximeCheramy,项目名称:simso-web,代码行数:15,代码来源:test_simident.py

示例8: test_queueevent

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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"
开发者ID:MaximeCheramy,项目名称:simso-web,代码行数:15,代码来源:test_simident.py

示例9: test_get_level

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
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"
开发者ID:MaximeCheramy,项目名称:simso-web,代码行数:15,代码来源:test_simident.py

示例10: model

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
def model():
    print "Initializing..."
    Sim.initialize()

    print "Random seed: %s" % (Parameters.randSeed,)
    random.seed(Parameters.randSeed)

    print "Verbose:", Parameters.verbose

    Parameters.languages = [
        Language(Parameters.langStatuses[i], "Language %s" % (i,)) for i in range(Parameters.numLanguages)
    ]

    Parameters.numSpeakers = 0
    speakers = []
    langIdx = 0
    for population in Parameters.initialDistribution:
        for i in range(population):
            speakers.append(
                Speaker(
                    Parameters.languages[langIdx],
                    gauss(Parameters.position_distribution[langIdx][0], Parameters.position_distribution[langIdx][1]),
                    gauss(Parameters.position_distribution[langIdx][2], Parameters.position_distribution[langIdx][3]),
                    "Speaker %s" % (Parameters.numSpeakers,),
                )
            )
            Parameters.numSpeakers += 1
        langIdx += 1

    for s in speakers:
        s.set_affecting_speakers_list(speakers)

    for s in speakers:
        Sim.activate(s, s.go())
    timer = Timer()
    Sim.activate(timer, timer.tracktime(resolution=0.10))

    print "Speakers: %s" % (Parameters.numSpeakers,)
    print "Initial population distribution:"
    for l in range(len(Parameters.languages)):
        print "\t%s: %s speakers" % (Parameters.languages[l], Parameters.initialDistribution[l])

    print
    print "Simulating..."
    Sim.simulate(until=Parameters.simLength)
    print "Simulation Complete at t=%s" % Sim.now()

    return speakers
开发者ID:adambaker,项目名称:language-evolution-modeling,代码行数:50,代码来源:AdamModel.py

示例11: initialize

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
def initialize():
	print 'Initializing...'
	Sim.initialize()
	
	print 'Random seed: ' + repr(params['random seed'])
	random.seed(params['random seed'])
	
	pop0 = LinePopulation( 500.0, 500.0, params['initial x std dev'], params['initial y std dev'], 
							params['mean speak'], params['mean learn'], params['mean innovation'],
							500.0, params['pop0 loc sd'], params['mean talk radius'] )
	
	for i in range(params['num agents']):
		pop0.new_agent()
	
	segregator = Segregator()
	Sim.activate( segregator, segregator.go() )
开发者ID:adambaker,项目名称:language-evolution-modeling,代码行数:18,代码来源:Segregation.py

示例12: main

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
def main():
	print 'Initializing...'
	Sim.initialize()
		
	white = LinePopulation( params['white x mean'], params['white y mean'],
				params['white x std dev'], params['white y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['white mean loc'], 
				params['white loc sd'], params['white talk radius'], 'white' )
	
	seasoned = LinePopulation( 0.0, 0.0, 0.0, 0.0, params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['seasoned mean loc'], 
				params['seasoned loc sd'], params['seasoned talk radius'], 'seasoned' )
	
	bozal0 = LinePopulation( params['bozal0 x mean'], params['bozal0 y mean'],
				params['bozal0 x std dev'], params['bozal0 y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['bozal mean loc'], 
				params['bozal loc sd'], params['bozal talk radius'], 'bozal 0')
	
	bozal1 = LinePopulation( params['bozal1 x mean'], params['bozal1 y mean'],
				params['bozal1 x std dev'], params['bozal1 y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['bozal mean loc'], 
				params['bozal loc sd'], params['bozal talk radius'], 'bozal 1' )
	
	for i in range(params['num white']):
		white.new_agent()
	for i in range(params['num slaves']):
		if i%2 == 0:
			bozal0.new_agent()
		else:
			bozal1.new_agent()
	
	adjuster = PopAdjuster( white, seasoned, bozal0, bozal1, params['update period'],
					params['pop schedule'], params['white pop targets'],
					params['slave pop targets'], params['proportion seasoned'] )
	Sim.activate( adjuster, adjuster.go() )
	
	number = math.ceil(params['proportion seasoned']*white.num_agents())
	adjuster.get_seasoned( number, white, bozal0, bozal1, seasoned )
	
	plotter = Plotter('gradual', params['plot period'], params['stop time'], params)
	Sim.activate( plotter, plotter.go() )
	
	print 'Simulating...'
	Sim.simulate(until=params['stop time'])
	print 'Simulation Complete at t=%s' % Sim.now()
	
	plotter.cleanup()
开发者ID:adambaker,项目名称:language-evolution-modeling,代码行数:49,代码来源:Gradual.py

示例13: main

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
def main():
	print 'Initializing...'
	Sim.initialize()
	
	Agent.lang_tolerance = params['lang tolerance']
	
	white = LangRelPop( params['white x mean'], params['white y mean'],
				params['white x std dev'], params['white y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['white mean loc'], 
				params['white loc sd'], params['white talk radius'], 'white' )
	
	seasoned = LangRelPop( params['seasoned x mean'], params['seasoned y mean'],
				params['seasoned x std dev'], params['seasoned y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['seasoned mean loc'], 
				params['seasoned loc sd'], params['seasoned talk radius'], 'seasoned' )
	
	bozal0 = LangRelPop( params['bozal0 x mean'], params['bozal0 y mean'],
				params['bozal0 x std dev'], params['bozal0 y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['bozal mean loc'], 
				params['bozal loc sd'], params['bozal talk radius'], 'bozal 0')
	
	bozal1 = LangRelPop( params['bozal1 x mean'], params['bozal1 y mean'],
				params['bozal1 x std dev'], params['bozal1 y std dev'], params['mean speak'], 
				params['mean learn'], params['mean innovation'], params['bozal mean loc'], 
				params['bozal loc sd'], params['bozal talk radius'], 'bozal 1' )
	
	for i in range(params['num white']):
		white.new_agent()	
	for i in range(params['num seasoned']):
		seasoned.new_agent()
	for i in range(params['num bozal']):
		if i%2 == 0:
			bozal0.new_agent()
		else:
			bozal1.new_agent()
	
	plotter = Plotter('centripetal by lang', params['plot period'], params['stop time'], params)
	Sim.activate( plotter, plotter.go() )
	
	print 'Simulating...'
	Sim.simulate(until=params['stop time'])
	print 'Simulation Complete at t=%s' % Sim.now()
	
	plotter.cleanup()
开发者ID:adambaker,项目名称:language-evolution-modeling,代码行数:46,代码来源:LangRelativeSpeaking.py

示例14: visit

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
	def visit(self, res):
		arrive = Sim.now() 	#arrival time
		print "%.3f: %s Arrived" % (Sim.now(), self.name)

		yield Sim.request, self, res
		wait = Sim.now()-arrive	#waiting time
		print "%.3f: %s Waited for %6.3f" % (Sim.now(), self.name, wait)

		tib = random.expovariate(1.0/timeInBank)
		yield Sim.hold, self, tib 
		yield Sim.release, self, res
		print "%.3f: %s took %.3f minutes to complete. Done." \
				% (Sim.now(), self.name, tib)


## Experiment data ##
maxNumber = 5 #max number of customers
maxTime = 400.0 #minutes
timeInBank = 12.0 #minutes
ARRint = 10.0 #mean arrival interval, minutes
theseed = 12345

## Model/Experiment ##
random.seed()
k = Sim.Resource(name="Counter", unitName="Clerk")
Sim.initialize()
s = Source(name="Source")
Sim.activate(s, s.generate(number=maxNumber, meanTBA=ARRint, resource=k), at=0.0)
Sim.simulate(until=maxTime)
开发者ID:lzmacro,项目名称:pyDES,代码行数:31,代码来源:EmergencyDepartment.py

示例15: Monitor2

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import initialize [as 别名]
            Simulation.activate(c, c.checkout())
            arrival = random.expovariate(float(AVGCUST)/CLOSING)
            yield hold, self, arrival

class Monitor2(Monitor):
    def __init__(self):
        Monitor.__init__(self)
        self.min, self.max = (int(2**31-1),0)
    def tally(self, x):
        Monitor.tally(self, x)
        self.min = min(self.min, x)
        self.max = max(self.max, x)
        
				
for run in range(RUNS):
    waittime = Monitor2()
    checkouttime = Monitor2()
    checkout_aisle = Simulation.Resource(AISLES)
    Simulation.initialize()
    cf = Customer_Factory()
    Simulation.activate(cf, cf.run(), 0.0)
    Simulation.simulate(until=CLOSING)

    #print "Customers:", checkouttime.count()
    print "Waiting time average: %.1f" % waittime.mean(), \
          "(std dev %.1f, maximum %.1f)" % (sqrt(waittime.var()),waittime.max)
    #print "Checkout time average: %1f" % checkouttime.mean(), \
    #      "(standard deviation %.1f)" % sqrt(checkouttime.var())

print 'AISLES:', AISLES, '  ITEM TIME:', ITEMTIME
开发者ID:jmaala,项目名称:aup-oop2011a,代码行数:32,代码来源:Market.py


注:本文中的SimPy.Simulation.initialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。