通过一系列分组逻辑门

Stepping through a sequence of grouped logic gates

我正在模拟蛋白质-蛋白质相互作用。我正在使用 Python 将逻辑门编码为模拟蛋白质相互作用的函数。 我的模型基本上是一系列包含逻辑门的组(g0g4)(见图)。最初,我设置了一个 list 包含我的组,然后为每个组设置一个 dict 包含蛋白质(节点)及其起始值(它们所谓的 seedValues,这是t=0).

网络的起始参数

我的问题是:是否有某种方法可以遍历我的组(及其逻辑门函数),它从组 0(图中的 g0)开始,位于 t,并且在 t=t+1 执行组 g0g1,然后在 t=t+2 执行三个组 g0g1g2,依此类推,直到 t=m,其中 m 是所需的迭代次数?

Clarification: Perhaps I am unclear. My problem is this: say that I write a function that steps through my groups, one at a time. It starts at g0 at time t=0, and executes, stores and outputs all the gates in that group, plus all the gates "ahead" of itself (g1 to g4). When this is done, the function ticks time one step forward (t=t+1) and goes to g1 and exeuctes again, including outputting groups g2 to g4. Now is where an error creeps in: for an accurate model, I need to execute g0 at time t=t+1 too, before the program steps to g2. How can I make my program output such sequential "waves" of execution? I imagine I might need to use recursion, but I don't know how.

请参阅我用 "groups" here 表示的示例图像。 图片说明:AB 是开关(程序应该改变它们,作为研究扰动的一种方式), C 是一个常量(从未改变)。 J 是输出(主要用于展示)。 DF 以这种方式构建,只要 A = 0.

我在 Stack Exchange 和 Stack Overflow 上搜索过这个;虽然我看到许多问题与我感兴趣的领域 (1, 2) 相切,但我没有看到任何我确定可以专门解决我的问题的问题。谢谢你的时间。

在我看来,您的问题归结为几个嵌套循环。如果将所有组放入名为 gx 的列表中,并且将时间 t 从 0 逐步增加到某个值 tmax,它在 Python 中看起来像这样。 .

for t in range(tmax):
    for i in range(t):
        nodeExecute(gx[i])

每次递增 t,除了之前的所有组之外,还会执行一组。如果我还是没听懂,请见谅。

对于事件驱动的数字仿真或discrete event simulation,通常使用"time wheel"或"timing wheel"作为基本数据结构。轮子基本上是一个数组,其中每个元素都指向一个列表或模拟事件的动态向量,它们共享 "time mod wheelsize" 的相同值。

时间轮如图所示here

时间轮比 priority queue 更有效,后者也可用于按时间戳的升序处理模拟事件。

事件驱动逻辑仿真伪代码:

t = tStart
While (t < tEnd) {
    process all events scheduled for t and schedule follow-up events
    schedule events from signal sources
    t = t + 1
}

要处理门的分组,您可以将每个组视为具有多个输出的超级门。可能有必要在给定的一组门内对不同的延迟进行建模。

与其编写自己的模拟器,不如在 Hardware Description Language like Verilog and use a ready-made simulator 中描述您的电路。