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


Python Simulation.peek方法代码示例

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


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

示例1: test_schedule_input_presentation

# 需要导入模块: from SimPy import Simulation [as 别名]
# 或者: from SimPy.Simulation import peek [as 别名]
def test_schedule_input_presentation():
    schedule_input_presentation(Tns.p1, Tns.s1, None, 10)
    assert sim.peek() == sim.now()
    schedule_input_presentation(Tns.p1, Tns.s1, start_t=20, duration=10)
    assert sim.Globals.allEventTimes() == [0, 20]
    from scheduling.pynn_scheduling import SIMULATION_END_T as end_t
    assert end_t == 30
开发者ID:agravier,项目名称:pycogmo,代码行数:9,代码来源:pynn_scheduling_tests.py

示例2: run_simulation

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