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


Python Simulation.step方法代码示例

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


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

示例1: run_simulation

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import step [as 别名]
def run_simulation(end_time=None):
    """Runs the simulation while keeping SimPy and PyNN synchronized at
    event times. Runs until no event is scheduled unless end_time is
    provided. if end_time is given, runs until end_time."""
    global SIMULATION_END_T
    def run_pynn(end_t):
        pynn_now = pynnn.get_current_time()
        pynn_now_round = round(pynn_now, PYNN_TIME_ROUNDING)
        delta_t = round(end_t - pynn_now_round, PYNN_TIME_ROUNDING)
        if pynn_now <= pynn_now_round and delta_t > PYNN_TIME_STEP:
            delta_t = round(delta_t - PYNN_TIME_STEP, PYNN_TIME_ROUNDING)
        if delta_t > 0:  # necessary because run(0) may run PyNN by timestep
            pynnn.run(delta_t)  # neuralensemble.org/trac/PyNN/ticket/200
    is_not_end = None
    if end_time == None:
        # Would testing len(sim.Globals.allEventTimes()) be faster?
        is_not_end = lambda t: not isinstance(t, sim.Infinity)
    else:
        DummyProcess().start(at=end_time)
        e_t = end_time
        is_not_end = lambda t: t <= e_t
    for e in RATE_ENC_RESPAWN_DICT.iteritems():
        if e[1] == None:
            continue
        renc, start_time, end_time = e[0], e[1][0], e[1][1]
        _schedule_output_rate_encoder(renc,
                                      start_t=start_time,
                                      end_t=end_time)
        if SIMULATION_END_T < end_time:
            SIMULATION_END_T = end_time
    RATE_ENC_RESPAWN_DICT.clear() # unnecessary as _schedule_output_rate_encoder performs cleanup
    t_event_start = sim.peek()
    while is_not_end(t_event_start):
        LOGGER.debug("Progressing to SimPy event at time %s",
                     t_event_start)
        run_pynn(t_event_start) # run until event start
        sim.step() # process the event
        run_pynn(get_current_time()) # run PyNN until event end
        t_event_start = sim.peek()
    if SIMULATION_END_T < get_current_time():
        SIMULATION_END_T = get_current_time()
开发者ID:agravier,项目名称:pycogmo,代码行数:43,代码来源:pynn_scheduling.py


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