![]() ![]()
|
CHAPTER 10
Customizing a Model with Attributes and ExpressionsSIMPROCESS provides a wide range of predefined model elements and statistical options, but every business Process is unique in some way. There will be times when flexibility is needed to model complex situations, and the built-in functions of SIMPROCESS may be inadequate. In those cases, Attributes and Expressions can be defined.For example, a typical SIMPROCESS model for an appliance manufacturer's distribution Process might include a batch Activity where customer orders are collected for shipment. Products may be shipped on a predetermined schedule, or when the total number of pending orders reaches a certain number. The SIMPROCESS Batch Activity readily handles these scenarios with the Quantity to Batch and Release Threshold options.But suppose the dispatching of a shipment depends on the total weight of the appliances that have been accumulated. How is this situation modeled?
Customizing reports is another area where flexibility might be needed. SIMPROCESS provides several reports that track the flow of Entities through a model. The values for how many Entities of a particular type (each customer order, for example) are processed during simulation, or the average amount of time an Entity takes to make its way through the simulation are available in the Standard Report.But suppose the percentage of orders that are shipped by a promised delivery date (service level) is needed to measure success in attaining service goals.Two advanced SIMPROCESS features, Attributes and Expressions, provide the ability to handle these and many other situations.Introduction to Attributes and Expressions
Attributes
Attributes are user-defined and built-in variables of model elements whose values can change during the course of a simulation run. For example, for a Batch Process where Entity release depends on the weight of the Entities received, an Attribute is the total weight of the items accumulated in the Batch Activity.To determine the percentage of orders processed within a specified period of time, Attributes need to track the processing time for each order, the number of orders that meet the promised delivery date, and the total number of orders processed.Attributes may be used to:· Alter the behavior of a Process by changing the value of an Attribute during a simulation· Communicate information (such as Attribute values) between two Processes in a model· Store data collected during a simulation run.There are two categories of SIMPROCESS Attributes: built-in System Attributes, which SIMPROCESS automatically creates and updates, and User Defined Attributes, which the user creates. For example, the number of Entities generated for each Entity type (e.g., number of orders) is automatically tracked and stored in a built-in System Attribute namedNumberCreated. To track an Attribute such as weight, which SIMPROCESS does not know about, an Attribute calledapplianceWeightcould be created.Some System Attributes can be modified by users. These are called "Get-Set" type System Attributes. Generally, these are variables that control Process parameters such as the number of Entities to batch or amount of time of the next delay. By modifying these System Attributes, the behavior of the simulation can be affected.System Attributes that cannot be changed include those that monitor statistics, such as the number of Entities generated during the simulation. These are called "Get-Only" type System Attributes. Information on the status of a simulation, such as which Activity is processing an Entity or what type of Entity is being processed, is also available through "Get-Only" System Attributes.See "SIMPROCESS System Attributes and Methods," beginning on page 511 for a complete list of System Attributes.Expressions
Attributes are a powerful simulation feature when used in conjunction with SIMPROCESS Expressions. Expressions are user-written statements that SIMPROCESS executes during a simulation run. Expressions are defined at the point at which the Expression is to be evaluated; for example, at the beginning of the simulation, or at the moment an Entity (e.g., a customer order) is received by an Activity (e.g., order distribution).In the case of the model where releasing of shipments depends on the total weight of orders such as appliances, the following could be done:1. An Attribute calledapplianceWeightcould be defined and its value set whenever an appliance-order Entity is generated by SIMPROCESS. The value to assignapplianceWeightwould be determined by checking the name of the Entity type (e.g., dishwasher-order, television-order). This information is available from the System AttributeName.2. When an Entity is received at the Batch Activity, the Entity'sapplianceWeightvalue would be added to the total weight of all orders waiting to be shipped (another User Attribute). The total weight would then be checked. If it exceeds a certain value, the Batch Activity would be forced to release a shipment.One way to force a shipment to be released is to change the batch size to a value equal to the current number of Entities in the Batch Activity. These values are available in System Attributes.This chapter describes:· Built-in System Attributes· User-Defined Attributes· How to write an Expression which uses User-Defined Attributes and System Attributes.Using Attributes in SIMPROCESS
This section contains a closer look at Attributes and how they can be used in SIMPROCESS. It starts with a look at the System Attributes built into SIMPROCESS and then goes on to a detailed discussion of User-Defined Attributes.System Attributes
SIMPROCESS provides access to the state of a simulation through a set of built-in variables. These System Attributes provide information such as:· The type of Entity currently in an Activity· The number of Entities of a particular type that have been generated thus far in the simulation· The name of the Activity holding a particular Entity· The type of Entity being generated by a Generate Activity.A complete list of System Attributes is given in "SIMPROCESS System Attributes and Methods," beginning on page 511. The table entries below show the Attributes accessible from Batch Activities:
1. The MaxBatchSize Attribute is an integer value representing the maximum number of Entities to batch at a Batch Activity. The current value of the Attribute can be retrieved and changed.2. The MinBatchSize Attribute is an integer value containing the minimum number of Entities a Batch Activity must hold before it can release a batched Entity.3. The Attribute MaxWaitTime specifies the maximum amount of time to wait before releasing the batched Entities that have met the Activity's MinBatchSize. The value is a real number (e.g., 1.0, 7.5, etc.) representing the time unit selected for the maximum wait time. The value of this Attribute can be retrieved and changed.User Defined Attributes
Customizing a model begins with defining Attributes. These Attributes can represent model element Attributes that are not built into SIMPROCESS, such as Entity weight and size or skill level of a Resource.Attributes can be defined in association with:· Entity types or Entity instances· Processes or Activities· Resources· The Model itself.How an Attribute is defined tells SIMPROCESS whether to create an instance of that Attribute for every model element of the same type (e.g., Entities, Resources), or to just create the Attribute for a particular type of model element (customer order Entities, truck Resources). In SIMPROCESS terminology, Attributes are either globally-defined or locally-defined. Model Attributes are only globally-defined.When an Attribute is defined globally, an instance of that Attribute is automatically created for each model element of that class. For example, if the model contains Entities of different types of appliances (refrigerators, televisions, toasters, etc.) and a weight value needs to be assigned to each Entity, a global Entity Attribute could be defined (applianceWeight). SIMPROCESS creates an instance of that Attribute for every Entity in the model, so every Entity has an appliance weight Attribute which can be referenced.The only Activity concerned with weight is the Activity where Entities are batched. In this case, it makes sense to locally define an Attribute for that particular Activity. When that's done, no other Activity will have a weight Attribute automatically created for it.Note that Attributes for different model elements can have the same name. For example, a global Attribute called applianceWeight could be defined for Resources. It can have a completely different meaning and data type. Global and local Attributes for the same model element cannot have the same name.All attributes (global or local) are managed using a table similar to Entities and Resources. Changes to global attribute definitions from the table cannot be canceled. Each table can be sorted by a particular column by clicking the column header. Holding the Shift key while clicking the column header causes the sort to be in reverse order.Creating a User Defined Attribute
Global Attributes can be defined from the SIMPROCESS menu or from the dialog of a model element. Local Attributes can only be defined from the dialog of a model element.Globally Defining an Attribute from the Menu
To globally define an Attribute from the SIMPROCESS menu select Global Attributes... from the Define menu. The following dialog appears:
The Global Attribute Definitions dialog is used to add a new Attribute or to change, copy, or delete existing Attributes. There are five tabs: Entity, Entity Type, Resource, Activity, and Model. Each tab represents model elements for which global Attributes can be defined. Note that the Entity tab defines Attributes for each Entity instance created by the simulation. The originating Entity Type for the Entity instance is not considered. So every Entity instance created by the simulation will have an instance of each Attribute listed on the Entity tab. Attributes defined from the Entity Type tab are assigned to each Entity Type. That is, for all Attributes listed on the Entity Type tab, there is one of each Attribute created for each Entity Type that all Entity instances originating from that type can reference. Each tab shows the names of all Attributes of that type previously defined. If no Attributes have been defined, the list in each tab will be empty and the Edit, Copy, and Remove buttons will be inactive. The Undo button activates when an Attribute is removed. Select the Entity tab and click on Add to create a new Attribute.In the Attribute Properties dialog:Name can be anything (except as noted below), as long as the name has not been previously used for another Attribute of the same class of model element. For new Attributes, SIMPROCESS initializes the field with a default name.Value is the default initial value of this Attribute. The value must correspond to the data type specified in the Mode field. For instance, 1.0 cannot be entered if the Mode is Integer. If the Mode is Object, the Default value is UNDEFINED. An Object Attribute's value can only be set during a simulation run. Anything entered in the Default field is ignored. (See Mode types below.)Mode is the data type of the Attribute. Click on the arrow button to select either Integer, Real, String, Boolean, or Object:Integer values are numbers without fractional or decimal parts.Real values can contain fractional parts.A String is any series of alphanumeric characters.Boolean values can be either TRUE or FALSE.An Object is a reference to another model element in the model, a reference for Expression Language constructs, or a reference to external Java classes. For example, during a simulation an Object Attribute can point to an Activity in the model.Array Dimension allows for Attributes to be set up as an array. The default value of 0 means the Attribute is not an array. If an array dimension is provided and the user wishes to reference the Attribute in the Expression language, it must be done using an integer subscript (e.g.,myattribute[2] := value;). The subscripted arrays are zero-based, meaning that a subscript of 0 refers to the first item in the array.Model Parameter, when checked, means that every time the model is run, a dialog will open allowing new initial values to be entered for the Attribute. Only global, user-defined Attributes can be set as Model Parameters. If a Comment is entered for the Attribute, this will appear in the Description field of the Model Parameters dialog when the Attribute is selected.Model Parameters can be changed during a simulation run by selecting Change Model Parameters from the Simulate menu. Note that changing the value of Model Parameters during a simulation run may or may not affect the simulation. For instance, if the Model Parameter is used to set the number of units of a Resource, changing the value of the Model Parameter will have no affect on the simulation since the units of a Resource are set at the beginning of a simulation run. However, changes to Model Parameters used to control entity flow or used for time durations will affect the simulation. If the Model Parameter is an Entity instance attribute, only Entities created after the change will reflect the change.There is another option that does not appear on the properties dialog for global Entity Attributes. Do Not Reset Before Each Replication is a property of global Entity Type, Resource, Activity, and Model Attributes. If Reset System is selected on the Run Settings (page 109), all Attributes (other than Entity Attributes) are reset to their initial value before each replication. This does not happen if Do Not Reset Before Each Replication is selected. The Attribute maintains its current value.Statistics Types refer to statistics collected for Attributes during a simulation run. These statistics are used in SIMPROCESS reports. Note that no statistics can be collected for Entity instance Attributes.Observation Based and Time-Weighted refer to the way statistics are collected:Observation Based tells SIMPROCESS to collect statistical data without considering the amount of time an Attribute maintains a particular level. Each time the value of an Attribute changes, the new value is added to a running total.Time-Weighted provides time-weighted statistics. That is, the length of time an Attribute remains at a particular value is factored into the statistical data when the average value is calculated.Real Time Histogram Plot tells SIMPROCESS to plot the Attribute value changes as they occur during the simulation run (Real Time Plot) using a Histogram-type graphic. The plots can be saved, printed, resized, and re-read from prior saves using the menu on the Plot dialog.Real Time Trace Plot tells SIMPROCESS to plot the Attribute value changes as they occur during the simulation run to a trace type graphic. The trace plots can be manipulated similar to the Histogram Plots.Standard Report tells SIMPROCESS to write the statistics to the standard report file.Click on OK to accept the options selected, or click on Cancel to exit without setting/resetting any options.
An existing user Attribute can be copied by selecting the Attribute in the table and then clicking on the Copy button. The Global Attribute Properties dialog is displayed with the options and defaults set to the values of the copied Attribute.To remove an existing user Attribute, select the Attribute from the table, and then click on the Remove button. The Undo button will restore an Attribute definition that was removed.The Local button is on every tab except the Model tab (Model Attributes are only global). Selecting Local brings up a dialog that displays all model elements of the same type that have local Attributes. For example, the Local button on the Activity tab shows all Activities that have local Attributes defined. Selecting an item on the left displays the local Attributes for that item on the right. An item on the left can be edited by double clicking or by selecting the Edit... button. Note that from this dialog local Attributes cannot be defined for items that do not already have local Attributes.
Click on Close when finished defining or modifying global Attributes.Globally Defining Attributes from Dialogs
All global Attributes (other than Model Attributes) can also be accessed from the properties dialog of the appropriate model element (Entity, Resource, or Activity). For example, assume a model has three Entities defined (refrigerator-order, television-order, and toaster-order). Selecting Entities... from the Define menu, brings up the list of defined Entities.
Editing the refrigerator-order brings up the properties dialog. The image below shows the Entity Attributes tab selected.
There are no local Entity Attributes defined for this Entity. The Global button brings up the Global Attribute Definitions dialog with the appropriate tab active. Since the Entity Attribute tab is selected on the Entity properties dialog, the Entity tab will be active on the Global Attribute Definitions dialog. Note that the Local button is missing since the Global Attribute Definitions dialog was opened from the properties dialog of a model element.
Defining a Local Attribute for a Model Element
A local Attribute is defined for a single model element (Entity, Resource, or Activity). Local Attributes are defined from the properties dialog of the model element. Note that Entity instance and Entity Type local Attributes are both defined from the Entity properties dialog (Entity Attributes and Entity Type Attributes tabs). The Resource and Activity properties dialog each have an Attributes tab. Attributes defined locally exist only for the model element in which they were defined. Local Attributes are managed in the same manner as the Global Attributes by using the Add..., Edit..., Copy..., and Remove buttons. The Attributes tab for Resource properties is shown below.
Assign Activity
The Assign Activity can be used to assign values to globally defined Attributes and local Entity instance and Entity Type Attributes. The Assign can also change the priority of an Entity.Changing an Attribute Value with the Assign Activity
The Set Attribute list box of the Assign Activity is used to change the value of any global Attribute (except globally-defined Resource Attributes) and local Entity instance and Entity Type Attributes. Once an Attribute has been selected, clicking on the Add button will open up the Assign Attribute Properties dialog.The combo box in the Set Attributes field contains the names of all the Attributes that the Assign Activity can access. Selecting an Attribute from the pull down list and then clicking on the Add button will open the Attribute Assignment dialog where the Attribute value is specified. Likewise, by selecting an Attribute from the left side of the Set Attributes list and clicking on the Remove or Edit buttons an Attribute assignment can be removed or changed.The Operation field contains the operators that can be used to change the value of the selected Attribute. The supported operators are; =, +, -, *, and / (equals, addition, subtraction, multiplication, and division).The Value field contains the value to be used with the Operation. This can take the form of a constant, a Statistical Distribution, a User-defined Function, or an Evaluate (Evl) Function. User-defined Functions can be found on page 293 of this chapter. The Evaluate Function is covered on page 263.
Each time an Entity enters the Assign Activity, the Set Attribute commands are performed.Important: If the Attribute selected for assignment is a local Entity or Entity Type Attribute, a run time error will occur if an Entity enters the Activity that does not have the selected Attribute defined.Variable Resource Usage
User-defined Attributes can be used to request units of Resources. Using an Attribute allows the units of Resource required by each Entity to vary. For instance, in the example from Chapter 5 (page 152) an Entity needed one unit of the Service Rep Resource for that Activity.Thus, every Entity will get one and only one unit of the Resource. However, there may be instances where the amount of Resources needed would be different for each Entity. This is true many times when using consumable Resources (such as fuel). Any type of Attribute may be used to set these levels (Entity, Entity.Type, Resource, Activity, or Model). When Attributes are used, they must be provided in the Evl distribution function such as "Evl(Model.myattribute)." The Evl function gives added flexibility since mathematical functions can be used with the Attributes. "Evl(Model.myattribute + (Entity.myEntityattribute * SQRT(Activity.myActivityattribute))" is an example.In addition to Attributes, any statistical distribution may be used. Use Edit to modify the existing requirement definition and then enter the Attribute that will have the unit information. The Attribute must be a real or integer type Attribute.
During the simulation run, if the units of Resource requested is larger than the Resource capacity, the Entity will not proceed since there will never be more units available than capacity. This will not occur when using consumable Resources. If the Resource is consumable, the Entity will continue when more Resource units are available. Also, if a fractional number of units is requested and fractional usage was not selected for the Resource, an error will occur.Writing Expressions
The previous section discussed how to define user Attributes. This section discusses how to use them.For Attributes to be useful, they must be able to be accessed and changed during a simulation run. SIMPROCESS provides opportunities to do this at many points during a simulation. The instructions written to process Attributes and SIMPROCESS model elements are called Expressions.An Expression is a user-defined routine that runs within the larger SIMPROCESS program. In effect, SIMPROCESS checks at various points during a simulation run to see if there are any special instructions for it. If so, it runs the code. Expressions accomplish simulation and modeling requirements for which standard SIMPROCESS processing does not support.The SIMPROCESS Expression language is introduced first, then how Expressions are implemented is explained.SIMPROCESS Expression Language Basics
The SIMPROCESS Expression language contains the basic features of any programming language. Complex Expressions can be written in this language.In the definitions that follow, the word expression with a lower case "e" refers to a mathematical expression. Expression with a capital "E" refers to the SIMPROCESS Expressions feature.Types
SIMPROCESS supports a limited set of data types. The supported types are as follows:· BOOLEANA variable that contains the binary values of TRUE or FALSE· REALA variable that contains a real number· INTEGERA variable that contains an integer number· STRINGA variable that contains an array of charactersTypes are specified in either one of two ways: by declaring a variable local to the Expression such as the variablesmyRealandmyString:myReal : REAL;myString : STRING;or by selecting the Attribute type from the Attribute definition dialogs. The Attribute definition dialogs support the same types that can be declared locally in the Expression. However, the data type of Object is not supported in the Expressions. ANYOBJ is used instead of Object.Operators
· Assignment OperatorThe assignment operator is used to assign a value to an Attribute::=For example:x := 15;assignWeight := 1000;The colon (:) preceding the equal sign (=) is required. An error will occur if it is omitted.String values can be concatenated using the + operator:For example:mystring1:= "hello ";mystring2:= "dolly";mystring3:= mystring1 + mystring2;The string mystring3 now contains the value "hello dolly". String concatenation can also be used on functions that return string values such as the SUBSTR function.For example:mystring1:= SUBSTR(0,5,mystring3) + " dude";The variable mystring1 will now contain "hello dude".· Compare OperatorAn equal sign without a preceding colon is used when comparing two values. Thus, the statement beginning:IF assignWeight = 1000...compares the value of Attribute assignWeight to the number 1000.· Arithmetic Operators used in the SIMPROCESS Expression language are+(addition),-(subtraction),*(multiplication),/(division),DIV(integer division), andMOD(modulus).· Relational Operators include=,<>(not equal),<, <=, >, >=.Literals
· A string of printable characters on a single line is enclosed in quotation marks:"The plain in Spain looks lovely in the rain.";· A boolean literal is entered as uppercase TRUE or FALSE:myBool := TRUE;· An integer literal is entered as a whole number:myInteger := 67;· A real literal is entered as a whole number plus a decimal, fraction, or whole number plus a fraction:myReal1 := 67.;myReal2 := 67.133;myReal3 := 0.345;Type Checking
· The use of variables (both those defined locally in the Expression and those defined as Attributes) in Expressions will be checked for correct type on assignment statements. For example, the following code will produce a type mismatch by the Expression interpreter.myReal : REAL;myString : STRING;myString := "Hello Dolly";myReal := myReal + myString;
System Methods
· System methods are commands which result in a system action or return a value from the underlying system. One commonly-used function isSimTime, which returns a Real number containing the current simulation time.· For a list of System Methods available in SIMPROCESS, refer to page 521.Expression Language Statements
·IF condition{ELSIF condition}{ELSE condition}END IF;·WHILE conditionEND WHILE;·FOR expression TO|DOWNTO expression [BY expression]END FOR;·RETURN (possible return value)·EXIT (with WHILE or FOR loops)·OUTPUTSIMPROCESS Expression language syntax:1. The SIMPROCESS Expression language is case sensitive. An Attribute namedApplianceweightis not the same Attribute as the Attribute referred to asapplianceWeight.2. All built-in language elements are in capital letters (IF,END,WHILE, etc.).3. Each Expression language statement ends with a semicolon (;). The exceptions to this are lines that begin with IF, ELSIF, ELSE, WHILE, and FOR.4. Comments can be included in Expressions by enclosing them in curly brackets ({ }). For example:{This is a comment}Do not end a comment line with a semicolon.5. Basic conditional logic has the form:IF a < bx := c;ELSIF a < cx := d;END IF;For example:IF batchweight > 2000MaxBatchSize := 100;batchWeight := 0;ELSIF batchweight > 1800MaxBatchSize := 110;END IF;Messages can be displayed in the SIMPROCESS Expression Output Dialog with theOUTPUTstatement. This is useful for tracking the value of Attributes as a simulation proceeds. TheOUTPUTstatement has the form:OUTPUT(expression);For example:OUTPUT("Just assigned a weight to Entity");OUTPUT("Current batch weight ", batchWeight);In the second example, the value of AttributebatchWeightis displayed following the text "Current batch weight ". The literal string and Attribute name are separated by a comma so the actualbatchWeightvalue will appear next to the string.
Expression Editor
Editing any Expression activation event brings up the Expression Editor, shown below. On the right is the text area for entering the Expression. The dialog contains a single menu, Edit, which includes the traditional Cut, Copy, Paste and Select All items. It also includes Find..., Replace... and Go To... items, any of which display a dialog containing Find, Replace and Go To Line tabs. The Find and Replace features include matching case, whole word searching, search up/down direction selection, and a Replace All command. The Go To Line tab allows movement directly to any given line number of the expression text, which can be useful when a validation error message includes a line number. Entering a very large number goes to the last line; entering zero or a negative value goes to the first line; entering a non-numeric value causes an error message to be displayed.
On the left are four tabs (Expression Language, System Methods, System Attributes, and User Defined Attributes) listing the items that can be included in the Expression. The Expression Language tab lists data types, operators, and constructs of the SIMPROCESS Expression Language along with a description of the selected item. The System Methods tab lists the System Methods available for SIMPROCESS along with the Arguments, the type the system method Returns, and a Description of the selected item. The System Attributes tab lists the System Attributes defined for each simulation object in SIMPROCESS. Included is the Get/Set property of the Attribute, the Type of the Attribute (e.g., INTEGER, REAL), and a Description of the selected item. (See "SIMPROCESS System Attributes and Methods," beginning on page 511 for more information on System Attributes and System Methods.) The User Defined Attributes tab lists all the global Attributes defined in the model and any local Attributes defined for the Expression owner including the Type of the selected Attribute. Double clicking an item on any of the lists causes the item to appear in the Expression text area.The Validate button below the text area checks the syntax of the Expression without closing the editor. The Done button checks the syntax of the Expression and, if there are no errors, closes the Expression editor.Expressions entered into the Expression editor are saved as a part of the model file. This is the preferred method of storing Expressions since copies made of the model file (either external to SIMPROCESS or with Save As) will automatically have any Expressions that were defined in the original model file, all the capabilities of the Expression Search feature (page 40) are available, and templates defined (page 225) will also have any Expressions included in the original item being templated. However, Expressions can also be stored in external files. This can be useful if the same Expression is used multiple places, or if there is a need to change an Expression without opening the model. The same Expression file can be used with multiple models, but this is discouraged since it is best if the Expression file is stored in the model's directory. Storing an Expression file in the model's directory shows clear linkage between an Expression file and a model. An Expression file must be an ASCII file. If a word processor is used to create the file, make sure the file is saved in text format. Note that when using Expression Search, if the Search For field is empty, the Expression Search will find any item that has an Expression whether stored in the model or stored in a file, but searches for specific text ignore Expressions in files.To use an external file for an Expression select the Use Expression in File checkbox, and enter a file name in the adjoining text field. If the file name does not have a path included, the file is assumed to be in the model's directory. If a path is included, it must be a complete path. SIMPROCESS will not create the file entered in the text field. The file must be created by an editor independent of SIMPROCESS. When there is already a file assigned, the text of the Expression file is loaded into the Expression editor when the editor opens. If the file is assigned after the editor opens, the Refresh button can be used to load the Expression. Expressions from files are not editable in the Expression editor. The text of an Expression in a file is loaded into the Expression editor so the syntax of the Expression can be checked using the Validate button. Expressions edited in another editor should always have the syntax checked before running the simulation. If the syntax error is caught at run time the simulation will stop. If the Validate button shows there are errors, the Expression can be modified in another editor, the file re-saved, and then the Expression reloaded using the Refresh button. Clicking the Done button checks the syntax before closing the Expression editor. However, unlike when the expression is stored in the model, the option to close with errors is available.If the Use Expression in File checkbox is deselected, the text of the Expression becomes editable. However, if the editor is closed with Use Expression in File deselected, the Expression becomes a part of the model. If Use Expression in File is reselected before closing the editor, any changes made are lost since Expressions are only read from the specified file. Changes to the Expression must be done and saved to the file in another editor. Expressions can be copied from the SIMPROCESS Expression Editor and pasted into another editor by highlighting the desired text and using the Copy and Paste commands.Using Attributes in Expressions
The value of an Attribute may be useful in the calculation of an Expression for a different construct than that for which the Attribute was defined. For instance, the duration of a Delay Activity could take the value of an Attribute of the Entity currently at the Delay Activity. To do so, the Expression on the Activity must access the value of the Attribute on the Entity. This is accomplished by referring to the Entity Attribute with the prefix "Entity." followed by the name of the Entity Attribute.Using the duration example above, for an Entity Attribute called "TimeFactor", the duration that each Entity (that carries theTimeFactorAttribute) will spend at a Delay Activity can be set with the following statement:NextDelay := Entity.TimeFactor;By placing the above statement in the "Accept Entity" activation event (for a listing of activation events, see "Expression Activation Events," beginning on page 264) on the Delay Activity, the value of the System Attribute,NextDelay, will take the value of theTimeFactorAttribute. The result is, for each instance of an Entity reaching this Activity, its processing time at that Activity is determined by the value of the Entity Attribute,TimeFactor, that each instance of the Entity carries. However, this assumes that there is no wait for Resources. If an Entity has to wait, another Entity could enter and changeNextDelaybefore the first Entity is able to process. The preferred method is to use the Evaluate function in the Duration Value field on the Delay Activity to return the value of the AttributeTimeFactor. This method is better, since the duration of each Entity at the Delay Activity is calculated from theTimeFactorAttribute. This is visible on the Properties dialog of the Delay rather than in an Expression. Also, there is no possibility of another Entity changing the value of the delay. See the "Evaluate (Evl) Function" on page 263 for more detail.The format would be similar for an Entity Type Attribute. If the Attribute to be referenced was named "TypeTime", it would be used in the Expression of a construct other than an Entity as:Entity.Type.TypeTimeThe same holds true for Attributes of other SIMPROCESS constructs as well. An Activity Attribute called "ActivAttr" that is referenced in an Expression on a construct other than an Activity, would be referred to as:Activity.ActivAttrA Model Attribute calledModAttrwould be referred to as:Model.ModAttrUser-defined Resource Attributes can be accessed by an Expression from any other construct in SIMPROCESS, and values can be assigned to those Attributes by using the syntax described above. However, User-defined and System Attributes for Resources must be accessed by using theResourceSystem Method.For instance, to reference the number of units currently busy of the Resource called Resource1, use:Resource("Resource1").UnitsBusyThese are just some basics of the SIMPROCESS Expression language. See "System Method Examples" on page 551 for more detail.Evaluate (Evl) Function
The simplest use of an Expression is with the Evaluate (Evl) function. This function supports a single line Expression. That Expression can contain any of the System Methods, System Attributes, User-defined Attributes and Operators that are supported at the Activation Events level described in the next section. The Evl function can be found on any of the combo boxes where the standard distributions and User-defined Functions are listed.An example using the Evaluate function is a system with a processing time (Delay) that is a function of an Entity Attribute. Select theEvl(1.0)function on the Hours field from the Delay Activity's Properties dialog. Clicking the Detail button will open an Evaluate dialog where the Expression describing the processing time is entered. This example reads the Entity's processing time (given by the Entity AttributeProcTime) and multiplies it by 1.5. This value would then be the delay time for the Activity.Entity.ProcTimecould be typed in directly or selected from the Global Attributes list. Once selected in the Global Attributes list, the attribute can be added to the Expression by selecting Add Selection to Evl.Expression Activation Events
SIMPROCESS has a set of activation points at which it checks for the existence of Expressions, and then runs those that it finds. An Expression is assigned to an activation point at the time it is defined.Each activation point corresponds to a simulation event and has a name identifying it to SIMPROCESS. For example, the start of a replication is referred to as theStart Simulationevent. TheStart Trialevent marks the beginning of a single trial within a replication (after warmup).
Some events can occur many times during a simulation. TheStart TrialandEnd Trialevents occur once during each replication of a multi-replication simulation. If the simulation contains only a single replication, these events occur just once. TheStart SimulationandEnd Simulationevents occur once during each replication of a multi-replication simulation if Reset System is selected in the Simulation Run Setting dialog. Otherwise, theStart Simulationevent occurs just once at the beginning of the first replication. TheEnd Simulationevent occurs at the end of the last replication. These are specified on the Expressions tab of Process, Activity, Resource, and Entity Type dialogs.
Start RunandEnd Runare model Expressions only (menu Define/Model Expressions). These Expressions are executed only once no matter how many replications are run.Start Runis the very first Expression executed, andEnd Runis the very last Expression executed. These Expressions are particularly useful for opening and closing files that are needed throughout the simulation. (See "Methods OpenFile, CloseFile, ReadFromFile, and WriteToFile:," beginning on page 555 for information on opening and closing files.) TheStart SimulationandStart Trialmodel Expressions are executed before theStart SimulationandStart TrialExpressions of Entity Types, Resources, Activities, and Processes. TheEnd SimulationandEnd Trialmodel Expressions are executed after theEnd SimulationandEnd TrialExpressions of Entity Types, Resources, Activities, and Processes.Events related to Entities and Resources can occur numerous times throughout a simulation trial. For example, an Entity's arrival at an Activity is a simulation event calledAccept Entity(so-called because the Entity is being accepted into the Activity). This can occur thousands of times during a long simulation, once for each Entity that arrives at the Activity.
Every Expression is associated with a specific SIMPROCESS model element. Select the model element that requires customized processing, specify the event at which the processing is to occur, and then write the Expression to do the processing. "Example: Batching Entities Based on Weight" on page 270, describes this Process in detail.Not every event is available as an activation point for every model element. For example, the initial value of an Attribute for an Entity can be set when the Entity is first generated (Initialize Entity), or when the Entity is released from a Generate Activity (Release Entity). But the value of an Entity Attribute cannot be set when the simulation first begins to run (Start Simulation), because no Entities have been generated at that point.The table below contains a complete list of activation events. Note that the order of the elements is the order in which the Expressions are executed.