User's guide chapter 3 section 11 & 12

Previous: Chapter 2 Next: Chapter 4

3.11 – Action Logic

ProcessModel allows you to design custom behavior in your model by using action logic in which you enter simple but powerful logic statements. Action logic allows you to define special logic that may not be easily defined using the normal property fields. Examples would include assigning values to attributes and variables or performing a test using an IF…THEN statement.

Action logic can be defined for any activity, storage, arrival or routing by clicking on the Action tab of the properties dialog.

Depending on the object or connection for which the action is defined, only certain statements and other logic elements are meaningful and therefore valid. The valid statements and logic elements (variables, attributes, resources, distributions, operators, and scenario parameters) are available via the Keywords and Filters (Keywords & filters) dialog. These statements and elements may be pasted from the list box into the action window to help you construct the desired action logic.

Action Logic zoom window

You may also start typing your saved attributes, variable, scenarios, scenario parameters, activity, entity, resource names or any of the ProcessModel supported statements, functions or distributions to see a help menu popup to help you easily populate what you wish to add.

Auto help for action logic

Paste elements into the action window

1. Click the Keywords and Filters Keywords & filters button on the action logic window.

2. Select the type of element (including statements) you want from the pull down box.

3. Select the specific element or statement from the list box.

4. Press the Insert button to insert the element at the position of the cursor in the action edit window or simply double-click the item.

Important information to be aware of Action Logic often uses expressions (combinations of attributes, variables, numbers, and operators) in assigning values to attributes or variables, testing the value or state of a variable or attribute, etc. For more information on expressions and valid operators, see Expressions.

See Also To learn advance functions / Keyboard shortcuts, see “Advanced Options for Action Logic Window”.

3.11.1 – Functions

Functions provide you with critical system information at any given time during the simulation. They can be used in an assignment statement to set the value of a variable or attribute or in an IF…THEN statement to make a decision based on system information. There are several system functions: Clock(), Contents(), FreeCap(), FreeUnits(), GroupQty(), OwnedResource(), Percent(), and ResQty().

 System reserved words cannot be used as variable names, attributes, or scenario parameters.

Clock( )

Clock(min)
Clock(sec)
Clock(hr)
Clock(Day)
Clock(Wk)

Syntax:

CLOCK( ) or CLOCK(time unit)

Example:

a_Time = Clock( )
v_Time_in_System =
Clock( ) – CycleStart
If Clock(Hr) > 24
Then…

The default clock function returns the elapsed time of the simulation clock in minutes. It can be accessed, but not assigned a value. For example a variable could be assigned the value of the clock in minutes: v_Var1 = Clock() would result in the number of minutes elapsed in the simulation assigned to the variable. To assign the number of hours that have elapsed, use v_Var1 = Clock(hr), and to get the number of seconds, use v_Var1 = Clock(sec).

More Information

A common use of the Clock( ) function is collect and plot individual cycle times for entities. It can be used to help collect individual times in just part of the model or individual entities for the entire cycle time. Why would this be important? Doesn’t ProcessModel automatically collect and report the average cycle time for each entity type? Yes it does, but a major reason for simulation is to dig deeper than averages, because averages are misleading.

ProcessModel automatically notes the simulation clock time when each entity first enters the process and writes that information to a default entity attribute called CycleStart. You can use a formula below calculate and record the processing time for each entity.

Example: v_Time = Clock() – CycleStart

Each entity that crosses the action statement that contains this formula will find out the current simulation time, subtract the starting time of the entity and write the result to variable defined (in this case, v_Time).

Many times, however, it is helpful to know the time it takes for an entity to complete only a portion of the process, for example activities 4 to 6 of a larger process. In this case, you would enter a_attribute1 = clock() in the action logic of the route entering activity 4. [Not specifying a unit of time by not putting anything in the parentheses after “clock” causes ProcessModel to use the default time unit which is minutes.] This would cause ProcessModel to note the time that each entity enters activity 4. You would also enter v_variable1 = clock() – a_attribute1 in the action logic of the route leaving activity 6. This would cause ProcessModel to take a new clock reading, subtract from it the first clock reading, and write to a variable that reflected the difference which you could then track in your output reports.

Important information to be aware of If you change the default time units to hours, then the value returned will be divided by 60. If you change the default time units to seconds, then the value returned will be multiplied by 60.

