Presentation is loading. Please wait.

Presentation is loading. Please wait.

矩阵定义命令 NAME MATRIX A,B,C,D,E,F,G NAME :矩阵名称 A :必须为空值,是为了与以前的版本兼容

Similar presentations


Presentation on theme: "矩阵定义命令 NAME MATRIX A,B,C,D,E,F,G NAME :矩阵名称 A :必须为空值,是为了与以前的版本兼容"— Presentation transcript:

1 矩阵定义命令 NAME MATRIX A,B,C,D,E,F,G NAME :矩阵名称 A :必须为空值,是为了与以前的版本兼容

2 矩阵定义命令 例子: Inventory MATRIX ,1000,5 Mclass MARTIX ,8,10,3

3 矩阵模块的相关模块: MSAVEVALUE
An MSAVEVALUE Block updates an element of a Matrix Entity. MSAVEVALUE A,B,C,D Operands A - Matrix Entity name or number, with optional + or -. Required. the operand must be Name, PosInteger, ParenthesizedExpression, SNA, or SNA*Parameter, followed by +, -, or Null. B - Row number. Required. The operand must be Name, PosInteger, ParenthesizedExpression, SNA or SNA*Parameter. C - Column number. Required. The operand must be Name, PosInteger, ParenthesizedExpression, SNA or SNA*Parameter. D - Value to be stored, added, or subtracted. Required. The operand must be Name, Number, String, ParenthesizedExpression, SNA, or SNA*Parameter.

4 矩阵模块的相关模块: MSAVEVALUE
Examples 1 MSAVEVALUE Sales+,Part23,Cust77,6.234 When a Transaction enters the MSAVEVALUE Block in this example, the element, of the Matrix Entity named Sales, with row equal to the value of Part23 and the column equal to the value of Cust77 is increased by Normally, the row and column names would have appeared earlier in EQU Statements.

5 矩阵模块的相关模块: MSAVEVALUE
Examples 2 MSAVEVALUE Parts,Part23,Description,"Zippo lighter" In this example, a string is assigned to a Matrix element. The Matrix Entity must be defined elsewhere in the Model, or interactively, by a MATRIX Command that defines the Parts Matrix Entity.

6 矩阵模块的相关模块: MSAVEVALUE
而PLUS可以操作二维以上的矩阵元素。 相关的SNA :MXEntnum(m,n) : 如: Mclass MARTIX ,8,10 ……….. SAVEVALUE MY_VAL,MX$Mclass(5,6)

7 文件操作 打开文件语句 OPEN A,B,C A:文件名称,可以是磁盘文件或内存文件。
B:文件句柄,数字,缺省值为1。为其它文件操作语句提供句柄:CLOSE READ WRITE SEEK C:打开文件出错时转向的语句标号。 例: OPEN (“YFILE.TXT“),2,Error_Block

8 文件操作 关闭文件语句 CLOSE A,B,C A:参数名称,出错时保存出错信息的参数名。 B:文件句柄,数字或名字,缺省值为1。
例: CLOSE M_P1,2,Error_Block

9 文件操作 文件定位语句 SEEK A,B A:要定位的行数。 B:文件句柄,数字或名字。 例: SEEK 20,Data_Base

10 文件操作 文件读操作 READ A,B,C A: 参数名,存放读出的文件内容的变量。 B:文件句柄名,缺省是1.
Example 例: READ Text_Parm,1,Done

11 文件操作 文件写操作 WRITE A,B,C,D A:变量名或值,存放写进文件内容的变量或值。 B:文件句柄名,缺省是1.
D: ON 或者 OFF,取ON时为插入模式,取OFF时为替代 模式,缺省时为ON 例: WRITE "new Line 20",1,Done

12 Transaction Group Entities 事务组实体
A Transaction Group is a set of Transactions. There is no limit to the number of Transaction groups you may have, and no limit to the number of groups to which a single Transaction may belong. Transaction Groups are useful for classifying and accessing Transactions. The active Transaction can test the Transaction Parameters of the members of any Transaction Group.

13 JOIN A JOIN Block adds the Active Transaction to a Transaction Group, or adds a number to a Numeric Group. JOIN A,B Operands A-事务组名。 必须的,表示将动态实体所要加入的组。 它必须是变量名、正整数、括号表达式、 SNA或SNA*Parameter。 B-数值,可选,如果有,则A表示为数字组。这导致将数值B加入到数字组A中,它不影响当前的动态实体。作为可选项,它必须是变量名、正整数、括号表达式、 SNA或SNA*Parameter。

14 REMOVE 将一个动态实体从一个事务组中移出。语法如下: REMOVE O A,B,C,D,E,F 相关参数解释如下: O:条件操作符。可选项,针对D和E而言。可是Null, E, G, GE, L, LE, MAX, MIN或NE。 A:事务组号或组名,针对移出操作所针对的事务组。必须是名字、正数、括号表达式、SNA、或SNA*Parameter。 B:移出限制。能被移出的动态实体的最大数量。作为可选项,只能是ALL,、Null,、变量、正整数、括号表达式、SNA或SNA*Parameter。 C:数值,针对数字组。 该数值表示从数字组中所移出的数。作为可选项,它必须是Null、变量名、数字、字符串、括号表达式、 SNA或SNA*Parameter。 D:测试值。PR 或 参数。这个成员的属性或者优先级(PR)的检验将导致动态实体被从事务组中移出。作为可选项,它必须是PR 、Null、变量名字,、正整数、括号表达式、SNA 或 SNA*Parameter. E:D的比较参照值。 作为可选项,它必须是Null、变量名、数字、字符串、括号表达式、 SNA或SNA*Parameter。 F:某种情况下动态实体转向的块语句标号。

15 REMOVE 例子一 REMOVE GX_200301 在这个例子中,经过这个语句块的动态实体将会被从事务组GX_200301中无条件地移出。

16 REMOVE 例子二 REMOVE G gx_3,10,,p_x,11.6,Jump_Block
在这个例子中,事务组3中的动态实体将进行检测,如果这些动态实体的参数p_x的值大于11.6 ,进入这个语句块的实体中的最先10个动态实体将被从事务组gx_3中移出来。如果这10个实体的测试不满足条件,则被转向向到Jump_Block语句,否则,它将顺序进入到下一个语句。

