设为首页收藏本站

最大的系统仿真与系统优化公益交流社区

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 6654|回复: 7

[求助] 产生load的问题

[复制链接]
发表于 2009-6-1 05:24:35 | 显示全部楼层 |阅读模式
5仿真币
用create产生load时,系统先将其放在系统自定义的队列space里,在送到用户定义的process里。
, D4 h) f+ Y1 A: D1 _1 h我的问题是,希望产生的load达到一定数目后,就停止,直到有新的空余空间(即排队系统中waiting space有限)。) A! W2 a7 a% S0 w6 ^" r9 v' [' I
现在我对产生load 的流程(P_Creation2)和load去的下一个流程(P_In2)都做了traffic limit.但space里的load数目却大于这个traffic limit. 所以模拟结果不能确定是否合理。
  i( g0 W8 _$ p! }% H0 r; M$ e0 k% j4 \3 U' M; t  Q
不知有没有办法设置space的limit(现在我找不到这个系统自己定义的队列space)? 多谢指导。
( c, A$ L+ n! n1 D9 b7 q+ I8 V& N
7 ]3 A! S% F( z* g3 T/ _* M9 k我的程序是(以前请教过各位):
% K  n6 ]5 p5 D) b" Q( u) f
2 O  N9 D$ T4 I4 H4 J/ Z, ]begin model initialization function- z4 u* l* `& k) b
  create 1 load of load type L_null  to P_Creation2
5 ^- d+ B5 w" A- h# s7 q   return true
' Z. ~, ~, u% L; r* J9 Rend
9 @4 F5 Y- k- ]3 H" X2 C1 O0 @- |4 j
begin P_Creation2 arriving procedure
! j, {& B7 I- iwhile 1=1 do
+ v8 ^6 g8 d$ X   begin' h8 d, [0 Q3 }0 `9 e
     wait for 1 sec