Contents(name of activity) 

Returns the total number of entities at an activity. Use CONTENTS() to make decisions based on how busy an activity is. Using CONTENTS() to keep track of the number of entities at an activity requires fewer steps and allows more flexibility than using variables to count the number of entities that enter and exit an activity. For example, the second syntax does in one statement what would require several statements without the CONTENTS() function.

Example

A car wash has an activity called Wash that often gets too busy for one operator to handle so the supervisor then comes to help. The logic below models this situation with an IF…THEN statement and the CONTENTS() function. As long as the activity contains fewer than three cars, the worker processes any arriving car. However, if the contents of the activity are greater than three, the Supervisor may also be used.

IF CONTENTS(Wash) {

GET Worker

}
ELSE
{

GET Worker OR Supervisor

}

FreeCap(name of activity) 

Returns the available capacity of an activity (an integer).

Example

Suppose an entity can be routed to one of two identical ovens for a curing process. However, you would like to ensure the ovens are loaded as evenly as possible at all times. The following logic could be used to set an attribute (called a_Router) to a 1 or a 2 based on the available capacity of the ovens. Conditional routings would then be used to route to the appropriate oven:

IF FREECAP(Oven1) > FREECAP(Oven2) THEN
{

a_Router=1

}
ELSE {a_Router=2}

FreeUnits(name of activity or resource) 

Returns the free units of an activity or resource (an integer).

Example

The example below demonstrates the use of the FREEUNITS() function to adjust the processing time for an entity based on the number of units of a resource available to process it. Once a Plane arrives at a passenger gate, it captures a certain number of resources named BH (Baggage Handlers). Operation logic at the gate determines how many BH resources have been captured and, accordingly, how long it will take to service the Plane. The more Baggage Handlers a Plane captures, the less time it takes to service it.

WHILE FREEUNITS(BH) <3
{

DO TIME(2 min)

}
IF FREEUNITS(BH)>=5 THEN {GET 5 BH}
ELSE
{

GET FREEUNITS(BH) BH
TIME(60/RESQTY(BH) min)

}

GroupQty( ) 

Returns the number of entities in a batched or loaded entity (a loaded entity is an entity with other entities attached to it). If the entity is a loaded entity, it will return only the number of loaded entities, not the base entity. For example, if you attach four Castings to a Pallet, the GroupQty() will return the number of Castings (i.e. 4), which does not include the entity Pallet.

In the case of multiple levels of groups and loads, GroupQty() returns the number of entities in the uppermost level only.

Example

A group of documents called Folder arrives at the Secretary in-box and is processed for some amount of time according to the number of documents in the folder. Each document takes 3.0 minutes to process.

TIME (GROUPQTY() *3.0 min)

OwnedResource(n) 

Returns the n th resource currently being used by the entity. Each resource is referenced according to the order it was put into use so that the longest held resource is OwnedResource(1). The most recently captured resource can be referenced by omitting the number: OwnedResource().

Example

The OwnedResource() function is useful when a decision must be made based on the resource that was captured. For example, suppose an entity captures either Worker_1 or Worker_2 in order to perform an activity. If Worker_1 is used, the activity takes 5 minutes. If Worker_2 is used, the activity takes 6.5 minutes. This can be defined using the following Action logic.

GET Worker_1 OR Worker_2
IF OWNEDRESOURCE() = Worker_1 THEN {TIME(5.0 min)}
ELSE {TIME(6.5 min)}
FREE OWNEDRESOURCE()

Important information to be aware of This function cannot be assigned a resource name in Action logic. For example, an assignment statement like OwnedResource() = Worker_1 will generate an error.

Percent(n) 

The percent function allows you to execute one or more statements only a certain percentage of the time. Used in an IF…THEN statement, the function returns a TRUE or FALSE.

To use the percent function, enter PERCENT(n) where n is the percentage of the time that the statement will return a TRUE condition in an IF…THEN statement.

Example

In the first example, logic following the THEN statement is executed 21.5% of the time. In the second, logic following the THEN statement is executed 35% of the time and the logic following the ELSE statement is executed 65% of the time.

1) IF PERCENT(21.5) THEN…
2) IF PERCENT(35) THEN…

ELSE…

ResQty(name of resource) 