17 REMOVE 例子三 REMOVE E my_g1,10,,p_3,10.8,Jump_Lab
在这个例子中,事务组my_g1中的动态实体将进行检测,如果这些动态实体的参数p_3的值等于10.8 ,进入这个语句块的实体中的最先10个动态实体将被从事务组my_g1中移出来。如果这10个实体的测试不满足条件,则被转向向到Jump_Lab语句,否则,它将进入到下一个语句。

18 EXAMINE An EXAMINE Block may be used to test for membership in a Numeric Group or a Transaction Group. 语法: EXAMINE A,B,C Operands A -组名 B - 数字组时才用,可选项; C - 如果不满足组项要求,则转向C EXAMINE GX2005 , , L_GX2006 EXAMINE ValidColors, P$Color, NotCorrectColor

19 SCAN A SCAN Block passes information from a Transaction Group member to the Active Transaction. 语法: SCAN O A,B,C,D,E,F 操作数 O - 条件操作符. 对事务组A中成员的B和C进行比较。 作为可选项,它必须是:Null, E, G, GE, L, LE, MAX, MIN, 或NE. A - 事务组名字。 B - 测试值,可以是 PR或 参数。以决定事务组中的 事务成员谁将被选择。作为可选项,它必须是:PR 或 Null, Name, 正整数,括号表达式, SNA, 或 SNA*Parameter. C - 针对B的参照值,缺省是0。作为可选项,它必须是 Null, Name, Number, String, 括号表达式, SNA, 或 SNA*Parameter. D - Retrieved value. PR or Parameter number. The member attribute which is to be assigned to a Parameter of the Active Transaction. It is evaluated with respect to the Transaction Group member. 作为必选项,它必须是PR, Name,正整数,括号表达式, SNA, or SNA*Parameter. E - Receiving Parameter number. The Parameter number of the entering Transaction which will receive the value retrieved from Operand D. Required.作为可选项,它必须是Name,正整数,括号表达式, SNA,或 SNA*Parameter. F - 转向语句标号. 作为可选项,它必须是Null, Name, 正整数,括号表达式, SNA,或 SNA*Parameter.

20 ALTER ALTER O A,B,C,D,E,F,G 对事务组中的事务活动实体的优先级和参数进行有选择的更改的模块。 语法: 操作数
O - 条件操作符. 对E和F进行比较。 作为可选项,它必须是:Null, E, G, GE, L, LE, MAX, MIN, 或NE. A - 事务组名字。 B - 被更改的最大事务活动实体的限制数.缺省是ALL(全部)。作为可选项,操作数必须是Null, 变量名, 正整数, 括号表达式,SNA 或 SNA*Parameter。 C - 被更改的属性. 可以是参数名字或事务活动实体的优先级PR. 该项必须是PR、变量名、正整数、括号表达式、SNA或SNA*Parameter。 D - C项所对应的替代值。 不能省略,该项必须是变量名、数字、字符串、括号表达式、SNA或SNA*Parameter。 E - 被测试项。 PR或参数。针对事务组成员。作为可选项,必须是PR、Null、 变量名、正整数、括号表达式、 SNA或SNA*Parameter。 F - E所对应的测试比较值。作为可选项,必须是Null、变量名、数字、字符串、括号表达式、 SNA或SNA*Parameter。 G - 转向语句标号. 作为可选项,它必须是Null, Name, 正整数,括号表达式, SNA,或 SNA*Parameter.

21 ALTER实例 例1: ALTER Inventory,ALL,Price,49.95
在这个简单的例子中, Inventory事务组中的所有事务活动实体的名为Price 的值将被更改为49.95。 例2: ALTER NE Bin7,10,Price,49.95,PartNum,99.95,Out 在这个较为复杂的例子中, 当一个事务活动实体进入该ALTER模块后,名为Bin7的事务组将被扫描以确定其事务活动实体的名为PartNum参数不等于99.5。 首先满足条件的10个事务活动实体的Price参数将被设置为49.95。如果 10个事务活动实体不能被发现, 正进入该模块的事务活动实体将进入名为Out的语句模块。如果测试成功,该事务活动实体将顺序进入下一个模块。

22 Transaction Group Entities 事务组实体的相关块
There are several GPSS Blocks which can be used with Transaction Groups: · JOIN Blocks place the entering Transaction into a Transaction Group. · REMOVE Blocks take some group members out of a Transaction Group. · EXAMINE Blocks test members of a Transaction Group. · SCAN Blocks test and/or modify members of a Transaction Group. · ALTER Blocks test and/or modify members of a Transaction Group.

23 注意:只在条件操作模式时,D和E才需要;(红色部分) C的地址变量值必须比B的地址变量值大; 地值变量的值必须小于32768。
COUNT 计数操作模块 将实体计数存放在当前活动实体的一个参数之中。 语法: COUNT O A,B,C,D,E O : 条件操作或逻辑操作符。 必须是 FNV, FV, I, LS, LR, NI, NU, SE, SF, SNE, SNF, SNV, SV, U, E, G, GE, L, LE, MIN, MAX, 或 NE之一。 A :接收计数结果的经过COUNT模块的动态实体的参数。 B :检测实体的下限名字。被O操作符检测的第一个(存储器、装置或逻辑等)实体 。 C : 检测实体的上限名字。被O操作符检测的第一个(存储器、装置或逻辑等)实体 。 D :E操作符的参考值。只有在条件操作模式时才需要。 E: 系统数字属性类名SNA 。为条件模式测试时指定实体属性 。只在条件模式时需要。 注意:只在条件操作模式时,D和E才需要;(红色部分) C的地址变量值必须比B的地址变量值大; 地值变量的值必须小于32768。

