Laura 发表于 2009-6-1 05:24:35

产生load的问题

用create产生load时,系统先将其放在系统自定义的队列space里,在送到用户定义的process里。
我的问题是,希望产生的load达到一定数目后,就停止,直到有新的空余空间(即排队系统中waiting space有限)。
现在我对产生load 的流程(P_Creation2)和load去的下一个流程(P_In2)都做了traffic limit.但space里的load数目却大于这个traffic limit. 所以模拟结果不能确定是否合理。

不知有没有办法设置space的limit(现在我找不到这个系统自己定义的队列space)? 多谢指导。

我的程序是(以前请教过各位):

begin model initialization function
create 1 load of load type L_nullto P_Creation2
   return true
end

begin P_Creation2 arriving procedure
while 1=1 do
   begin
   wait for 1 sec
   create 1 load of load type L_C2 to oneof(2:P_In2,8:die)
   end
end

begin P_In2 arriving procedure
   move into Q_F2
   move into Elevator:cp2
。。。。。

zhdew 发表于 2009-6-1 05:24:36

A:一些概念
    1. Space大概是个假想的队列吧,因为模型没有哪个非运行时的文件里出现过Space的描述。
    2. 对P_Creation2设置traffic limit应该是无效的,因为P_Creation2里只有一个L_null,产生的
新load并不进入P_Creation2。

B:解决你的问题
    1. 如果你想让P_In2一直是满的,首先要设置P_In2的traffic limit,然后,代码如下:
-------------------------------------------------------------------------
begin model initialization function
    create 1 load of L_C2 to P_In2
    return true
end

begin P_In2 arriving procedure
    clone 1 load of L_C2 to P_In2
    move into Q_F2
... ...
-------------------------------------------------------------------------
      如果想让Q_F2满着,就把clone动作拿到第二句。

    2. 其实你想要的应该不是以上那种吧,而是依然以固定时间间隔投放Load,只是遇到没
空间了就暂停下来。这又分两种情况(以下只看P_Creation2):
    2.1 每1秒钟检查是否有空间,有就投放(到P_In2或die);不管是否投放了,都再等下1秒钟,如此循环。
---------------------------------------------------------------------------
begin P_Creation2 arriving procedure
    while 1 = 1 do begin
      wait for 1 sec
      if P_In2 current = P_In2 capacity begin
            create 1 load of load type L_C2 to oneof(2:P_In2,8:die)
      end
    end
end
---------------------------------------------------------------------------
    2.2 每1秒钟检查是否有空间,有就投放;没有的话就等到有,再投放;每次投放Load后开始计时1秒钟,如此循环。
---------------------------------------------------------------------------
begin P_Creation2 arriving procedure
    while 1 = 1 do begin
      wait for 1 sec
      wait until P_In2 current = P_In2 capacity
      create 1 load of load type L_C2 to oneof(2:P_In2,8:die)
    end
end
---------------------------------------------------------------------------
    以上是以P_In2为限制。要以Q_F2为限制,直接把P_In2改成Q_F2就可以了,current和capacity属性对于Process和Queue都有效。

    3. 如果要一次产生某个数量的Load把P_In2填满,等到空了再进入,方法也蛮简单,我就不写出来了。

Laura 发表于 2009-6-2 02:07:16

非常感谢zhdew的耐心指导。
的确我是想,当达到capacity,不再产生load,直到有空余空间再产生。

我按照这个方法做了(2.1和2.2都试了),但运行结果和我以前设traffic limit完全相同,那个Space里的load数 仍然大于所设的limit。也就是说load在下一个流程没有空余空间的情况下也在产生,等在队列space里,有空间就挤进去,这样后面这些load的到达就不是伯努利过程了。

看用户手册上说,“Created loads start in the predefined queue “Space.” You specify which process they go to
first. A created load does not actually enter the system until it can get on the traffic count of the first process. A traffic count that has reached its limit on the first process does not prevent the create action from occurring. The loads are created but wait to enter the first process. Using the create action incorrectly can accidentally create a huge number of loads in the model.

For example:
-------------------------
begin CreateMe arriving
create 1 load of load type Lnew to CreateMe
send to Pnext
end
---------------------------
The create action in the process above is incorrect because there is no time delay between the time the first load enters the process and the time it creates another load and sends it to the same process. An infinite number of loads are created at the same clock time unit. The model enters an infinite loop until the machine runs out of memory.

感觉一个create 好像总在产生load,停不下来?

Laura 发表于 2009-6-2 06:13:08

我发现,如果以Q_F2为限制,即程序中把P_In2改成Q_F2,得到的结果就不一样了,Space里的loads 数就不会超过limit.

zhdew 发表于 2009-6-2 21:10:35

原帖由 Laura 于 2009-6-2 02:07 发表 http://www.simulway.com/bbs/images/common/back.gif
非常感谢zhdew的耐心指导。
的确我是想,当达到capacity,不再产生load,直到有空余空间再产生。

我按照这个方法做了(2.1和2.2都试了),但运行结果和我以前设traffic limit完全相同,那个Space里的load数 仍然大于所设的limit ...
这是我的错。看这句
wait until(或 if) P_In2 current = P_In2 capacity

这里的“=”应该是“<”。。。
马虎了马虎了。

Laura 发表于 2009-6-3 22:50:27

哈哈,zhdew,对于你这种大师来说,这些小错不足为道。我在copy的时候已经改过来了。
不过真的很奇怪,用P_In2做限制,结果和以前完全相同,而用Q_F2为限制,结果似乎就合理了。

anyway, 非常感谢zhdew,你真的太博学了,而且俺这个程序没有你的三次指点,根本无从谈起。如果住的近,一定得请你吃顿大餐!

zhdew 发表于 2009-6-3 23:20:56

原帖由 Laura 于 2009-6-3 22:50 发表 http://www.simulway.com/bbs/images/common/back.gif
哈哈,zhdew,对于你这种大师来说,这些小错不足为道。我在copy的时候已经改过来了。
不过真的很奇怪,用P_In2做限制,结果和以前完全相同,而用Q_F2为限制,结果似乎就合理了。

anyway, 非常感谢zhdew,你真的太博学了,而且俺这个 ...
过奖。

不过很奇怪。手头没有AutoMod,没法测试,你能不能看一下,当P_In2里Load数量达到traffic limit的时候,P_In2的current和capacity各是多少?为何那两句能通过?想不通了,这个。

Laura 发表于 2009-6-4 02:20:48

是这样的,我在改程序的时候,就把wait until(或 if) P_In2 current = P_In2 capacity 的中“=”改成“<”了,因为如果不改的话,一个load都不会产生。我当时想这个可能是你的笔误。
页: [1]
查看完整版本: 产生load的问题