* e+ Z, \! U3 U1 Q     create 1 load of load type L_C2 to oneof(2_In2,8:die)
" r$ I: W" C$ u) }: H4 G   end- p0 \+ Q3 ?  N; O3 a, w% _% t$ }
end3 ^' P+ F( u/ m& R" j/ l, g+ R
8 u1 N2 @( N6 o0 n; O
begin P_In2 arriving procedure
9 {: i" p" N3 `$ `   move into Q_F2) Z5 c6 ?7 `$ r% X1 {3 x2 z
   move into Elevator:cp25 D/ e, Z0 @- v
。。。。。

最佳答案

查看完整内容

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 mod ...
发表于 2009-6-1 05:24:36 | 显示全部楼层
A:一些概念6 G) ?' ^" x& J3 k+ G: ?: O( b
    1. Space大概是个假想的队列吧,因为模型没有哪个非运行时的文件里出现过Space的描述。; L, Z3 @" v7 x, j/ s% P, Z5 s
    2. 对P_Creation2设置traffic limit应该是无效的,因为P_Creation2里只有一个L_null,产生的. S: t/ Q. ^& R* d9 o' O- m# T
新load并不进入P_Creation2。! v# l; B+ C! J5 v" d) o
. g) \- l, B% k  W/ Q9 C( R* O! `1 A
B:解决你的问题
; y! t+ b/ a) Y: [& G( R    1. 如果你想让P_In2一直是满的,首先要设置P_In2的traffic limit,然后,代码如下:
$ C& j* Y  B8 v* n/ x# D, W-------------------------------------------------------------------------
0 h- L* w3 U7 S% x) W( g9 Ebegin model initialization function
! `2 X) X& M3 @- r& z    create 1 load of L_C2 to P_In2
& p+ J5 N: r$ |8 l* I9 P    return true
+ p- u1 F5 ?  J" cend( m+ L. x% i2 _9 h) c  ^

: R" r9 Y5 c# o- ibegin P_In2 arriving procedure
4 a7 Q- F$ x* D2 h- b4 o    clone 1 load of L_C2 to P_In2* V; _8 d" N, U$ v- N
    move into Q_F2& T) l4 A# c4 u5 S" v, P2 j  f. G
... ...- n! A3 O" T! x# G" t! m/ y. A
-------------------------------------------------------------------------
/ ^& X/ s) ~& d2 C3 W5 \5 [. ]  m        如果想让Q_F2满着,就把clone动作拿到第二句。
% N" N% o& v2 Z: h; K9 T
( V  C# O! m) o% T2 [7 b" A    2. 其实你想要的应该不是以上那种吧,而是依然以固定时间间隔投放Load,只是遇到没
& _, Z  v  x* @  @' U# I  K空间了就暂停下来。这又分两种情况(以下只看P_Creation2):
. {( E& J* b6 N- Y5 J4 Q/ f    2.1 每1秒钟检查是否有空间,有就投放(到P_In2或die);不管是否投放了,都再等下1秒钟,如此循环。2 {; n. g, K5 g  g% G* t
---------------------------------------------------------------------------
% O" L3 M/ P; Pbegin P_Creation2 arriving procedure- }; u' q4 x3 H
    while 1 = 1 do begin
( u& y1 u; z$ I9 {: l! b( |4 r  X1 q% W        wait for 1 sec: ]; b' |. ]) p7 b' f/ d8 q
        if P_In2 current = P_In2 capacity begin# s  k$ ^- s. o3 d8 H8 I# ]
            create 1 load of load type L_C2 to oneof(2_In2,8:die)
9 J$ _' P. ?/ Y* Z6 [        end
: K: o7 [' e6 x' q5 Y8 @& a    end
1 l: L% J" L, m5 N+ V+ eend
/ p7 \) h! t" N---------------------------------------------------------------------------7 k* A2 }6 c; ]7 [9 \$ a
    2.2 每1秒钟检查是否有空间,有就投放;没有的话就等到有,再投放;每次投放Load后开始计时1秒钟,如此循环。- n7 s6 u( b- E
---------------------------------------------------------------------------7 g8 _; T, F& f* ~) a" @
begin P_Creation2 arriving procedure
: _& d4 A$ X& J    while 1 = 1 do begin
4 C9 F* \2 m, B        wait for 1 sec/ A) \* L1 A2 E7 q  Q, F2 H+ B
        wait until P_In2 current = P_In2 capacity; k8 M3 s  v$ _7 q* d
        create 1 load of load type L_C2 to oneof(2_In2,8:die)
& U3 v1 A0 ^$ {% k6 |* u    end4 z) U! W7 Y5 c  s1 V
end
. T; d1 D9 y/ J8 w8 s* v& b( l  k- g---------------------------------------------------------------------------% q5 h# B( g; y" ^  h  Q+ i
    以上是以P_In2为限制。要以Q_F2为限制,直接把P_In2改成Q_F2就可以了,current和capacity属性对于Process和Queue都有效。. R6 o! L. C8 @' |
  X' _9 C0 X' p5 Z/ N3 F+ l
    3. 如果要一次产生某个数量的Load把P_In2填满,等到空了再进入,方法也蛮简单,我就不写出来了。
 楼主| 发表于 2009-6-2 02:07:16 | 显示全部楼层
非常感谢zhdew的耐心指导。, z; H* K$ V0 ^! ]. a! p  W
的确我是想,当达到capacity,不再产生load,直到有空余空间再产生。0 E( u6 c% U& y; z

6 L" F0 O. I& }5 g; h# U) J我按照这个方法做了(2.1和2.2都试了),但运行结果和我以前设traffic limit完全相同,那个Space里的load数 仍然大于所设的limit。也就是说load在下一个流程没有空余空间的情况下也在产生,等在队列space里,有空间就挤进去,这样后面这些load的到达就不是伯努利过程了。
$ b9 \' y) R! X, y
$ G8 ?- F( J; o6 K看用户手册上说,“Created loads start in the predefined queue “Space.” You specify which process they go to4 [1 k# K3 E* r" T  j. M% j: l# v1 G" V
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.
2 u, D) x' o" `2 }4 h2 @
  z3 T) S9 i5 g1 @' uFor example:* P% I' s3 A; W; x2 _