24 COUNT 计数操作模块 FNV The Facility must be unavailable in order to be counted. FV The Facility must be available in order to be counted. I The Facility must be currently interrupted (preempted) in order to be counted. LS The Logicswitch Entity must be set (in the state) in order to be counted. LR The Logicswitch Entity must be reset (in the state) in order to be counted. NI The Facility must NOT be currently interrupted (preempted) in order to be counted. NU The Facility must not be in use in order to be counted. SE The Storage must be empty in order to be counted. SF The Storage must be full in order to be counted. SNE The Storage must NOT be empty in order to be counted. SNF The Storage must NOT be full in order to be counted. SNV The Storage must NOT be available in order to be counted. SV The Storage must be available in order to be counted. U The Facility must be in use in order to be counted.

25 COUNT 计数操作模块 Examples 1 Bin1 EQU 101 Bin2 EQU 102 Bin3 EQU 103
Bin1 STORAGE 11 Bin2 STORAGE 510 Bin3 STORAGE 151 Generate ,,, ;只产生一个动态实体 Enter Bin1, ;占满存储器Bin1 TERMINATE GENERATE ,,, ;只产生一个动态实体 Enter Bin2, ;占用存储器Bin2 500容量 Generate ,,, ;只产生一个动态实体 Enter Bin3, ;占用存储器Bin3 150容量 Generate 3, ;产生动态实体 COUNT SNF My_1,Bin1,Bin3 ;判断没有装满的存储器的个数 SAVEVALUE MCOUNT,P$My_1 TERMINATE 1

26 COUNT 计数操作模块 Examples 2 COUNT SF FullCount,Warehouse1,Warehouse13 在这个例子中,该模块将对存储器 Warehouse1、Warehouse2,Warehouse3、Warehouse4、……、Warehouse12、Warehouse13进行检测,将存储器已满的存储器个数保存在经过该模块的动态实体的FullCount 参数中。 注意:存储器的标号应当是连续存放的,这可用EQU命令对Warehouse1、……、Warehouse13进行连续命名。

27 COUNT 计数操作模块 Examples 3 COUNT E EmptyCount,FirstQueue,LastQueue,0,Q
在本例中,COUNT模块处于条件操作模式。操作符E指定了系统数字属性(SNA)类是Q, 即指定了队列( Queue)实体。 队列的范围是从FirstQueue到LastQueue,这些队列中队列长度为0的队列数将存放在当前的动态时体的EmptyCount参数中。 一般来说,队列名FirstQueue,……,LastQueue应当是连续定义的。

28 COUNT 计数操作模块 Examples 3 COUNT E S_E_2, Store_1, Store_8, 2, S
在本例中,COUNT模块处于条件操作模式。操作符E指定了系统数字属性(SNA)类是S, 即指定了存储器(Storage)实体。 存储器的范围是从Store_1到Store_8,这些存储器容量为2的存储器数将存放在当前的动态时体的S_E_2参数中。 一般来说,队列名Store_1,……,Store_8应当是连续定义的。

29 SELECT 选取操作模块 SELECT模块选择符合条件的实体名称(地址号)保存在经过该模块的动态实体的参数A之中。
SELECT O A,B,C,D,E,F O :条件操作或逻辑操作符。 这些操作符应是:FNV, FV, I, LS, LR, NI, NU, SE, SF, SNE, SNF, SNV, SV, U, E, G, GE, L, LE, MIN, MAX, 或 NE。 A:存放选取结果的参数名。在该参数中存放装置或容器名  B: 被选实体的名字下限值。 C :被选实体的名字上限值。 D :条件操作模式时E操作符的参考值。但在E为MAX或MIN时不用。 E :系统数字属字(SNA)名. 为条件模式测试时指定实体属性 。只在条件模式时需要。. F : 当不满足选择条件时动态实体跳转去的语句标号。

30 SELECT Examples 1 SELECT SNF Not_Full,Bin1,Bin3 在这个例子中,SELECT模块依序检测存储器Bin1、Bin2和Bin3,当有一个存储器满足SNF(存储器不满)的条件时,将存储器的名字(号码)保存在当前活动实体的Not_Full参数之中。如果参数还没有,则创建该参数。如果所有的存储器都不满足该条件,则在Not_Full参数之中保存0值。 注意:如果Not_Full参数中保存的值为0时,不能用 Enter P$Not_Full 这会导致一个错误发生。