Returns the number of units of a specific resource that the current entity owns. You can use RESQTY() to determine the amount of time necessary to process an entity based on the number of units of a resource the entity owns.

Example

The example below demonstrates the use of RESQTY() to adjust the processing time for an entity based on the number of resources available to process it. Once a Plane arrives at a passenger gate, it captures a certain number of resources named BH (Baggage Handlers). Operation logic at the gate determines how many BH resources have been captured and, accordingly, how long it will take to service the Plane. The more Baggage Handlers a Plane captures, the less time it takes to service it.

IF FREEUNITS(BH)>=5 THEN {GET 5 BH}
ELSE
{

GET FREEUNITS(BH) BH

}
TIME(45/RESQTY(BH) min)

3.11.2 Statements

Statements are simply commands to be executed at particular stages in an entity’s progress through the process. The following pages explain in detail each statement listed below.

 System reserved words cannot be used as variable names, attributes, or scenario parameters.

Comments
( ) = ( ) assignment
ANIMATE
DEC
DISPLAY
FREE
GET
INC
IF…THEN…ELSE
JOINTLYGET
NEWGRAPHIC
NEWNAME
PAUSE
REPORT
STOP
TIME
WAIT UNTIL
WHILE…DO

Comments

Comments You can add explanatory comments to your action logic by placing special characters in front of the comment. Comment lines are for user information only and the simulation ignores them during run time. To include a single-line comment, use a pound sign “#” or two forward slashes “//” at the beginning of the line. Multiline comments begin with a “/*”… and end with a “*/”. Some statements and functions such as GET or FREE are not ignored when found in a single comment line. To ensure they are ignored, you must use the multiline /* . . . */ comment indicators, and the ending “*/” must appear on a different line than the opening “/*”.

 FREE, GET, and JOINTLYGET, PERCENT and GROUP statements are not ignored by the // comment indicator. Use the /* … */ comment indicators. These indicators are normally used to comment multiple lines. So if you are only commenting out a single line, the closing */ must appear on a second line since it cannot exist on the same line as the opening /*.

For example:

IF Test = Reject THEN INC RejectQty
/*Number of rejects increased
for each test reject.*/

or…

// The logic below describes how rejects are handled.

( ) = ( )

This is the assignment statement which allows you to assign a value (or descriptor) to a variable or to one of the attributes defined for your entities.

Syntax

assignee = assignor

assignee The variable or attribute to which the value is assigned.
assignor The value assigned to the variable. This could be another variable or attribute, a pre-defined descriptor, or a mathematical expression.

Example

In the first example, the attribute a_ Attr1 is assigned a value of 2. The second example assigns the value of a_ PO_No to the attribute a_ Invoice_No . Number three assigns the descriptor Red to the attribute a_ Color . And the last example assigns the product of 5 and the value of Base to the attribute a_ Size.

1) a_Attr1 = 2
2) a_Invoice_No = a_PO_No
3) a_Color = Red
4) a_Size = 5 * Base

ANIMATE

The ANIMATE statement allows the control of the animation speed through the action logic dialog.

Syntax

ANIMATE(speed)

speed A numeric value between 0 and 100. One is the slowest and one hundred is the fastest speed of animation. A speed of zero turns the animation off.

Example

In the first example, ANIMATE statement is used to turn the animation off so that the model will run ahead in time quickly. In the second example the speed of animation is set very slow (usually to show a particular entity or activity). In the third example the speed of animation is set to the highest possible speed with animation still on (often used to help the user gain a “feel” for the general flow and buildups that would occur over time.

1) animate(0)
2) animate(10)
3) animate(100)

The ANIMATE statement is usually implemented by placing a separate entity, arrival and activity combination in the existing model. Scheduled arrivals work well because the exact time can be assigned for the arrival(s) and individual action logic applies for each scheduled arrival. The first arrival could be used to “fast forward” to a time in the model of particular importance, while the next arrival could be used to slow the animation for inspection of a particular aspect of the simulation and then a third to again “fast forward” to see the results.

DEC

The decrement statement allows you to decrement a variable or attribute’s value. It subtracts one (the default) or more from the value of the variable or attribute.

Syntax

DEC name [, expression]

name This is the name of the variable or attribute to be decremented.