-------------------------" o" D1 v+ [" V. M. S
begin CreateMe arriving4 p+ I: h% a/ \7 z& k
create 1 load of load type Lnew to CreateMe
/ \# F2 z/ Q% h& S$ `& |send to Pnext$ t' @! J. J- r  c! a
end
# j0 o4 X% Y% h6 L) V---------------------------
& S4 I9 b2 O) k5 |$ @4 vThe 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.
8 y* }! {5 q' Y6 m0 e
& c: T$ B( J% a4 w, d# |2 K感觉一个create 好像总在产生load,停不下来?
 楼主| 发表于 2009-6-2 06:13:08 | 显示全部楼层
我发现,如果以Q_F2为限制,即程序中把P_In2改成Q_F2,得到的结果就不一样了,Space里的loads 数就不会超过limit.
发表于 2009-6-2 21:10:35 | 显示全部楼层
原帖由 Laura 于 2009-6-2 02:07 发表
0 F9 A; }5 O# K, \; N非常感谢zhdew的耐心指导。
1 a& W4 F$ t4 Y# T的确我是想,当达到capacity,不再产生load,直到有空余空间再产生。1 {. g) }- }  T9 U
/ B7 t  d2 L  P( x
我按照这个方法做了(2.1和2.2都试了),但运行结果和我以前设traffic limit完全相同,那个Space里的load数 仍然大于所设的limit ...

4 O; |7 [$ k3 U这是我的错。看这句6 {4 e. ]6 n$ l
wait until(或 if) P_In2 current = P_In2 capacity' {& Y/ ~* {# a% [
* w. U" {. m+ @' P9 T; ]8 Z
这里的“=”应该是“<”。。。
! i9 `8 f% `6 n: N马虎了马虎了。
 楼主| 发表于 2009-6-3 22:50:27 | 显示全部楼层
哈哈,zhdew,对于你这种大师来说,这些小错不足为道。我在copy的时候已经改过来了。
) A; {2 o, s% t$ {& W# ^不过真的很奇怪,用P_In2做限制,结果和以前完全相同,而用Q_F2为限制,结果似乎就合理了。9 Q/ A6 x. a5 J1 d3 C7 p
# z/ C  p" P! o4 |
anyway, 非常感谢zhdew,你真的太博学了,而且俺这个程序没有你的三次指点,根本无从谈起。如果住的近,一定得请你吃顿大餐!
发表于 2009-6-3 23:20:56 | 显示全部楼层
原帖由 Laura 于 2009-6-3 22:50 发表
3 y% z$ G: M/ r% \% P8 _哈哈,zhdew,对于你这种大师来说,这些小错不足为道。我在copy的时候已经改过来了。# S8 I1 S1 z* h& O1 A6 u
不过真的很奇怪,用P_In2做限制,结果和以前完全相同,而用Q_F2为限制,结果似乎就合理了。) e! _$ H2 \! i4 e/ M
7 G" n8 t$ y) C
anyway, 非常感谢zhdew,你真的太博学了,而且俺这个 ...

2 Z9 Y6 v# V  z' A, h# P过奖。" c2 v! a: a$ x1 B0 r3 N

1 ?% Q' Q, a) |) q# g8 T# U2 z$ i不过很奇怪。手头没有AutoMod,没法测试,你能不能看一下,当P_In2里Load数量达到traffic limit的时候,P_In2的current和capacity各是多少?为何那两句能通过?想不通了,这个。
 楼主| 发表于 2009-6-4 02:20:48 | 显示全部楼层
是这样的,我在改程序的时候,就把wait until(或 if) P_In2 current = P_In2 capacity 的中“=”改成“<”了,因为如果不改的话,一个load都不会产生。我当时想这个可能是你的笔误。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|SimulWay 道于仿真   

GMT+8, 2024-3-29 06:57 , Processed in 0.019303 second(s), 13 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表