你可以获取一个保持块改变其状态的次数吗?

huangapple go评论68阅读模式
英文:

How can I obtain the number of times that a hold block changes its state?

问题

我正在建模供应链流程。情况是,当等待块达到其最大容量时,我会阻止保持块,以停止零部件的流动,当一个零部件离开等待块时,我会解除保持的阻塞。我尝试计算以下内容:

  1. 在整个模拟期间,保持块处于阻塞状态的时间(time())。
  2. 在模拟过程中,此保持块从解除阻塞状态变为阻塞状态的次数(count)。

我尝试使用事件来计算这些内容,但我得到的结果不正确。您能帮助我吗?谢谢!

你可以获取一个保持块改变其状态的次数吗?

英文:

I am modelling a supply chain process. The case is that when the wait block reaches its maximum capacity I block the hold block in order to stop the flow of components and when one component exits the wait block I unblock the hold . What I am trying to calculate is:

  1. How much time is the hold in the block state during the whole simulation ( time()).
  2. The number of times that this hold block changed its state from unblocked to block during the simulation (count)

I tried to calculate this using events but the results that I am obtaining are not correct.Could you give me a hand with this? Thanks!

你可以获取一个保持块改变其状态的次数吗?

答案1

得分: 1

创建两个 double 类型的变量,命名为 timeBlockedblockStartTime(初始值为 0)。还创建一个名为 blockCount 的变量,类型为 int(初始值也为 0)。

在你的代码中,每次阻塞 hold block 时,添加以下行:

blockStartTime = time();
blockCount++;

每次解除阻塞时,添加以下行:

timeBlocked += time() - blockStartTime;

现在额外注意一下,我看到你有多个 hold block,所以我建议对每个 block 都执行上述操作(即为每个 block 重复创建我建议的变量)。如果你有大量的 hold block 并提供更多细节,我们可能能够为你提供更精简的解决方案,但我想上述方法应该足够适用于你的模型。

英文:

Create two variables of type double and call them timeBlocked and blockStartTime (initial value = 0). Also create a variable called blockCount. This one can be of type int (initial value = 0 too).

In your code, every time you block the hold block, add the following line:

blockStartTime = time();
blockStart++;

Every time you unblock it, add the following:

timeBlocked += time() - blockStartTime;

Now as an extra note, I can see you have more than one hold block, so I would recommend doing the above for each one (i.e. create the variables I suggested twice, once for each block). If you have a ton of hold blocks and you provide more details, we may be able to give you a leaner solution, but I guess the above should work well enough for your model.

huangapple
  • 本文由 发表于 2023年2月14日 02:15:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75439748.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定