[expression] You can optionally decrement the variable or attribute by more than one using an expression which can be a constant or a mathematical expression. The name and expression must be separated by a comma. (The square brackets illustrate only that this element is optional.)

Example

The following are several easy-to-understand examples. The first decrements the value of v_ Var1 by one. The second decrements the value of a_ Attr1 by five. The third decrements the value of Number_in_System by the value of an attribute called a_ Batch_Size.

1) DEC v_Var1
2) DEC a_Attr1, 5
3) DEC Number_in_System, a_Batch_Size

DISPLAY

Pauses the simulation and displays a message. The simulation will resume when the user selects OK.

Syntax

DISPLAY “< text string >” [,< attribute / variable / function call >]
DISPLAY “Now completing the 100th set”
DISPLAY “The current number of entries is: “, Var1
DISPLAY “Var1 = “, Var1 $ CHAR(13) $ “Attr1 = ” $ Attr1

text string The message ProcessModel will display. The text string must be enclosed in quotes.

[attribute / variable / function call] The text string or numeric value you wish to display.

After the original set of information (i.e. text string, variable) the “$” character is used to add additional information (i.e another text string or variable). You can force a carriage return by using the statement CHAR(13). Each new item that is appended to the statement must be prefaced with the “$” character.

Example 1

This example displays a message whenever a new order type begins processing at the current activity. A variable, v_ Last_Order , stores the order type of the last entity processed at the activity. If the current entity’s a_ Order_Type attribute value is different from the previous order type, ProcessModel displays a message stating the new order’s type.

IF Order_Type <> Last_Order THEN
{

DISPLAY “New Order Type: ”, a_Order_Type
v_Last_Order = a_Order_Type

}

Example 2

This example displays the entity name during simulation.

Display “Entity Name = “, Name

Or

Display “Entity Name = “, Ent(Name)

Using just Name will display the entity number rather than the text name. Name is the system defined attribute which contains the numeric value of the entity name. Ent(Name) will display the text name of the entity.

Important information to be aware of The display statement is valuable for debugging complex models and for halting a model temporarily during a presentation to display information.

FREE

The free statement allows you to free a resource (or resources) being used by the current entity.

Syntax

FREE [ quantity ] resource
FREE [ quantity ] resource , [ quantity ] resource , …
FREE ALL

[quantity] The number of units of the following resource to free. If no quantity is used, the quantity is assumed to be one. (The square brackets illustrate only that this element is optional.)

resource The name of the resource or list of resource names to be freed. If any resource specified is not being used by the current entity, it is simply ignored.

ALL The keyword used with the FREE statement to free all captured resources.

Example

In the following example, an entity, which earlier captured the resource Operator, frees the Operator after a three minute activity time. This action is followed by an increment of the variable called v_TimesUsed.

TIME(3 min)
FREE Operator
INC v_TimesUsed

If no action statements follow the freeing of a resource, the resource can just as easily be freed by drawing a Free resource assignment connection between the resource and the activity.

GET

The get statement enables an entity to obtain a resource. ProcessModel attempts to capture the resources in the order they are listed. If multiple resources are requested, but not available, those that are available will be captured and tied up until all are available.

If you get and free your resources in action logic (rather than with a connector line), the entity must enter the activity before it knows whether a resource is available or not. Therefore, if the resource is not available and the entity must wait “in” the activity for the resource to be available as compared to the GET/FREE route where the entity will wait at the input queue for the resource to be available before entering the activity.

To have the GET/ FREE action logic to behave in the same manner as the GET / FREE routes, add an extra activity that will server as the input queue, before the the activity where you want the resource to work. Remove the input/output queue from the new activity as well as the working activity. Change the capacity of the new activity to the input queu size for the work activity and GET the resource at the new activity.

Syntax

GET [ quantity ] resource, [ priority ]
GET [ quantity ] resource, [ priority ] AND [ quantity ] resource, [ priority ]
GET [ quantity ] resource, [ priority ] OR [ quantity ] resource, [ priority]

[quantity] You can optionally specify the number of resources to get if the resource has multiple units defined for it. (The square brackets illustrate only that this element is optional.)

Important information to be aware of By default, quantity is equal to one unit of the resource.

resource The name of the resource to be captured.

AND Used to capture more than one resource as each becomes available. To wait until all become available before capturing any of them, use the JOINTLYGET statement.