31 SELECT Examples 2 Bin1 EQU 101 Bin2 EQU 102 Bin3 EQU 103
Bin1 STORAGE 11 Bin2 STORAGE 1000 Bin3 STORAGE 150 Generate ,,, ;只产生一个动态实体 Enter Bin1, ;占满存储器Bin1 TERMINATE GENERATE ,,, ;只产生一个动态实体 Enter Bin2, ;占用Bin2存储器 500容量 Generate ,,, ;只产生一个动态实体 Enter Bin3, ;占满存储器Bin3 Generate 3, ;产生动态实体 SELECT SNF My_1,Bin1,Bin3,,,No_Room ENTER P$My_1,1 TERMINATE 1 No_Room ADVANCE 10,4 在这个例子中,由于Bin2满足SNF(存储器不满)的条件,则当前动态实体的My_1参数值为Bin2(102)。(Bin2是第一个满足该条件的存储器。

32 SELECT Examples 3 Bin1 EQU 101 Bin2 EQU 102 Bin3 EQU 103
Bin1 STORAGE 11 Bin2 STORAGE 500 Bin3 STORAGE 150 Generate ,,, ;只产生一个动态实体 Enter Bin1, ;占满存储器Bin1 TERMINATE GENERATE ,,, ;只产生一个动态实体 Enter Bin2, ;占满存储器Bin2 Generate ,,, ;只产生一个动态实体 Enter Bin3, ;占满存储器Bin3 Generate 3, ;产生动态实体 SELECT SNF My_1,Bin1,Bin3,,,No_Room TERMINATE 1 No_Room ADVANCE 10,4 在这个例子中,由于Bin1,Bin2,Bin3都不满足SNF(存储器不满)的条件,则当前动态实体的My_1参数值为0,同时跳转到No_Room语句。

33 SELECT Examples 4 Bin1 EQU 101 Bin2 EQU 102 Bin3 EQU 103
Bin1 STORAGE 11 Bin2 STORAGE 510 Bin3 STORAGE 150 Generate ,,, ;只产生一个动态实体 Enter Bin1, ;占满存储器Bin1 TERMINATE GENERATE ,,, ;只产生一个动态实体 Enter Bin2, ;占用Bin2存储器500容量 Generate ,,, ;只产生一个动态实体 Enter Bin3, ;占满存储器Bin3 Generate 3, ;产生动态实体 SELECT SNF My_1,Bin1,Bin3,,,No_Room Enter P$My_1,1 TERMINATE 1 No_Room ADVANCE 10,4 在这个例子中,由于Bin2满足SNF(存储器不满)的条件,则当前动态实体的My_1参数值为Bin2(102)。Enter P$My_1,1将会给Bin2增加一个容量。

34 SELECT Examples 5 Bin1 EQU 101 Bin2 EQU 102 Bin3 EQU 103
Bin1 STORAGE 110 Bin2 STORAGE 120 Bin3 STORAGE 130 Generate ,,, ;只产生一个动态实体 Enter Bin1, ;占用Bin1存储器100容量 TERMINATE GENERATE ,,, ;只产生一个动态实体 Enter Bin2, ;占用Bin2存储器100容量 Generate ,,, ;只产生一个动态实体 Enter Bin3, ;占用Bin3存储器100容量 Generate 3, ;产生动态实体 SELECT SNF My_1,Bin1,Bin3,,,No_Room Enter P$My_1,1 ADVANCE 5,2 TERMINATE 1 No_Room ADVANCE 10,4 在这个例子中,由于3个存储器满足满足SNF(存储器不满)的条件,则当前动态实体的My_1参数值为Bin1(101)。Enter P$My_1,1将会给Bin1增加一个容量。但随后会必生相应变化。

35 SELECT Examples 6 SELECT E Empty1,Queue1,Queue9,0,Q
在这个例子中,SELECT 模块处于条件操作模式。队列实体从Queue1到Queue9将被检测,第一个队列长度为0的队列名字将存储在当经过当前SELECT模块的动态实体的 名为EMPTY1参数之中。如果不不存在,则将数值0存放在 。

36 DISPLACE模块 DISPLACE 模块 移动任意的动态实体。 语法: DISPLACE A,B,C,D A:动态实体号码。可以是名字或数值。 B:动态实体被移动的目的地。 C:参数号。被移动的动态实体的用于保存剩余时间的参数,如果当时该实体正在处于某个延时状态。 D:(可选的)当前活动实体转向的目的地址(语句标号)。

37 DISPLACE模块 例 如下图:有十台警车,分别相隔10钟从Point_1点出发,顺时针沿外围道路等速巡逻从一个点到下一个点需要10±1钟,图中红色十字路口为治安案件高发点,60±35分钟发生一起凶案,发案时,中心将通知刚过黄色出警点的的警车沿红色虚线到达案发地点。处理案件案件需要量20±15钟。处理完毕之后沿紫色虚线回到外围道路继续巡逻。模拟该过程24小时 出警点 热点治安区域有案件 警车出警路线 Point_8 Point_1 顺时针 Point_11 Point_18

38 DISPLACE模块 Example 2 ` 顺时针
如下图:有十台警车,分别相隔10钟从Point_1点出发,顺时针沿外围道路等速巡逻从一个点到下一个点需要10±1钟,图中红色十字路口为治安案件高发点,60±35分钟发生一起凶案,发案时,中心将通知刚过黄色出警点的的警车沿红色虚线到达案发地点。处理案件案件需要量20±15钟。处理完毕之后沿紫色虚线回到外围道路继续巡逻。模拟该过程24小时 出警点 治安区域有案件 治安区域有案件 警车出警路线 Point_8 Point_1 ` 6> >12 5> >13 4> >14 3> >15 2> >16 1> >17 顺时针 Point_11 Point_18

39 DISPLACE模块 Example 2 DISPLACE X$Culprit,Compensate,Residual,NotCaught 在这个例子中,DISPLACE 模块先从当前的保存值Culprit中确定要被移动的动态实体的号码X$Cuplprit,如果该动态实体存在,它将被送到标号名为Compensate的语句处。 假若该动态实体还停留在将来事件链(FEC)中, 其在FEC中的剩余时间将存储在被移动的实体的名为Residual参数中,如果参数不存在,将被创建。如果目标动态实体不存在,当前动态实体将移动到名为NotCaught的语句处。

40 Continuous Simulation 连续仿真
GPSS World can automatically integrate systems of ordinary differential equations. Integration of User Variables in GPSS World is extremely easy. One or more INTEGRATE statements, and variable initialization, is all that is needed. Integration is done automatically by a modified variable step 5th order Runge-Kutta-Fehlberg method, RKF4(5). Systems of ordinary differential equations, of any order, can be simulated. Plot and Epressions Windows are available for online viewing of the states of variables.

41 How to Set up an Integration 如何设置一个积分
There are two things to do in order to set up the automatic integration of a User Variable. You must assert an INTEGRATE Command and you must give the variable an initial value. Let us assume you have a simple ordinary differential equation of the form y’ = f(表达式) where f(表达式) is an Expression, possibly involving the System Time, i.e. the AC1 System Numeric Attribute, and other User Variables. f(表达式) is the derivative of y with respect to time. First, put the derivative in parentheses and set up the INTEGRATE Command as Y_ INTEGRATE ( f(表达式) ) Second, make sure Y_ has a starting value, such as Y_ EQU 100.3

42 How to Set up an Integration 如何设置一个积分
Then, when the simulation advances the clock, it automatically sees to it that the value of the User Variable Y is kept current. Since several single letter names clash with SNA classes, here we append an underscore to be sure that the name is unique. All other User Variables involved in the derivative, must be initialized, as well. PLUS Assignment Statements can also be used to assign values to User Variables. Integrations are automatically begun in the active, or "enabled" state. However, you can turn an integration ON or OFF while a simulation is running by using one or more INTEGRATION Blocks. This is discussed in Chapter 7.

43 Thresholds: Integrated的阀值
Integrated User Variables create Transactions when they cross thresholds. This makes it easy to use a continuously modeled value to trigger discrete events. Each INTEGRATE Command may have zero, one, or two numeric thresholds. Operands B and C can be used to specify threshold 1, and/or operands D and E can be used to specify threshold 2. In either case, the first operand of the pair determines the value of the threshold, the second indicates the Block which will receive generated Transactions. During the integration, if the value of the integrated variable crosses the value of a threshold, from either direction, a new Transaction is created. It is given a priority of 0, and is scheduled to enter the Block associated with that threshold in the INTEGRATE Command. The Transaction’s time of entry into the model is estimated by a linear interpolation.

44 Thresholds: Integrated的阀值
To improve accuracy, the integration ministep is decreased when a threshold is imminent. Thresholds may be constants, parenthesized Expressions, or even Procedure Calls. In addition, the Transactions generated by a threshold crossing may be used to move the threshold. Both thresholds behave identically; there is no need to specify one as upper and the other as lower. It is the crossing of the threshold (in either direction) that triggers a Transaction arrival. If the direction of crossing is meaningful to your model, you will have to either keep track of the state of the integrated variable, or test for the direction of crossing when the Threshold Event occurs.

45 Higher Order Equations 高次微分方程的处理
You must reduce the order of higher order ordinary differential equations. If you have higher order differential equations, before you enter them into GPSS World, you should rewrite them as a system of first order equations. This is relatively easy, and requires that you introduce a new variable for each of the intermediate derivatives. For example, if you have 25 y’’’ - 6 y’ + y = 0 Let u = y ’ v = u ‘ = y’’

46 Higher Order Equations 高次微分方程的处理
For even higher orders, we would continue to introduce variables. Then, substituting into the original equation and using only one first order derivative, we have 25 v’ - 6 u + y = 0.  Now we have the following system of equations: y’ = u u’ = v v’ = 6/25 u - 1/25 y    In GPSS World, you could use the following Statements Y_ INTEGRATE U_ U_ INTEGRATE V_ V_ INTEGRATE ( (6/25) # U_ - (1/25) # Y_) To these, you must add EQU Statements that initialize U_, V_, and Y_.

47 Continuous Only 纯连续型 If you want to do a purely continuous simulation, you still need to create a termination condition by entry into a TERMINATE Block. Therefore, include a GPSS segment such as GENERATE End_Time ;End_time为结束时间数值 TERMINATE 1 In the model, which is begun by a START 1

48 Phases 运行状态 Simulations run in alternate continuous and discrete phases. At any instant where events are scheduled, the simulation runs in a discrete phase. The clock does not advance within an instant in a discrete phase. Between instants, the simulation runs in a continuous phase, during which the integrations proceed in small time increments called mini steps. Plotted integration variables report intermediate values at the end of mini steps. When a threshold crossing generates a Transaction, the simulation goes into a discrete phase.

49 Phases 阶段 In this manner, the continuous and the discrete phases can be closely interrelated. Conversely, User Variables can be assigned new values in a discrete phase even if they are being integrated. You can do so using an EQU Command, or a PLUS Assignment Statement. If you want such assignments to occur within the running of the simulation, you must define a PLUS Procedure that makes the assignment. For example, if you defined a PLUS Procedure as PROCEDURE SetPop(Pop_Level)Foxes = Pop_Level ; you could reinitialize the FOXES User Variable by entering a PLUS Block, such as PLUS (SetPop(200)) or by using a parenthesized Expression that invokes SetPop( ) in some other kind of Block.

50 INTEGRATE 的语法 NAME INTEGRATE A,B,C,D,E
An INTEGRATE Command sets up the integration and thresholds of a continuous variable. NAME INTEGRATE A,B,C,D,E Operands NAME - User Variable. Required. The field must be Name. A - Derivative. Required. The operand must be Name, Number, String, ParenthesizedExpression, or SNA. B - Threshold 1. Optional. The operand must be Null, Name, Number, String, ParenthesizedExpression, or SNA. C - Arrival Block 1. Optional. The operand must be Null, Name, PosInteger, ParenthesizedExpression, or SNA. D - Threshold 2. Optional. The operand must be Null, Name, Number, String, ParenthesizedExpression, or SNA. E - Arrival Block 2. Optional. The operand must be Null, Name, PosInteger, ParenthesizedExpression, or SNA.

51 INTEGRATE 的语法 Examples 1
Rabbits INTEGRATE (a_ # Rabbits) - ( b_ # Rabbits # Foxes) Foxes INTEGRATE ( - c_ # Foxes) + ( d_ # Rabbits # Foxes) Rabbits EQU 10000 Foxes EQU 1500 a_ EQU 0.9 b_ EQU 0.4 c_ EQU 0.2 d_ EQU 0.1 This example defines a "Predator-Prey" model relating a rabbit population to a fox population. The Expressions in the INTEGRATE Commands are used as the derivatives with respect to time. The values of the constants in the Expressions, and the initial values of the populations are set by the EQU Commands. When the simulation runs, the integrations are performed automatically when the clock advances.

52 INTEGRATE 的语法 Examples 2 X_ INTEGRATE (Y_),0.707,Wake_Up
Y_ INTEGRATE (-X_) X_ EQU 1.0 Y_ EQU 0.0 This example defines a coupled system of ordinary differential equations (ODEs) whose solution is X_=cos(Y_VAR) and Y_=-sin(X_VAR). The expressiions in the INTEGRATE Commands are used as the derivatives with respect to time. The initial values of the continuous variables are set by the EQU Commands. When the simulation runs, the integrations are performed automatically between discrete time instants. A threshold is used for the User Variable X_. When this variable crosses the value 0.707, from either direction, a new Transaction is created and scheduled for the Block labeled WAKE_UP. X is an SNA Class, and therefore cannot be used as a Named Value. Here we use X_. It’s always safe to create names if they include an underscore character.

53 INTEGRATE 的 Action The INTEGRATE Command is a Queued Command. When the Simulation Object receives one, it places it at the end of the simulation’s Command Queue. When an INTEGRATE Command is performed, the data structures are set up so that a User Variable will be integrated automatically when the system clock advances. Integrations are done using a modified fifth order Runge Kutta Fehlberg method (RK4(5)), with a variable step size. All User Variables involved in an integration must be given initial values before the simulation runs. You can do this with EQU Commands or by Assignment Statements in PLUS Procedures.

54 INTEGRATE 的 Action Operand A of the INTEGRATE Command is used for the derivative of the User Variable with respect to time. It can be very simple or quite complex. In the latter case you may want to define a PLUS Procedure and place a Procedure Call in the parenthesized Expression used for Operand A. Each INTEGRATE Command may have zero, one, or two numeric thresholds. Operands B and C can be used to specify threshold 1, and/or operands D and E can be used to specify threshold 2. In either case, the first operand of the pair determines the value of the threshold, the second indicates the Block which will receive generated Transactions.

55 INTEGRATE 的 Action During the integration, if the value of the integrated variable crosses the value of a threshold, from either direction, a new Transaction is created. It is given a priority of 0, and is scheduled to enter the Block associated with that threshold in the INTEGRATE Command. The Transaction’s time of entry into the model is estimated by a linear interpolation. To improve accuracy, the integration ministep is decreased when a threshold is imminent. Thresholds may be constants, parenthesized Expressions, or even Procedure Calls. In addition, the Transactions generated by a threshold crossing may be used to move the threshold. Integrations are automatically begun in the active, or "enabled" state. However, you can turn an integration on or off while a simulation is running by using one or more INTEGRATION Blocks.

56 INTEGRATE 的 Phases Simulations run in alternate continuous and discrete phases. At any instant where events are scheduled, the simulation runs in a discrete phase. The clock does not advance within an instant in a discrete phase. Between instants, the simulation runs in a continuous phase, during which the integrations proceed in small time increments called ministeps. Plotted integration variables report intermediate values at the end of ministeps. When a threshold crossing generates a Transaction, the simulation goes into a discrete phase. In this manner, the continuous and the discrete phases can be closely interrelated. Conversely, User Variables can be assigned new values in a discrete phase even if they are being integrated. You can do so using an EQU Command, or a PLUS Assignment Statement.

57 INTEGRATE 的 Phases If you want such assignments to occur within the running of the simulation, you must define a PLUS Procedure that makes the assignment. For example, if you defined a PLUS Procedure as          PROCEDURE SetPop(PopLevel) BEGIN                 Foxes = PopLevel ;         END ; you could reinitialize the Foxes User Variable by entering a PLUS Block, such as         PLUS (SetPop(200)) or by using a parenthesized Expression that invokes SetPop() in some other kind of Block.

58 PLUS直接赋值模块 格式: PLUS A, B A: 带括弧的PLUS表达式,
B:保存结果的参数名字,如果PLUS没有返回值,B可以省略。 例 : GENERATE 1 ASSIGN X_1,(RN1) ASSIGN X_2,0 PLUS (SIN(P$X_1)+COS(P$X_1)),X_2 LINK USK_1,FIFO,L_1 L_1 ADVANCE 10 UNLINK USK_1,L_1,1 TERMINATE 1

59 PLUS定义过程的代码编写注意事项 一、PLUS过程名称的选取,不要与系统的标准函数名相同,否则会出现意料不到的结果;
四、在PLUS过程中访问矩阵,与模型词句的MSAVEVALE不同,直接用矩阵名、方括号及座标进行访问,参见实例 中的S_MAT过程的定义。 五、在PLUS的可以使用语句标号,但在标号后要跟一个“:”,可以用GOTO语句直接跳转到某个标号处。 六、在PLUS过程中可以直接访问模型中的系统数字属性,系统数字属性在所有的PLUS过程中的值是相同的。 七、如果矩阵的维数超过2维以上,要实现对矩阵单元的访问和修改,只能通过PLUS进行。但矩阵的定义仍然在模型的前面用MATRIX命令进行定义,在PLUS中不能独立定义矩阵。矩阵的维数最大可达到6维。

60 第九章 对模拟结果的后续分析 GPSSWorld对模拟除了提供一系列基本的模拟统计报告外,还提供了非常高效的统计分析工具,并且可以利用前面章节介绍的模块和另外几条简单的命令,就可以实现对模拟结果的方差分析和F检验,以帮助用户确定模拟结果的可靠性及风险评估。

61 第九章 对模拟结果的后续分析 RMULT 命令 命令模式: RMULT A,B,C,D,E,F,G INCLUDE命令
第九章 对模拟结果的后续分析 RMULT 命令 命令模式: RMULT A,B,C,D,E,F,G INCLUDE命令 命令模式:INCLUDE "文件名“ CLEAR命令 命令模式:CLEAR A

62 第九章 对模拟结果的后续分析 CLEAR命令 命令模式:CLEAR A 操作数A有两个选项:ON或OFF,如果A省略,等价于ON。
第九章 对模拟结果的后续分析 CLEAR命令 命令模式:CLEAR A 操作数A有两个选项:ON或OFF,如果A省略,等价于ON。 如果执行了CLEAR 或CLEAE ON,将发生以下项目的作用: 1、模拟所产生的所有事务活动实体将被清除掉;. 2、当前计数被置为 0; 3、系统时钟被置为0; 4、模型中的所有装置被置为空闲并为可用; 5、各种统计表被置为0; 6、存储器被置为完全可用状态; 7、装置的时空点积 、存储器、队列和用户链等被置为0; 8、总的计数器被置为0;. 9、队列实体、用户链实体和存储器实体的最小和最大值被设置成这些实体的当前容量、随机数发生器没有被复位; 10、GENERATE模块所生成的事务事务活动实体被置为0; 11、所有的数字组中的成员将被清空; 12、保存值实体被置为0; 13、逻辑开关实体被设为0(RESET)状态; 14、矩阵元素被置为0。

63 第九章 对模拟结果的后续分析 CLEAR命令 命令模式:CLEAR A
第九章 对模拟结果的后续分析 CLEAR命令 命令模式:CLEAR A 如果执行CLEAR OFF 命令,以上1到11项全部将生效,而最后三项不发生作用,也就是说,保存值实体、逻辑开关实体和矩阵实体将不会改变而保存最后一次模拟时的状态值。 1、模拟所产生的所有事务活动实体将被清除掉;. 2、当前计数被置为 0; 3、系统时钟被置为0; 4、模型中的所有装置被置为空闲并为可用; 5、各种统计表被置为0; 6、存储器被置为完全可用状态; 7、装置的时空点积 、存储器、队列和用户链等被置为0; 8、总的计数器被置为0;. 9、队列实体、用户链实体和存储器实体的最小和最大值被设置成这些实体的当前容量、随机数发生器没有被复位; 10、GENERATE模块所生成的事务事务活动实体被置为0; 11、所有的数字组中的成员将被清空; 12、保存值实体值不变; 13、逻辑开关实体状态不变; 14、矩阵元素值不变。

64 第九章 对模拟结果的后续分析 START命令。 命令模式:START A,B,C,D 四个操作数的用法如下:
第九章 对模拟结果的后续分析 START命令。 命令模式:START A,B,C,D 四个操作数的用法如下: A:终结数量,此操作数据一般是正整数。 B:报告输出选项,如果缺省,将模拟结果输出到报告窗口之中,如果选项为NP,则不将模拟结果报告输入到窗口。 C:在GPSSWorld之中不再使用,保留这个操作数的目的是为了与GPSS老版本保持兼容。 D:链输出标志,1表明在模拟结果标准报表中将包括CEC(当前事件链)和FEC(将来事件链)的信息。可以省略。这个操作数必须为正整数。

65 第九章 对模拟结果的后续分析 ANOVA函数(过程)。 调用模式:ANOVA(A,B,C) 三个操作数的用法如下:
第九章 对模拟结果的后续分析 ANOVA函数(过程)。 调用模式:ANOVA(A,B,C) 三个操作数的用法如下: A:存放实验数据的矩阵名字 B:矩阵中用于表示重复实验结果数据所在的维数 C:交互限制,用于分析的交互因子限制数,这个操作数可以取1、2或3。它通常用来保留用于标准离差估计的自由度。

66 一个单因素的ANOVA实验的实例过程 GENERATE 5,1.7 ;顾客到达. QUEUE Q_Line ;顾客进入队列
以下代码为参与方式分析实验的模型: 模型文件名称:BARBER.GPS 时间单位:分钟 内容:对一个理发店的模拟 GENERATE 5, ;顾客到达. QUEUE Q_Line ;顾客进入队列 SEIZE Barber ;顾客获得理发师. DEPART Q_Line ;离开队列 ADVANCE Cut_Time ;顾客由理发师理发,所需时间为Cut_Time. RELEASE Barber ;理发完毕,释放理发师 TEST G TG1,1,Doout ;测试TG1是否大于1,只由最后一个顾客将数据写入方差数据文件 TERMINATE ;顾客离开理发店 Doout OPEN ("BARBER.RST"),,Prob ;打开方差数据文件,如失败转向Prob SEEK ;定位到文件未尾 WRITE (Polycatenate(QT$Q_Line," ",Treatment," ")),,Prob,On ;将平均排队等候时间写入文件 CLOSE Errorcode,,Prob ;关闭文件,如失败转向Prob TERMINATE 1 Prob TERMINATE ;失败时离开系统

67 一个单因素的ANOVA实验的实例过程 以下内容为实验文件, 文件名为BarberTest.txt
RESULTS MATRIX ,2,3 ; 定义一个二行三列的矩阵RESULTS Cut_Time EQU 6.8 ;将理发时间参数设定为6.8分钟 Treatment EQU ;将Treatment定为1,表示第一组实验(共三次模拟) RMULT ;第一组第一次模拟 设定随机数种子数 Start 100,NP ;模拟100个顾客 MSAVEVALUE RESULTS,1,1,QT$Q_Line ;将平均排队等候时间写入矩阵元素 Clear Off ;清除本次模拟结果,为下一次模拟作准备 RMULT ;第一组第二次模拟 设定随机数种子数 Start 100,NP MSAVEVALUE RESULTS,1,2,QT$Q_Line Clear Off RMULT ; 第一组第三次模拟 设定随机数种子数 MSAVEVALUE RESULTS,1,3,QT$Q_Line Cut_Time EQU ;将理发时间参数设定为5分钟 Treatment EQU 2 ;将Treatment定为2,表示第一组实验(共三次模拟) RMULT ;第二组第一次模拟 设定随机数种子数 MSAVEVALUE RESULTS,2,1,QT$Q_Line RMULT ;第二组第二次模拟 设定随机数种子数 MSAVEVALUE RESULTS,2,2,QT$Q_Line RMULT ;第二组第三次模拟 设定随机数种子数 MSAVEVALUE RESULTS,2,3,QT$Q_Line

68 一个双因素的ANOVA实验的实例过程 我们用实验来说明有两个实验变量水平的实验。 例 有某4S汽车店,代理某品牌的单型号小汽车,该车进货单价为28万元。该车零售指导价为33万元。该4S店用于进货的流动资金主要靠银行贷款,贷款月利率为%1按月计息。4S店租有门面和仓库,仓库最多能停车10辆。4S店每月租金和人工工资等等固定费用为35万元。 根据统计,每天到达4S店的顾客平均每隔45分钟到达一人,方差为3分钟。 如果4S店有现车,到店顾客的成交率3%,如果无现车,成交率为1%。4S店向汽车制造商每次订货需要按一个火车车皮支付运费和保险费0.5万元,并且每台汽车的运输单价为0.1万元。交货时间为6到10天。 该4S店刚开张时没有存货,请通过模拟确定每次订货的数量和确定安全库存线来进行自动订货,目标是在未来3年的时间里平均每月的纯利最大。每月按30天计算,每天按8小时算。节假日无休。 简单分析: 设每次订货的数量:order_q,最小为1,最大10,如果超过10台,仓库装不下; 所谓安全库存线,是指当可供销售的汽车数量(包括现车和已经在途的汽车)的数量低于某个数值时,4S店马上向厂家发出订单。因此,safe_q;最小为1,最大为10。 利润总额profit = 总销售量*5-固定费用总额-订货费用总额-利息总额 平均月纯利:av_profit = 利润总额/总的月数

69 一个双因素的ANOVA实验的实例过程 CAR_STO STORAGE 10 ;仓库的最大容量 GENERATE 45,3 ;顾客到达
ASSIGN S_KEY,RN1 ;该顾客的随机购买数值参数(0-999) GATE SNE CAR_STO,NO_CAR ;是否有现货检测 ASSIGN L_KEY, ;有现货,成交水平线参数为30(3%) T_O TEST LE P$S_KEY,P$L_KEY,NO_SALES ;测试是否成交 SALES QUEUE WAIT_CAR ;顾客进入等待提车队列 GATE SNE CAR_STO ;检测仓库是否有现车 DEPART WAIT_CAR ;若有现车进入仓库提车 LEAVE CAR_STO,1 ;从仓库中提走一台车 SAVEVALUE sales_num+,1 ;销售数量增加一辆 SAVEVALUE cars_inhand-,1 ;可供销售的车减少一辆 NO_SALES TERMINATE ;顾客离开 NO_CAR ASSIGN L_KEY, ;无现货时顾客的成交水平线为10(1%) TRANSFER ,T_O ;转向T_O语句进行成交测试 GENERATE ;每10分钟检测一次安全库存量 TEST L X$cars_inhand,safe_q,L_END ;检测安全库存量,若在安全线;以上转向L_END SAVEVALUE order_fee+,5 ;4S店向厂商订车,订货费用增加5万 SAVEVALUE cars_inhand+,order_q ;可供销售的车增加order_q ADVANCE (8#8#60),(2#8#60) ;订货到达路途延时 ASSIGN l_p,order_q ;本次到达的汽车数 CAR_IN ENTER CAR_STO,1 ;汽车进入仓库,每次进入一辆 LOOP l_p,CAR_IN ;直到所有汽车全部入库 L_END TERMINATE ;本次安全库存检测或订贷过程结束 GENERATE (30#8#60) ;每月进行一次核算 SAVEVALUE months+,1 SAVEVALUE interest+,(0.01#28#X$cars_inhand) ;存货资金占用利息,月息按存货进价总值1%计算 TERMINATE ;当月核算结束 GENERATE (3#12#30#8#60+1) ;三年产生一次最终核算业务 SAVEVALUE profit,(5#X$sales_num-X$order_fee-35#X$months-X$interest) ;三年总利润计算 #代表乘法,5#X$sales_num表示每一台汽 车的销售差价5万乘以总销量, 35#X$months代表每月35万的固定费用之合, SAVEVALUE av_profit,(X$profit/X$months) ;平均月利润计算 TERMINATE ;结束模拟。 ;以下名为W_M的PLUS过程是为了将每次实验结果存入矩阵RESULTS而定义的。 PROCEDURE W_M(ARG1,ARG2,ARG3,ARG4)BEGIN RESULTS[ARG1,ARG2,ARG3]=ARG4; END;

70 程序代码:9-1-6build.gps 这段代码是为了自动生成实验文件9-1-6.txt
GENERATE ,,,1 OPEN("9-1-6.TXT"),1,DONE ASSIGN X_ID,13 ; X_ID 代表X_1数的变化值范围 ASSIGN X_START, ; X_START代表X数变化的起点水平 ASSIGN Y_ID,19 ; Y_ID 代表Y_1数的变化值范围 ASSIGN Y_START, ; Y_START代表Y数变化的起点水平 ASSIGN Z_ID,5 ; Z_ID 代表实验次数的变化值范围 ASSIGN K_ID,1 ; K_ID 代表Z数,也是Z数变化的起点水平 WRITE (PolyCatenate("RESULTS MATRIX ,",STRING(P$X_ID),",",STRING(P$Y_ID),",",STRING(P$Z_ID))),1,DONE ASSIGN L_X,P$X_ID ASSIGN I_ID,1 X_L ASSIGN 1,101 ASSIGN 2,201 ASSIGN 3,301 ASSIGN 4,401 ASSIGN 5,501 ASSIGN 6,601 ASSIGN 7,701 ASSIGN L_Y,P$Y_ID ASSIGN J_ID,1 Y_L WRITE (PolyCatenate("order_q EQU ",STRING(P$I_ID+P$X_START-1))),1,DONE WRITE (PolyCatenate("safe_q EQU ",STRING(P$J_ID+P$Y_START-1))),1,DONE ASSIGN L_Z,P$Z_ID ASSIGN K_ID,1Z_L WRITE (PolyCatenate("RMULT ",STRING(P1),",",STRING(P2),",",STRING(P3),",",STRING(P4),",",STRING(P5),",",STRING(P6),",",STRING(P7))),1,DONE WRITE "START 1,NP",1,DONE WRITE (PolyCatenate("PLUS(W_M(",STRING(P$I_ID),",",STRING(P$J_ID),",",STRING(P$K_ID),",X$av_profit))")),1,DONE WRITE "CLEAR OFF",1,DONE WRITE "INITIAL X$months,1",1,DONE WRITE "INITIAL X$sales_num,0",1,DONE WRITE "INITIAL X$cars_inhand,0",1,DONE WRITE "INITIAL X$order_fee,0",1,DONE WRITE "INITIAL X$interest,0",1,DONE WRITE " ",1,DONE ASSIGN 1+,11 ASSIGN 2+,11 ASSIGN 3+,11 ASSIGN 4+,11 ASSIGN 5+,11 ASSIGN 6+,11 ASSIGN 7+,11 ASSIGN K_ID+,1 LOOP L_Z,Z_L ASSIGN J_ID+,1 LOOP L_Y,Y_L ASSIGN I_ID+,1 LOOP L_X,X_L CLOSE E_RR,1 DONE TERMINATE 1


Download ppt "矩阵定义命令 NAME MATRIX A,B,C,D,E,F,G NAME :矩阵名称 A :必须为空值,是为了与以前的版本兼容"

Similar presentations


Ads by Google