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


Python Simulation.simulate方法代码示例

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


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

示例1: testBackPressureLoopTwoServers

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例2: test_accumulate_in_time

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例3: test_activate

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例4: test_observe_no_time

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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_put_store

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例6: test_request

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例7: test_queueevent

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例8: test_get_level

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例9: model

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例10: main

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例11: main

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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

示例12: simulate

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [as 别名]
def simulate():
	print 'Simulating...'
	Sim.simulate(until=params['stop time'])
	print 'Simulation Complete at t=%s' % Sim.now()
开发者ID:adambaker,项目名称:language-evolution-modeling,代码行数:6,代码来源:Segregation.py

示例13: generators

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [as 别名]
                          accessPattern=args.accessPattern,
                          replicationFactor=args.replicationFactor)
        clients.append(c)

    # Start workload generators (analogous to YCSB)
    latencyMonitor = Simulation.Monitor(name="Latency")

    for i in range(args.numWorkload):
        w = workload.Workload(i, latencyMonitor)
        Simulation.activate(w, w.run(clients,
                                     "poisson",
                                     args.constArrivalTime, args.numRequests/args.numWorkload), at=0.0)
        workloadGens.append(w)

    # Begin simulation
    Simulation.simulate(until=args.simulationDuration)

    #
    # Print a bunch of timeseries
    #
    pendingRequestsFD = open("../logs/%s_PendingRequests" %
                             (args.expPrefix), 'w')
    waitMonFD = open("../logs/%s_WaitMon" % (args.expPrefix), 'w')
    actMonFD = open("../logs/%s_ActMon" % (args.expPrefix), 'w')
    latencyFD = open("../logs/%s_Latency" % (args.expPrefix), 'w')
    latencyTrackerFD = open("../logs/%s_LatencyTracker" % (args.expPrefix), 'w')

    for clientNode in clients:
        printMonitorTimeSeriesToFile(pendingRequestsFD,
                                     clientNode.id,
                                     clientNode.pendingRequestsMonitor)
开发者ID:mcanini,项目名称:absim,代码行数:33,代码来源:experiment.py

示例14: LqnNetwork

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [as 别名]
logger.info("*************************************************")
logger.info("Starting Simulation.")
logger.info("Current time is %d", sim.now())

network = LqnNetwork("Kilkenny LQN", sim)
network.create_network()
sim.activate(network, network.run(), at=0.0)

total_quids_in_network = Level(
    name="total_quids_in_network",
    unitName="quids",
    capacity="unbounded",
    initialBuffered=0,
    monitored=True,
    monitorType=Monitor,
)

# IMPORTANT: To activate profiling, uncomment the following
# line and comment the subsequent.
# cProfile.run('sim.simulate(until=90)')
sim.simulate(until=90)


logger.info("************************************************")
logger.info("Simulation terminated")
logger.info("Current time is %d", sim.now())
# print "The quid level in the " + network.council.id + " account has been:"
# print network.council_quids.yseries()
# print "The quid level in the " + network.members[3].id + " account has been:"
# print network.a_member_quids.yseries()
开发者ID:stephenbee,项目名称:lqn,代码行数:32,代码来源:thelqn.py

示例15: Monitor2

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import simulate [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.simulate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。