OR Used to capture one resource or the other. Useful for situations where one of several resources could be used to accomplish the same thing.

[priority] You can optionally specify priority level to get the resource (0-99). The higher the number, the higher priority. A priority above 99 will become an interrupt priority, to learn more see Chapter 10, Section 10.5.8, Interrupting Resources. (The square brackets illustrate only that this element is optional.)

Example

The following examples demonstrate the use of the GET statement. The first shows a simple request for a resource called Operator . The second tests the Size attribute to determine whether or not the Operator and Helper are needed. And the third requests three units of the resource called Operator.

1) GET Operator
2) IF Size > 10 THEN GET Operator AND Helper
3) GET 3 Operator

Important information to be aware of Connected resources will always be captured before resources specified in a GET statement. On the other hand, resource connections that free a resource occur after any Action logic for the activity.

IF…THEN…ELSE

The if statement is used to test for a condition and then execute sections of logic based on whether that condition is True or False. The condition is described with a Boolean expression , If the condition is True, the logic flow branches one way. If the condition is False, the flow branches in another direction.

If-Then statements can be added to Action Logic fields of the following objects:

  • Arrivals
  • Activities
  • Storages
  • Routings

Syntax

If Boolean Expression Then
{

Statement

}

If Boolean Expression Then
{

Statement1

}
Else
{

Statement2

}

If Boolean Expression Then
{

Statement1
Statement2

}
Else
{

Statement3
Statement4

}

If Boolean Expression Then
{

Statement

}

If Boolean Expression Then
{

Statement1

}
Else
{

Statement2

}

If Boolean Expression Then
{

Statement1

}
Else
{

If Boolean Expression Then
{

Statement

}

}

conditional expression Is a comparative expression using comparison operators like the equals sign (=) and the less than/greater than symbols (< >). The result of this expression is either true or false (yes or no). Multiple or alternative conditions can be tested using the operators AND and OR. Parentheses may be used for nesting expressions.

statement_1 This statement is executed if the conditional expression is true. This can also be a block of statements started with a BEGIN keyword or symbol ({ ) and ended with the END keyword or symbol ( }).

statement_2 This statement, preceded by the keyword ELSE, is executed if the conditional expression is false. This can also be a block of statements started with a BEGIN keyword or symbol ({ ) and ended with the END keyword or symbol ( }).

Rules

  • All words must have at least one space separation
    NO IfName = Rework YES If Name=Rework OR If Name = Rework
  • If more than one action is the result of the If-Then statement, the group of statements must be bracketed By the Begin and End statements or {…}

    If Name = Phone_Call Then
    {

    Inc v_Calls
    Time(5 min)

    }
    Else
    {

    Inc v_Fax
    Time(10 min)

    }

    In the Example above if the Attribute “name” contains the word Phone_Call, then the statement is true. the statements after the THEN will be executed and all the statements after the Else will be skipped.

  • Indenting and carriage returns are optional — but if you want to be able to read your work next week, group blocks of statements and indent so that it is easy to see the result of true or false conditions.

Example

In the following examples the IF…THEN…ELSE statement is used to make decisions about what happens in the model. In the first example, the variable v_Calls is incremented if the Name has the same descriptor value as Phone_Call. The second example shows a decision made based on the a_Patient_Type. If the patient is critical, both a Nurse and a Doctor resource are needed. Otherwise, only a nurse is captured and the activity takes less time.

1)
IF Name = Phone_Call THEN INC v_Calls

2)
IF a_Patient_Type = Critical THEN
{

GET Nurse AND Doctor
TIME(N(30, 5) min)
FREE ALL

}
ELSE
{

GET Nurse
TIME(N(8, 1) min)
FREE ALL

}

INC

The increment statement allows you to increment a variable or attribute’s value. It adds one (the default) or more to the value of the variable or attribute.

Syntax

INC name [, expression]

name This is the name of the variable or attribute to be incremented.

[expression] You can optionally increment the variable or attribute by more than one using an expression which can be a constant or a mathematical expression. The name and expression must be separated by a comma. (The square brackets illustrate only that this element is optional.)

Example

The following are several easy-to-understand examples. The first increments the value of v_ Var1 by one. The second increments the value of a_ Attr1 by five. And the third increments the value of v_ Number_in_System by the value of v_ Num_Processed plus one.

1) INC v_Var1
2) INC a_Attr1, 5
3) INC v_Number_in_System, v_Num_Processed +1

JOINTLYGET

This statement allows an entity to get more than one resource, but not until they all become available.

Syntax

JOINTLYGET [ quantity ] resource, [ priority ]
JOINTLYGET [ quantity ] resource, [ priority ] AND [ quantity ] resource, [ priority ]
JOINTLYGET [ quantity ] resource, [ priority ] OR [ quantity ] resource, [ priority]

[quantity] Optionally specify the number of units of the resource that you want to capture. (The square brackets illustrate only that this element is optional.)

Important information to be aware of By default, quantity is equal to one unit of the resource.

resource The name of the resource you want to capture.

AND Used to capture more than one resource once they all become available. To capture multiple resources as each one becomes available, use the GET statement.

OR Used to capture one resource or the other. Useful for situations where one of several resources could be used to accomplish the same thing.

[priority] You can optionally specify priority level to get the resource (0-999). The higher the number, the higher priority. (The square brackets illustrate only that this element is optional.)

Example

The following examples demonstrate the use of the JOINTLYGET statement. The first shows a simple request for a resource called Operator and a resource called Helper. The second tests the a_ Size attribute to determine whether or not the Operator needs two Helper resources. The third example requests the Operator and three units of the resource called Helper . If three helpers are not available, the statement may get two operators and two helpers.

1) JOINTLYGET Operator AND Helper
2) IF a_Size > 10 THEN JOINTLYGET Operator AND 2 Helper
3) JOINTLYGET (Operator AND 3 Helper) OR (2 Operator AND 2 Helper)

NEWGRAPHIC

This statement allows you to change an entity’s graphic without changing the name of the entity. The NEWGRAPHIC statement will permit you to graphically depict a change in an entity’s state without affecting the statistics collected for the original entity. The NEWGRAPHIC statement allows depiction of:

• assembly, by adding to the complexity of graphics
• value or size change, by increasing the size of the graphics
• exception tracking, by changing the color of the graphic.

For more information, see Finding Graphic ID Numbers.

Syntax

NEWGRAPHIC(id#)

id# The identification number of the new entity graphic you want to use in the animation. Numbers (1-20) are pre-assigned to the entities in the standard entities shape palette. When you place entity graphics on the layout, ProcessModel adds them internally as graphic number 21, 22, 23, . . . and so on.

Example

Suppose you want a completed order to appear with a different graphic. To do this, you would use the NewGraphic statement for the entity (e.g. Order) to change its ID from 21 to 22 (this will substitute a new graphic for the original). At the activity or connection where the change takes place, enter the following statement in the Action logic:

NEWGRAPHIC(22)

NEWNAME

This statement allows you to change the name of an entity along with its graphic so that model animation as well as statistical reports will reflect the change. In effect, this statement reassigns the entity the name enclosed in parentheses and changes the graphic i.d. number appropriately.

Syntax

NEWNAME(name)

name The new name assigned to the entity with its accompanying graphic if defined on the layout. The new entity and its graphic must be previously defined on the layout when using this statement.

Example

We want to see completed orders as a different graphic and collect statistics on the completed orders, so we use the NewName statement on the entity named Order. At the activity or connection where the change takes place, enter the following in properties dialog Action logic:

NEWNAME(Completed_Order)

An entity can be renamed using either the New Name drop down list in a routing Properties Dialog Box, or the NEWNAME statement in action logic. When renaming, all attributes from the original entity are inherited except the system created attributes ID and Name. The system created attributes which are inherited are Cost, CycleStart, and VATime.

PAUSE

Pauses the simulation and (optionally) displays a user-specified message. This pause allows you to examine the system in detail by using menu items from the Options and Information menu. The simulation will continue only when the user selects Resume Simulation from the Simulation menu.

Syntax

PAUSE [< text string >]
PAUSE
PAUSE “Work in Process levels are critically low.”

text string The optional message ProcessModel will display.

Example

The simple example below pauses the simulation after the 100th Claim has been processed at activity Quality Check. The purpose for doing this might be to view the current state of the system at this particular point in time.

INC v_Total
IF v_Total >= 100 THEN
{

PAUSE “Total = 100”
v_Total=0

}

REPORT

Calculates and reports the current statistics to the output database. This is useful to get a snapshot of the model at various points during the simulation.

The REPORT statement may be followed by the WITH RESET option to reset the statistics after the report is made to the database. When you use the WITH RESET option, you generally want to provide some periodic looping event that will call the report function at specific times.

Used with the AS option, REPORT creates a report with the name specified in the expression.

Syntax

REPORT [WITH RESET] [AS < text string >]
REPORT
REPORT WITH RESET
IF v_thruput = 50 THEN REPORT AS “RepOvr50”

text string A unique name given to the report so it can be easily identified in the General Stats dialog in the Output Program. If any reports have the same name, a number is tacked on the end of the name to make it unique.

Example

To get a snapshot report every 40 hours, schedule a “dummy entity” to arrive periodically (every 40 hours) at a “dummy activity.” In the action logic field, enter the statement REPORT WITH RESET AS 40HOUR and set the activity time to 0.

Report syntax action logic

This results in reports named, 40HOUR, 40HOUR2, 40HOUR3, etc.

 Variables are not automatically reset. You will need to manually reset the variables with the report statement if they are being used to track statistics.

 When a REPORT statement is used in a model, the final report is not generated. So unless a Report statement occurs exactly at the end of the simulation, there will likely be some additional processing that occurs. But that last bit of processing won’t be reported. Make sure the last Report statement occurs exactly at the end of simulation time.

 The “reset” doesn’t reset the number of entities in the activity. So at the start of each new report, there could be entities already in the activity. Therefore, if we add the Total Entries values for each report, we will have a number greater than the actual number of entities that entered that activity. Rather than add the Total Entries values, increment a variable in the activity in question. Then view that variable in the output report.

STOP

Terminates the current replication and optionally displays a message. The simulation will then continue with the next replication. Use STOP to end a replication when a user-defined condition becomes true.

Syntax

STOP [<“ text string” >]
STOP
STOP “Normal termination”

text string An optional message to display when the replication stops.

Example

The example below uses a STOP statement to terminate the simulation whenever the variable v_Total_Complete reaches 100.

INC v_Total_Complete
IF v_Total_Complete = 100 THEN

STOP

TIME

The time statement allows you to require the entity to spend time at an activity and has the same effect as entering a time value under the General tab of the properties dialog. This permits you to define a processing time based on logical criteria such as the value of an entity attribute.

Syntax

TIME( time expression <wk/day/hr/min/sec >)

time expression The amount of time to detain the entity at the activity. It can also be expressed as a distribution to add variability to the processing time.

<hr/min/sec> The time unit for the expression.

Caution DO NOT use this statement in an arrival connection’s Action logic. Doing so will result in an error when you run the simulation.

Example 1

In the first example, a 5-second activity time is specified. In the second, the activity time is a normal distribution with a mean of 10 minutes and a standard deviation of 2.5 minutes. The third example illustrates a discrete distribution function where the activity has a 20% chance of taking 5 minutes, a 30% chance of taking 8 minutes, and a 50% chance of taking 10 minutes. The fourth example uses a mathematical expression to indicate an activity time in hours equal to 2.5 times the value of the a_ Size attribute.

1) TIME(5 sec)
2) TIME(N(10, 2.5) min)
3) TIME(D3(20, 5, 30, 8, 50, 10) min)
4) TIME(a_Size * 2.5 hr)

Important information to be aware of The time expression and time unit must be used together and separated by a space. A Day time unit equals 24 hours and Week time unit equals 168 hours.

Example 2

Using a Time statement with 0 time can be a very helpful piece of action logic. The purpose of this statement is to place the current entity at the bottom of the simulation’s processing stack. One application of this kind of statement is as follows. Suppose you want to have 20 items enter a storage, one at a time or in groups, and have all 20 items leave the storage at the same time. You can accomplish this with batching. However, you can simplify your model by using the following action logic in a storage.

Inc v_Counter
Wait Until v_Counter = 20
Time(0 Min)
Dec v_Counter

This action logic will count entities entering the storage, and hold them until there are 20. Once the Wait condition is true, all 20 entities move to the Time statement which will place each entity at the bottom of the simulation’s pending actions queue. The result is that the v_Counter variable is not decremented until all 20 entities have passed the Time statement. Since the pr